composer.phar 2.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707
  1. #!/usr/bin/env php
  2. <?php
  3. /*
  4. * This file is part of Composer.
  5. *
  6. * (c) Nils Adermann <naderman@naderman.de>
  7. * Jordi Boggiano <j.boggiano@seld.be>
  8. *
  9. * For the full copyright and license information, please view
  10. * the license that is located at the bottom of this file.
  11. */
  12. // Avoid APC causing random fatal errors per https://github.com/composer/composer/issues/264
  13. if (extension_loaded('apc') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN) && filter_var(ini_get('apc.cache_by_default'), FILTER_VALIDATE_BOOLEAN)) {
  14. if (version_compare(phpversion('apc'), '3.0.12', '>=')) {
  15. ini_set('apc.cache_by_default', 0);
  16. } else {
  17. fwrite(STDERR, 'Warning: APC <= 3.0.12 may cause fatal errors when running composer commands.'.PHP_EOL);
  18. fwrite(STDERR, 'Update APC, or set apc.enable_cli or apc.cache_by_default to 0 in your php.ini.'.PHP_EOL);
  19. }
  20. }
  21. Phar::mapPhar('composer.phar');
  22. require 'phar://composer.phar/bin/composer';
  23. __HALT_COMPILER(); ?>
  24. .Ÿ�������� ���composer.phar����+���src/Composer/Autoload/AutoloadGenerator.php€��'‚`€��`KÑÔ¤������+���src/Composer/Autoload/ClassMapGenerator.phpÔ��'‚`Ô��ñ§¤���������src/Composer/Cache.phpJ��'‚`J��ˆ¿/‰¤������%���src/Composer/Command/AboutCommand.phpØ��'‚`Ø��ö÷;‡¤������'���src/Composer/Command/ArchiveCommand.phpÀ��'‚`À��Á’ =¤������$���src/Composer/Command/BaseCommand.phpE��'‚`E��Õ7z·¤������.���src/Composer/Command/BaseDependencyCommand.phpS��'‚`S��ªƒ"Ť������1���src/Composer/Command/CheckPlatformReqsCommand.php¹��'‚`¹��hV—¯¤������*���src/Composer/Command/ClearCacheCommand.phpó��'‚`ó��ˆ(*Ô¤������&���src/Composer/Command/ConfigCommand.phpûW��'‚`ûW���©»!¤������-���src/Composer/Command/CreateProjectCommand.phpQB��'‚`QB��ºŒA:¤������'���src/Composer/Command/DependsCommand.phpñ��'‚`ñ��kU‹{¤������(���src/Composer/Command/DiagnoseCommand.phpWJ��'‚`WJ��Ã
  25. œ¤������,���src/Composer/Command/DumpAutoloadCommand.php±��'‚`±��a#®¤������$���src/Composer/Command/ExecCommand.php ��'‚` ��?ìç¤������$���src/Composer/Command/FundCommand.php3 ��'‚`3 ��.½¤������&���src/Composer/Command/GlobalCommand.phpÅ ��'‚`Å ��©O:ü¤������$���src/Composer/Command/HomeCommand.php��'‚`��p—Τ������$���src/Composer/Command/InitCommand.phpy[��'‚`y[��›Uʤ������'���src/Composer/Command/InstallCommand.phpP��'‚`P��µœ¤������(���src/Composer/Command/LicensesCommand.phpZ��'‚`Z��OT@0¤������(���src/Composer/Command/OutdatedCommand.php� ��'‚`� ��7~½=¤������)���src/Composer/Command/ProhibitsCommand.php��'‚`��_¤éS¤������&���src/Composer/Command/RemoveCommand.php´)��'‚`´)��Y;”¤������'���src/Composer/Command/RequireCommand.php 7��'‚` 7��Í·Ǥ������)���src/Composer/Command/RunScriptCommand.phpF��'‚`F��8{O{¤������+���src/Composer/Command/ScriptAliasCommand.php¯��'‚`¯��?=Ѥ������&���src/Composer/Command/SearchCommand.phpT ��'‚`T ��ZÕ±¤������*���src/Composer/Command/SelfUpdateCommand.phpyD��'‚`yD��·¤A©¤������$���src/Composer/Command/ShowCommand.phpf‹��'‚`f‹��Ï„X+¤������&���src/Composer/Command/StatusCommand.phpë��'‚`ë��£c}¤������(���src/Composer/Command/SuggestsCommand.php˜ ��'‚`˜ ��=c{à¤������&���src/Composer/Command/UpdateCommand.php3��'‚`3���æÀ¤������(���src/Composer/Command/ValidateCommand.phpG��'‚`G��§ a¤���������src/Composer/Composer.php ��'‚` ��îÛl’¤���������src/Composer/Config.phpT%��'‚`T%��ÒCZ¤������-���src/Composer/Config/ConfigSourceInterface.php��'‚`���û¤������(���src/Composer/Config/JsonConfigSource.phpi��'‚`i��9jQ*¤������$���src/Composer/Console/Application.php <��'‚` <��šÖH¨¤������*���src/Composer/Console/GithubActionError.phph��'‚`h��œQÆt¤������,���src/Composer/Console/HtmlOutputFormatter.php0��'‚`0��^КҤ������-���src/Composer/DependencyResolver/Decisions.phpº��'‚`º��:ÎK¤������1���src/Composer/DependencyResolver/DefaultPolicy.phpñ��'‚`ñ��róM¦¤������/���src/Composer/DependencyResolver/GenericRule.php¡��'‚`¡��v'ù
  26. ¤������8���src/Composer/DependencyResolver/LocalRepoTransaction.phpQ��'‚`Q��í6Ĥ������3���src/Composer/DependencyResolver/LockTransaction.phps
  27. ��'‚`s
  28. ��­CÆ“¤������5���src/Composer/DependencyResolver/MultiConflictRule.php,��'‚`,��ðá¬$¤������>���src/Composer/DependencyResolver/Operation/InstallOperation.php·��'‚`·��#Ò­’¤������I���src/Composer/DependencyResolver/Operation/MarkAliasInstalledOperation.phpß��'‚`ß��=Ù÷À¤������K���src/Composer/DependencyResolver/Operation/MarkAliasUninstalledOperation.phpå��'‚`å��‡°¸/¤������@���src/Composer/DependencyResolver/Operation/OperationInterface.phpÚ���'‚`Ú���Qâè¤������=���src/Composer/DependencyResolver/Operation/SolverOperation.php��'‚`��mÑa¤������@���src/Composer/DependencyResolver/Operation/UninstallOperation.phpŸ��'‚`Ÿ��o ±(¤������=���src/Composer/DependencyResolver/Operation/UpdateOperation.phpG��'‚`G��–ˆ
  29. ¤������3���src/Composer/DependencyResolver/PolicyInterface.php7��'‚`7��ŽþR¤������(���src/Composer/DependencyResolver/Pool.phpO��'‚`O���(ž ¤������/���src/Composer/DependencyResolver/PoolBuilder.php:1��'‚`:1��Û Ü ¤������+���src/Composer/DependencyResolver/Problem.phpK6��'‚`K6��ƒ`Ãu¤������+���src/Composer/DependencyResolver/Request.phpë��'‚`ë��qid¤������(���src/Composer/DependencyResolver/Rule.phpJ'��'‚`J'��gë2¤������1���src/Composer/DependencyResolver/Rule2Literals.php��'‚`��^ Wá¤������+���src/Composer/DependencyResolver/RuleSet.phpr ��'‚`r ��bZ¬”¤������4���src/Composer/DependencyResolver/RuleSetGenerator.php¤��'‚`¤��Å�ÓÚ¤������3���src/Composer/DependencyResolver/RuleSetIterator.php ��'‚` ��…gØ,¤������2���src/Composer/DependencyResolver/RuleWatchChain.phpi��'‚`i��hïš,¤������2���src/Composer/DependencyResolver/RuleWatchGraph.php8 ��'‚`8 ��8ӎȤ������1���src/Composer/DependencyResolver/RuleWatchNode.php2��'‚`2��ü;㔤������*���src/Composer/DependencyResolver/Solver.php8��'‚`8��žN�’¤������6���src/Composer/DependencyResolver/SolverBugException.php™��'‚`™��Xg6¤������;���src/Composer/DependencyResolver/SolverProblemsException.phpÒ ��'‚`Ò ��Íi¾T¤������/���src/Composer/DependencyResolver/Transaction.php°��'‚`°��-­ïߤ������-���src/Composer/Downloader/ArchiveDownloader.php ��'‚` ��wZ¸w¤������1���src/Composer/Downloader/ChangeReportInterface.phpÌ���'‚`Ì���¯à¨¿¤������+���src/Composer/Downloader/DownloadManager.php4��'‚`4��]n(v¤������/���src/Composer/Downloader/DownloaderInterface.php��'‚`��<ê ¤������3���src/Composer/Downloader/DvcsDownloaderInterface.phpÑ���'‚`Ñ���&Áœ¿¤������*���src/Composer/Downloader/FileDownloader.phpV*��'‚`V*��êµ ¤������/���src/Composer/Downloader/FilesystemException.php
  30. ��'‚`
  31. ��.-‹¤������,���src/Composer/Downloader/FossilDownloader.phpÓ ��'‚`Ó ��™ó,¤������)���src/Composer/Downloader/GitDownloader.phpG>��'‚`G>��5­~ã¤������*���src/Composer/Downloader/GzipDownloader.phpÂ��'‚`Â�� Åtx¤������(���src/Composer/Downloader/HgDownloader.php ��'‚` ��uŸ?,¤������8���src/Composer/Downloader/MaxFileSizeExceededException.phps���'‚`s���Ù¢ ñ¤������*���src/Composer/Downloader/PathDownloader.phpg��'‚`g��èŽÖð¤������.���src/Composer/Downloader/PerforceDownloader.php ��'‚` ��=Ëw(¤������*���src/Composer/Downloader/PharDownloader.php'��'‚`'��i(¶¤������)���src/Composer/Downloader/RarDownloader.phpø��'‚`ø��6uÚ¤������)���src/Composer/Downloader/SvnDownloader.phpC��'‚`C��úø³0¤������)���src/Composer/Downloader/TarDownloader.php%��'‚`%��7³Øm¤������.���src/Composer/Downloader/TransportException.php��'‚`��¥¬ï‰¤������9���src/Composer/Downloader/VcsCapableDownloaderInterface.phpÔ���'‚`Ô���`§ôö¤������)���src/Composer/Downloader/VcsDownloader.php7��'‚`7��³ÌûY¤������(���src/Composer/Downloader/XzDownloader.php3��'‚`3��4ÍYä������)���src/Composer/Downloader/ZipDownloader.phpî��'‚`î��Eý½¤������&���src/Composer/EventDispatcher/Event.php ��'‚` ��±™jï¤������0���src/Composer/EventDispatcher/EventDispatcher.phpz.��'‚`z.��Z{N³¤������9���src/Composer/EventDispatcher/EventSubscriberInterface.php©���'‚`©���h·0¤������9���src/Composer/EventDispatcher/ScriptExecutionException.phpv���'‚`v���wZ8S¤������9���src/Composer/Exception/IrrecoverableDownloadException.phpv���'‚`v���DM½y¤������)���src/Composer/Exception/NoSslException.phph���'‚`h���ˆdñÓ¤���������src/Composer/Factory.phpÔB��'‚`ÔB��ÑZµ¤���������src/Composer/IO/BaseIO.php��'‚`��ŸÛ
  32. =¤���������src/Composer/IO/BufferIO.php¶��'‚`¶��ȼ†¦¤���������src/Composer/IO/ConsoleIO.php¬��'‚`¬��¡ã;N¤���������src/Composer/IO/IOInterface.phpØ��'‚`Ø��Fò°ð¤���������src/Composer/IO/NullIO.phpÀ��'‚`À��F`sʤ������"���src/Composer/InstalledVersions.phpý��'‚`ý��ï[S¤���������src/Composer/Installer.phpuw��'‚`uw��¨Öc¤������*���src/Composer/Installer/BinaryInstaller.php��'‚`��a·Á¤������2���src/Composer/Installer/BinaryPresenceInterface.phpË���'‚`Ë���À5š¨¤������.���src/Composer/Installer/InstallationManager.phpz2��'‚`z2��ž<&ì¤������)���src/Composer/Installer/InstallerEvent.phpå��'‚`å��ÎE N¤������*���src/Composer/Installer/InstallerEvents.php…���'‚`…���nÜ<Á¤������-���src/Composer/Installer/InstallerInterface.phpI��'‚`I��µªØ\¤������+���src/Composer/Installer/LibraryInstaller.phpk��'‚`k��¸/ý—¤������/���src/Composer/Installer/MetapackageInstaller.phpÍ��'‚`Í��·p(ù¤������(���src/Composer/Installer/NoopInstaller.php]��'‚`]��Û‰öÓ¤������'���src/Composer/Installer/PackageEvent.php–��'‚`–��=¯³X¤������(���src/Composer/Installer/PackageEvents.php¸��'‚`¸��dbØs¤������*���src/Composer/Installer/PluginInstaller.phpM
  33. ��'‚`M
  34. ��<—Ȥ������+���src/Composer/Installer/ProjectInstaller.phpf��'‚`f��ÙÇ“B¤������4���src/Composer/Installer/SuggestedPackagesReporter.php��'‚`��îÐD¤���������src/Composer/Json/JsonFile.php¦��'‚`¦��B>i,¤������#���src/Composer/Json/JsonFormatter.phpS��'‚`S��†e¤������%���src/Composer/Json/JsonManipulator.php¸7��'‚`¸7��hy¤������-���src/Composer/Json/JsonValidationException.php\��'‚`\��.Xóܤ������%���src/Composer/Package/AliasPackage.phpè��'‚`è��lÞ½­¤������7���src/Composer/Package/Archiver/ArchivableFilesFilter.php ��'‚` ��yY+¦¤������7���src/Composer/Package/Archiver/ArchivableFilesFinder.phpæ��'‚`æ��U`Ƥ������0���src/Composer/Package/Archiver/ArchiveManager.php^��'‚`^��?b"7¤������3���src/Composer/Package/Archiver/ArchiverInterface.php��'‚`��ñ´> ¤������3���src/Composer/Package/Archiver/BaseExcludeFilter.php~��'‚`~��!Ê p¤������7���src/Composer/Package/Archiver/ComposerExcludeFilter.php��'‚`��‹SZ0¤������2���src/Composer/Package/Archiver/GitExcludeFilter.phpr��'‚`r��3‘Mh¤������1���src/Composer/Package/Archiver/HgExcludeFilter.php
  35. ��'‚`
  36. ��&ðm(¤������.���src/Composer/Package/Archiver/PharArchiver.php8��'‚`8��Fx'M¤������-���src/Composer/Package/Archiver/ZipArchiver.php¤��'‚`¤��!Yò�¤������$���src/Composer/Package/BasePackage.php��'‚`�� `¼ ¤������*���src/Composer/Package/Comparer/Comparer.php©��'‚`©��þí%†¤������(���src/Composer/Package/CompletePackage.php§��'‚`§�� h“¤������1���src/Composer/Package/CompletePackageInterface.php��'‚`��2%ž¤������+���src/Composer/Package/Dumper/ArrayDumper.php ��'‚` ��Ã@Q¤���������src/Composer/Package/Link.phpÝ��'‚`Ý��ÃðÿФ������+���src/Composer/Package/Loader/ArrayLoader.phpŸ'��'‚`Ÿ'��›h[¤������7���src/Composer/Package/Loader/InvalidPackageException.phpE��'‚`E��xb¾¤������*���src/Composer/Package/Loader/JsonLoader.php°��'‚`°��Vœ\‹¤������/���src/Composer/Package/Loader/LoaderInterface.php²���'‚`²���¦}úΤ������1���src/Composer/Package/Loader/RootPackageLoader.phpñ��'‚`ñ��9JÛ¤������5���src/Composer/Package/Loader/ValidatingArrayLoader.phpžA��'‚`žA�� _‚ï¤���������src/Composer/Package/Locker.php!%��'‚`!%��ÑÞ¤������ ���src/Composer/Package/Package.php��'‚`��åwQ0¤������)���src/Composer/Package/PackageInterface.php� ��'‚`� ��H^K_¤������)���src/Composer/Package/RootAliasPackage.phpH ��'‚`H ��ëie`¤������$���src/Composer/Package/RootPackage.phpI��'‚`I��q]V¤������-���src/Composer/Package/RootPackageInterface.php¹��'‚`¹��"maV¤������0���src/Composer/Package/Version/StabilityFilter.phpé��'‚`é��Äi— ¤������/���src/Composer/Package/Version/VersionGuesser.php§$��'‚`§$��É"=å¤������.���src/Composer/Package/Version/VersionParser.phpý��'‚`ý��4º�Τ������0���src/Composer/Package/Version/VersionSelector.php‹��'‚`‹��Ó‘úo¤������&���src/Composer/Platform/HhvmDetector.phpñ��'‚`ñ��”\龤������!���src/Composer/Platform/Runtime.phpA��'‚`A��ò¥|¤������!���src/Composer/Platform/Version.php”��'‚`”��÷ða©¤������-���src/Composer/Plugin/Capability/Capability.phpW���'‚`W���æ_¨1¤������2���src/Composer/Plugin/Capability/CommandProvider.php—���'‚`—���ûOâ>¤���������src/Composer/Plugin/Capable.php���'‚`���Æq+¤������$���src/Composer/Plugin/CommandEvent.phpâ��'‚`â��³ÆÇW¤������$���src/Composer/Plugin/PluginEvents.phpe��'‚`e��*U~r¤������'���src/Composer/Plugin/PluginInterface.phpŽ��'‚`Ž���4%~¤������%���src/Composer/Plugin/PluginManager.php¿.��'‚`¿.��„Ë令������-���src/Composer/Plugin/PostFileDownloadEvent.phpá��'‚`á��M+æ¤������*���src/Composer/Plugin/PreCommandRunEvent.phpõ��'‚`õ��:ðd¤������,���src/Composer/Plugin/PreFileDownloadEvent.phpO��'‚`O��¾­wÀ¤������*���src/Composer/Plugin/PrePoolCreateEvent.phpA��'‚`A��x¼”y¤������4���src/Composer/Question/StrictConfirmationQuestion.php��'‚`��'.³è¤������+���src/Composer/Repository/ArrayRepository.phpæ��'‚`æ��­J—¤������.���src/Composer/Repository/ArtifactRepository.phpó ��'‚`ó ��æ¦í‚¤������.���src/Composer/Repository/ComposerRepository.php~‡��'‚`~‡�� ÖN­¤������/���src/Composer/Repository/CompositeRepository.phpO ��'‚`O ��¤¾ŸŽ¤������;���src/Composer/Repository/ConfigurableRepositoryInterface.php…���'‚`…���±Ÿ_¤������0���src/Composer/Repository/FilesystemRepository.phpð��'‚`ð��Ë@âm¤������,���src/Composer/Repository/FilterRepository.php��'‚`��×y¯¢¤������4���src/Composer/Repository/InstalledArrayRepository.php1��'‚`1��]«×¤������9���src/Composer/Repository/InstalledFilesystemRepository.php1��'‚`1��y&êͤ������/���src/Composer/Repository/InstalledRepository.php¸��'‚`¸��Ëõ¤������8���src/Composer/Repository/InstalledRepositoryInterface.php¥���'‚`¥���Ã%¤������6���src/Composer/Repository/InvalidRepositoryException.phpn���'‚`n���à“똤������/���src/Composer/Repository/LockArrayRepository.php¤���'‚`¤���E™†S¤������-���src/Composer/Repository/PackageRepository.phpÑ��'‚`Ñ��«‰´¤������*���src/Composer/Repository/PathRepository.php(��'‚`(��b2L¤������*���src/Composer/Repository/PearRepository.phpæ���'‚`æ���¤5‘¤������.���src/Composer/Repository/PlatformRepository.phpƒH��'‚`ƒH��ø1̤������-���src/Composer/Repository/RepositoryFactory.php¥��'‚`¥��»í�N¤������/���src/Composer/Repository/RepositoryInterface.php;��'‚`;�� _‹¤������-���src/Composer/Repository/RepositoryManager.php ��'‚` ��´=x¤������7���src/Composer/Repository/RepositorySecurityException.phpo���'‚`o���pÕ«ª¤������)���src/Composer/Repository/RepositorySet.php¶��'‚`¶��\Oo¤������1���src/Composer/Repository/RootPackageRepository.php@��'‚`@��X¦Ž¤������/���src/Composer/Repository/Vcs/BitbucketDriver.php… ��'‚`… ��Ôðpñ¤������,���src/Composer/Repository/Vcs/FossilDriver.phpe��'‚`e�� n�¤������2���src/Composer/Repository/Vcs/GitBitbucketDriver.phpè��'‚`è��8$ë¤������)���src/Composer/Repository/Vcs/GitDriver.phpñ��'‚`ñ��2[]I¤������,���src/Composer/Repository/Vcs/GitHubDriver.phpï4��'‚`ï4���äw¤������,���src/Composer/Repository/Vcs/GitLabDriver.php +��'‚` +��úIÞ?¤������1���src/Composer/Repository/Vcs/HgBitbucketDriver.phpâ��'‚`â��¾Â`Y¤������(���src/Composer/Repository/Vcs/HgDriver.php ��'‚` ��{濤������.���src/Composer/Repository/Vcs/PerforceDriver.php¾ ��'‚`¾ ��ˆáÀ¤������)���src/Composer/Repository/Vcs/SvnDriver.php’��'‚`’��qh|š¤������)���src/Composer/Repository/Vcs/VcsDriver.phpd
  37. ��'‚`d
  38. ��=1\Ǥ������2���src/Composer/Repository/Vcs/VcsDriverInterface.php÷��'‚`÷��ÇX[‰¤������)���src/Composer/Repository/VcsRepository.phpT2��'‚`T2��VóÅF¤������1���src/Composer/Repository/VersionCacheInterface.php”���'‚`”���A?Rï¤������3���src/Composer/Repository/WritableArrayRepository.phpO��'‚`O��‰Ýê¤������7���src/Composer/Repository/WritableRepositoryInterface.phpS��'‚`S��5CgÓ¤���������src/Composer/Script/Event.phpš��'‚`š��Óô©¤������$���src/Composer/Script/ScriptEvents.phpÜ��'‚`Ü��ÆíÁ¤������ ���src/Composer/SelfUpdate/Keys.phpœ��'‚`œ��zeƒŽ¤������$���src/Composer/SelfUpdate/Versions.php6��'‚`6��0鮤������ ���src/Composer/Util/AuthHelper.php��'‚`��„‰ó]¤���������src/Composer/Util/Bitbucket.phpØ��'‚`Ø��¬5èõ¤������$���src/Composer/Util/ComposerMirror.php±��'‚`±��­½øؤ������%���src/Composer/Util/ConfigValidator.php1��'‚`1��È ¤������"���src/Composer/Util/ErrorHandler.phpº��'‚`º��ª¤������ ���src/Composer/Util/Filesystem.php•3��'‚`•3��Ó,å¤���������src/Composer/Util/Git.phpë0��'‚`ë0��ÒÀ£“¤���������src/Composer/Util/GitHub.phpU ��'‚`U ��½Qjø¤���������src/Composer/Util/GitLab.phpq��'‚`q��$͆¤���������src/Composer/Util/Hg.php´��'‚`´��ÁˆNì¤������)���src/Composer/Util/Http/CurlDownloader.php·>��'‚`·>�� èñD¤������'���src/Composer/Util/Http/CurlResponse.php]��'‚`]��Dæñ@¤������&���src/Composer/Util/Http/ProxyHelper.php7
  39. ��'‚`7
  40. ��m|¥�¤������'���src/Composer/Util/Http/ProxyManager.phpW
  41. ��'‚`W
  42. ��´ý…d¤������'���src/Composer/Util/Http/RequestProxy.php��'‚`��üA8¤������#���src/Composer/Util/Http/Response.php!��'‚`!��ö˜„Ò¤������$���src/Composer/Util/HttpDownloader.php¡$��'‚`¡$��\�·Û¤���������src/Composer/Util/IniHelper.phph��'‚`h��;FP¤���������src/Composer/Util/Loop.php˜��'‚`˜��IyþŒ¤������&���src/Composer/Util/MetadataMinifier.php¹��'‚`¹��Ñ«²Ù¤������$���src/Composer/Util/NoProxyPattern.phpt��'‚`t��¨­6¯¤������#���src/Composer/Util/PackageSorter.phpø��'‚`ø��Oê♤���������src/Composer/Util/Perforce.php\2��'‚`\2��.ÞÑõ¤���������src/Composer/Util/Platform.phpm��'‚`m��º8ƒ¤������%���src/Composer/Util/ProcessExecutor.phpD��'‚`D��;üs-¤������&���src/Composer/Util/RemoteFilesystem.phpzM��'‚`zM��¯Ù—ý¤���������src/Composer/Util/Silencer.phpè��'‚`è��¿5ѳ¤������*���src/Composer/Util/StreamContextFactory.php¨��'‚`¨��lçë¤���������src/Composer/Util/Svn.php!��'‚`!��:ÚÒl¤������ ���src/Composer/Util/SyncHelper.phpE��'‚`E��åá‰Ç¤���������src/Composer/Util/Tar.phpb��'‚`b��å]–¤���������src/Composer/Util/TlsHelper.phpH
  43. ��'‚`H
  44. ��ÌÚ¤���������src/Composer/Util/Url.phpí ��'‚`í ��‹…pƒ¤���������src/Composer/Util/Zip.php&��'‚`&��Ì>vT¤���������src/bootstrap.php¹��'‚`¹��I}œ¤������%���src/Composer/Autoload/ClassLoader.php8��'‚`8��4ˆ)Ť������#���res/composer-repository-schema.jsonñ��'‚`ñ��|0à„¤���������res/composer-schema.jsonÿª��'‚`ÿª��Ûp…¤���������vendor/autoload.php‚���'‚`‚���‚���������vendor/composer/ClassLoader.phpï��'‚`ï��™{H·¤������%���vendor/composer/InstalledVersions.phpf��'‚`f��ñt¿8¤������%���vendor/composer/autoload_classmap.phpµ���'‚`µ���x’ý»¤������"���vendor/composer/autoload_files.phpŒ��'‚`Œ��� ¤������'���vendor/composer/autoload_namespaces.php¢���'‚`¢����R7c¤������!���vendor/composer/autoload_psr4.php÷��'‚`÷��Å*š¤������!���vendor/composer/autoload_real.phpc��'‚`c��£××̤������#���vendor/composer/autoload_static.php¹ ��'‚`¹ ��™�†–¤������!���vendor/composer/ca-bundle/LICENSE��'‚`��G _¤������(���vendor/composer/ca-bundle/res/cacert.pemê`�'‚`ê`�­3 ¤������*���vendor/composer/ca-bundle/src/CaBundle.phpg��'‚`g��Axð�¤���������vendor/composer/installed.phpu ��'‚`u ��k�7z¤���������vendor/composer/semver/LICENSE��'‚`��ÇSRm¤������)���vendor/composer/semver/src/Comparator.php��'‚`��^ÝŠ’¤������/���vendor/composer/semver/src/CompilingMatcher.phpo��'‚`o��Æ7L§¤������/���vendor/composer/semver/src/Constraint/Bound.phpq��'‚`q�� �]¤������4���vendor/composer/semver/src/Constraint/Constraint.phpb��'‚`b��¡ó�w¤������=���vendor/composer/semver/src/Constraint/ConstraintInterface.php˜��'‚`˜��œ?[¤������<���vendor/composer/semver/src/Constraint/MatchAllConstraint.php§��'‚`§��ÃÛé¤������=���vendor/composer/semver/src/Constraint/MatchNoneConstraint.phpÁ��'‚`Á��ê´ �¤������9���vendor/composer/semver/src/Constraint/MultiConstraint.php ��'‚` ��’Q\ä������'���vendor/composer/semver/src/Interval.phpæ��'‚`æ��=[i¤������(���vendor/composer/semver/src/Intervals.phpÓ+��'‚`Ó+��7ؤ������%���vendor/composer/semver/src/Semver.phpù��'‚`ù��á-i¤������,���vendor/composer/semver/src/VersionParser.php—+��'‚`—+��=
  45. �‚¤������%���vendor/composer/spdx-licenses/LICENSE��'‚`��ÇSRm¤������6���vendor/composer/spdx-licenses/res/spdx-exceptions.json¸ ��'‚`¸ ��Â4DC¤������4���vendor/composer/spdx-licenses/res/spdx-licenses.jsonu°��'‚`u°��›ý…T¤������2���vendor/composer/spdx-licenses/src/SpdxLicenses.phpH��'‚`H��͉T¤������&���vendor/composer/xdebug-handler/LICENSE+��'‚`+��Öã@T¤������0���vendor/composer/xdebug-handler/src/PhpConfig.php´��'‚`´��*D’�¤������.���vendor/composer/xdebug-handler/src/Process.phpk ��'‚`k ��ŽUÿߤ������-���vendor/composer/xdebug-handler/src/Status.php
  46. ��'‚`
  47. ��$Ÿv-¤������4���vendor/composer/xdebug-handler/src/XdebugHandler.php£$��'‚`£$�� € D¤������(���vendor/justinrainbow/json-schema/LICENSE"��'‚`"�� |»™¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/BaseConstraint.php¡ ��'‚`¡ ��†wÌl¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/CollectionConstraint.phpƒ
  48. ��'‚`ƒ
  49. ��ž¸=š¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php§ ��'‚`§ ��›Vؤ������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ConstraintInterface.php¼��'‚`¼��ÿ Qœ¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/EnumConstraint.php\��'‚`\��_}ý¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Factory.phpà ��'‚`à ��ë’_”¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/FormatConstraint.phps��'‚`s��d Þ¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/NumberConstraint.phpƒ ��'‚`ƒ ��e� ¨¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/ObjectConstraint.php·��'‚`·��%l¬ö¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php& ��'‚`& ��78÷¬¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/StringConstraint.phpz��'‚`z��ùfÅ~¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/LooseTypeCheck.phpa��'‚`a�� qä������Y���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/StrictTypeCheck.php—��'‚`—��4~¾ ¤������\���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeCheck/TypeCheckInterface.php‰��'‚`‰��“µ+j¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/TypeConstraint.php��'‚`��ª%}¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/UndefinedConstraint.php,"��'‚`,"��‰-¤������F���vendor/justinrainbow/json-schema/src/JsonSchema/Entity/JsonPointer.phpè��'‚`è��{N–¤������P���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ExceptionInterface.phpI���'‚`I���%|°¤������V���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidArgumentException.php•���'‚`•���‹àG¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidConfigException.phpl���'‚`l���A!Lפ������T���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaException.phpl���'‚`l���è2÷þ¤������]���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSchemaMediaTypeException.phpu���'‚`u���=hç¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/InvalidSourceUriException.phpw���'‚`w���N-ò[¤������S���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/JsonDecodingException.phpÞ��'‚`Þ��\¸
  50. ¤������W���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ResourceNotFoundException.phpo���'‚`o���píÛù¤������N���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/RuntimeException.php…���'‚`…���%…—¤������^���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UnresolvableJsonPointerException.php€���'‚`€���u-#1¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/UriResolverException.phpj���'‚`j���å>�¤������Q���vendor/justinrainbow/json-schema/src/JsonSchema/Exception/ValidationException.phpf���'‚`f���¬¤„þ¤������K���vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.phpþ��'‚`þ��M�„õ¤������;���vendor/justinrainbow/json-schema/src/JsonSchema/Rfc3339.php ��'‚` ��f4÷³¤������A���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php“ ��'‚`“ ��&zß^¤������J���vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorageInterface.php��'‚`��oŠ+}¤������T���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/AbstractRetriever.phpá���'‚`á���[þA�¤������G���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/Curl.php£��'‚`£��Ç’ô¦¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/FileGetContents.php ��'‚` ��£Á¤������R���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/PredefinedArray.php,��'‚`,��1•5þ¤������X���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/Retrievers/UriRetrieverInterface.php®���'‚`®���ÿ‹Áå¤������C���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriResolver.php ��'‚` ��æP¤������D���vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php@��'‚`@��5Î3¤������H���vendor/justinrainbow/json-schema/src/JsonSchema/UriResolverInterface.phpƒ���'‚`ƒ���J€¤������I���vendor/justinrainbow/json-schema/src/JsonSchema/UriRetrieverInterface.php…���'‚`…���íæe¤������=���vendor/justinrainbow/json-schema/src/JsonSchema/Validator.phps��'‚`s��ßÁ‘#¤���������vendor/psr/log/LICENSE?��'‚`?��„ù ¤������)���vendor/psr/log/Psr/Log/AbstractLogger.php;��'‚`;��ñ>3[¤������3���vendor/psr/log/Psr/Log/InvalidArgumentException.php`���'‚``��� ˆX1¤������#���vendor/psr/log/Psr/Log/LogLevel.phpû���'‚`û���jðñ8¤������/���vendor/psr/log/Psr/Log/LoggerAwareInterface.php|���'‚`|���$£ˆ¤������+���vendor/psr/log/Psr/Log/LoggerAwareTrait.php§���'‚`§���T½úB¤������*���vendor/psr/log/Psr/Log/LoggerInterface.phpÈ��'‚`È��šx¤������&���vendor/psr/log/Psr/Log/LoggerTrait.phpk��'‚`k��£}‰’¤������%���vendor/psr/log/Psr/Log/NullLogger.phpŸ���'‚`Ÿ����Xóª¤������)���vendor/psr/log/Psr/Log/Test/DummyTest.phpp���'‚`p���Τ������3���vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php ��'‚` ��$/Ò¤������*���vendor/psr/log/Psr/Log/Test/TestLogger.php<��'‚`<��þ(åI¤���������vendor/react/promise/LICENSE'��'‚`'��¶-º„¤������F���vendor/react/promise/src/React/Promise/CancellablePromiseInterface.php����'‚`���� ƒ<�¤������3���vendor/react/promise/src/React/Promise/Deferred.phpð ��'‚`ð ��o(ퟤ������:���vendor/react/promise/src/React/Promise/DeferredPromise.phpÇ��'‚`Ç��º`W¤������;���vendor/react/promise/src/React/Promise/DeferredResolver.phpÃ��'‚`Ã��7Ëu¤������;���vendor/react/promise/src/React/Promise/FulfilledPromise.phpÍ��'‚`Í��´–U¤������6���vendor/react/promise/src/React/Promise/LazyPromise.php��'‚`��Š»¤������2���vendor/react/promise/src/React/Promise/Promise.php��'‚`��º6Jµ¤������;���vendor/react/promise/src/React/Promise/PromiseInterface.phpŸ���'‚`Ÿ��� ½¨n¤������<���vendor/react/promise/src/React/Promise/PromisorInterface.php\���'‚`\���Wèêà¤������:���vendor/react/promise/src/React/Promise/RejectedPromise.php¾��'‚`¾��fC¿¤������<���vendor/react/promise/src/React/Promise/ResolverInterface.php¼���'‚`¼���û �O¤������/���vendor/react/promise/src/React/Promise/Util.phpè���'‚`è���Ëý$:¤������/���vendor/react/promise/src/React/Promise/When.phpÇ��'‚`Ç��¤o¤������4���vendor/react/promise/src/React/Promise/functions.phpÐ ��'‚`Ð ��!³O¤������<���vendor/react/promise/src/React/Promise/functions_include.php\���'‚`\���1…‰^¤���������vendor/seld/jsonlint/LICENSE$��'‚`$��4:‡~¤������@���vendor/seld/jsonlint/src/Seld/JsonLint/DuplicateKeyException.phpk��'‚`k��Zù¶Ã¤������5���vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.php62��'‚`62��28ˤ������0���vendor/seld/jsonlint/src/Seld/JsonLint/Lexer.php#��'‚`#��Úá@,¤������;���vendor/seld/jsonlint/src/Seld/JsonLint/ParsingException.php%��'‚`%��`a„|¤������4���vendor/seld/jsonlint/src/Seld/JsonLint/Undefined.php>���'‚`>���ÿqŸŸ¤���������vendor/seld/phar-utils/LICENSE$��'‚`$��š,M§¤������%���vendor/seld/phar-utils/src/Linter.phpÍ��'‚`Í��H:›¤������)���vendor/seld/phar-utils/src/Timestamps.phpœ ��'‚`œ ��kL€¤������&���vendor/symfony/console/Application.php+X��'‚`+X��«­yX¤������*���vendor/symfony/console/Command/Command.phpä"��'‚`ä"���¤Ê¤������.���vendor/symfony/console/Command/HelpCommand.phpØ��'‚`Ø��¦Ú-:¤������.���vendor/symfony/console/Command/ListCommand.phpZ��'‚`Z��»w`¤������(���vendor/symfony/console/ConsoleEvents.phpé���'‚`é���RÛÔe¤������<���vendor/symfony/console/Descriptor/ApplicationDescription.phpÏ��'‚`Ï��<ŽUî¤������0���vendor/symfony/console/Descriptor/Descriptor.php���'‚`���¿N•¤������9���vendor/symfony/console/Descriptor/DescriptorInterface.phpü���'‚`ü���±Qµ¤������4���vendor/symfony/console/Descriptor/JsonDescriptor.phpÜ ��'‚`Ü ��*û�ɤ������8���vendor/symfony/console/Descriptor/MarkdownDescriptor.php¶��'‚`¶��·Ô;ݤ������4���vendor/symfony/console/Descriptor/TextDescriptor.php·��'‚`·��c“q€¤������3���vendor/symfony/console/Descriptor/XmlDescriptor.php��'‚`��b{<¤������4���vendor/symfony/console/Event/ConsoleCommandEvent.php°��'‚`°��!�Ȥ������-���vendor/symfony/console/Event/ConsoleEvent.phpÅ��'‚`Å��ÒxÛ\¤������6���vendor/symfony/console/Event/ConsoleExceptionEvent.php��'‚`��á2é¤������6���vendor/symfony/console/Event/ConsoleTerminateEvent.phpz��'‚`z��³,îL¤������=���vendor/symfony/console/Exception/CommandNotFoundException.phpÔ��'‚`Ô��È÷ L¤������7���vendor/symfony/console/Exception/ExceptionInterface.phpf���'‚`f���¡ABª¤������=���vendor/symfony/console/Exception/InvalidArgumentException.php¦���'‚`¦���Ö̽Z¤������;���vendor/symfony/console/Exception/InvalidOptionException.php¦���'‚`¦���Ë×H¤������3���vendor/symfony/console/Exception/LogicException.php’���'‚`’���ÍO\e¤������5���vendor/symfony/console/Exception/RuntimeException.php–���'‚`–���Ùí,6¤������4���vendor/symfony/console/Formatter/OutputFormatter.php3��'‚`3��àפ������=���vendor/symfony/console/Formatter/OutputFormatterInterface.phpŒ��'‚`Œ��òññÀ¤������9���vendor/symfony/console/Formatter/OutputFormatterStyle.phpF��'‚`F��𦴤������B���vendor/symfony/console/Formatter/OutputFormatterStyleInterface.php„��'‚`„��÷½G¤������>���vendor/symfony/console/Formatter/OutputFormatterStyleStack.php@��'‚`@��G¨ýU¤������6���vendor/symfony/console/Helper/DebugFormatterHelper.phpy��'‚`y��Ì8ÆФ������2���vendor/symfony/console/Helper/DescriptorHelper.phpw��'‚`w��|¦C¤������.���vendor/symfony/console/Helper/DialogHelper.phpð��'‚`ð��ÔÈ7¤������1���vendor/symfony/console/Helper/FormatterHelper.phpd��'‚`d��§×,¸¤������(���vendor/symfony/console/Helper/Helper.php©��'‚`©��Õ'ƒ±¤������1���vendor/symfony/console/Helper/HelperInterface.phpå���'‚`å���Š ¤������+���vendor/symfony/console/Helper/HelperSet.phpÊ��'‚`Ê��áÏW"¤������2���vendor/symfony/console/Helper/InputAwareHelper.phpc��'‚`c��Ìøƒ¤������/���vendor/symfony/console/Helper/ProcessHelper.phpÓ ��'‚`Ó ��©w‚R¤������-���vendor/symfony/console/Helper/ProgressBar.phpc%��'‚`c%��C&w¤������0���vendor/symfony/console/Helper/ProgressHelper.phpY��'‚`Y��R!�/¤������3���vendor/symfony/console/Helper/ProgressIndicator.phpM��'‚`M��ü�‡¤������0���vendor/symfony/console/Helper/QuestionHelper.php[��'‚`[��¯6}ñ¤������7���vendor/symfony/console/Helper/SymfonyQuestionHelper.php•
  51. ��'‚`•
  52. ���]~R¤������'���vendor/symfony/console/Helper/Table.php¼*��'‚`¼*��fêý!¤������+���vendor/symfony/console/Helper/TableCell.php€��'‚`€��‹ƒ[¤������-���vendor/symfony/console/Helper/TableHelper.php ��'‚` ��›uô™¤������0���vendor/symfony/console/Helper/TableSeparator.phpÊ���'‚`Ê���az¤������,���vendor/symfony/console/Helper/TableStyle.php
  53. ��'‚`
  54. ��_ÍI"¤������*���vendor/symfony/console/Input/ArgvInput.php��'‚`��ªèB-¤������+���vendor/symfony/console/Input/ArrayInput.php) ��'‚`) ��¥ÑC¤������&���vendor/symfony/console/Input/Input.php£ ��'‚`£ ��f¡?¤������.���vendor/symfony/console/Input/InputArgument.php��'‚`��D £¤������4���vendor/symfony/console/Input/InputAwareInterface.php˜���'‚`˜���­O°¤������0���vendor/symfony/console/Input/InputDefinition.php†��'‚`†��¤U)¤¤������/���vendor/symfony/console/Input/InputInterface.php£��'‚`£��ÆBŒ'¤������,���vendor/symfony/console/Input/InputOption.php ��'‚` ��\¢Ü=¤������,���vendor/symfony/console/Input/StringInput.php™��'‚`™��{Šœþ¤���������vendor/symfony/console/LICENSE+��'‚`+��²‹ g¤������/���vendor/symfony/console/Logger/ConsoleLogger.php- ��'‚`- ��ghT›¤������0���vendor/symfony/console/Output/BufferedOutput.php_��'‚`_��‹ >P¤������/���vendor/symfony/console/Output/ConsoleOutput.php±��'‚`±��nì!f¤������8���vendor/symfony/console/Output/ConsoleOutputInterface.phpà���'‚`à���‡†Æʤ������,���vendor/symfony/console/Output/NullOutput.phpÉ��'‚`É��™0ïf¤������(���vendor/symfony/console/Output/Output.php˜ ��'‚`˜ ��0p¤������1���vendor/symfony/console/Output/OutputInterface.php��'‚`���ì&¤������.���vendor/symfony/console/Output/StreamOutput.php›��'‚`›��.¡îî¤������2���vendor/symfony/console/Question/ChoiceQuestion.phpv
  55. ��'‚`v
  56. ��‹²WP¤������8���vendor/symfony/console/Question/ConfirmationQuestion.phpè��'‚`è��/Ô�¤������,���vendor/symfony/console/Question/Question.phpÎ ��'‚`Î ��lF¤������4���vendor/symfony/console/Resources/bin/hiddeninput.exe�$��'‚`�$��•�¥v¤������ ���vendor/symfony/console/Shell.phpã��'‚`ã��‰ÁŽå¤������,���vendor/symfony/console/Style/OutputStyle.php\��'‚`\��wפ¤������/���vendor/symfony/console/Style/StyleInterface.phpÏ��'‚`Ï��&nÅѤ������-���vendor/symfony/console/Style/SymfonyStyle.phpÛ��'‚`Û��§ðcä¤������3���vendor/symfony/console/Tester/ApplicationTester.phpÏ��'‚`Ï��sž9i¤������/���vendor/symfony/console/Tester/CommandTester.php¨��'‚`¨��<œ•¤������(���vendor/symfony/debug/BufferingLogger.phpt��'‚`t��=�hܤ���������vendor/symfony/debug/Debug.php+��'‚`+��.À=©¤������)���vendor/symfony/debug/DebugClassLoader.php°��'‚`°��^æ*ñ¤������%���vendor/symfony/debug/ErrorHandler.phpýG��'‚`ýG��¿zL¤������9���vendor/symfony/debug/Exception/ClassNotFoundException.php–��'‚`–��i‰æô¤������8���vendor/symfony/debug/Exception/ContextErrorException.php˜��'‚`˜��-
  57. d2¤������1���vendor/symfony/debug/Exception/DummyException.php��'‚`��®+Ãê¤������6���vendor/symfony/debug/Exception/FatalErrorException.php ��'‚` ��4ç$¤¤������6���vendor/symfony/debug/Exception/FatalThrowableError.phpW��'‚`W��?àèK¤������3���vendor/symfony/debug/Exception/FlattenException.php»��'‚`»��+a&¤������7���vendor/symfony/debug/Exception/OutOfMemoryException.php~���'‚`~���ë¨oâ¤������=���vendor/symfony/debug/Exception/UndefinedFunctionException.phpš��'‚`š���ñJÀ¤������;���vendor/symfony/debug/Exception/UndefinedMethodException.php˜��'‚`˜��nöêؤ������)���vendor/symfony/debug/ExceptionHandler.php$3��'‚`$3��Eë×£¤������I���vendor/symfony/debug/FatalErrorHandler/ClassNotFoundFatalErrorHandler.php5��'‚`5��ŠÁ*V¤������E���vendor/symfony/debug/FatalErrorHandler/FatalErrorHandlerInterface.php��'‚`��ĹBV¤������M���vendor/symfony/debug/FatalErrorHandler/UndefinedFunctionFatalErrorHandler.phpx��'‚`x��~ò"¤������K���vendor/symfony/debug/FatalErrorHandler/UndefinedMethodFatalErrorHandler.phpN��'‚`N��'€³ˆ¤���������vendor/symfony/debug/LICENSE+��'‚`+��²‹ g¤������:���vendor/symfony/filesystem/Exception/ExceptionInterface.phpi���'‚`i���$ ÿ›¤������=���vendor/symfony/filesystem/Exception/FileNotFoundException.php¼��'‚`¼��pí\¶¤������3���vendor/symfony/filesystem/Exception/IOException.php‡��'‚`‡��€ü#Ѥ������<���vendor/symfony/filesystem/Exception/IOExceptionInterface.php¦���'‚`¦���jÙwM¤������(���vendor/symfony/filesystem/Filesystem.phpM4��'‚`M4��ãz_¤������!���vendor/symfony/filesystem/LICENSE+��'‚`+��²‹ g¤������)���vendor/symfony/filesystem/LockHandler.phpò��'‚`ò��~3ŸZ¤������1���vendor/symfony/finder/Adapter/AbstractAdapter.php\ ��'‚`\ ��hˆB¤������5���vendor/symfony/finder/Adapter/AbstractFindAdapter.phpƒ��'‚`ƒ��kM Þ¤������2���vendor/symfony/finder/Adapter/AdapterInterface.php›��'‚`›��Mþ¤������0���vendor/symfony/finder/Adapter/BsdFindAdapter.php2��'‚`2��ƒ€D)¤������0���vendor/symfony/finder/Adapter/GnuFindAdapter.php��'‚`��¦äàO¤������,���vendor/symfony/finder/Adapter/PhpAdapter.phpô��'‚`ô��Þdè;¤������/���vendor/symfony/finder/Comparator/Comparator.php���'‚`���¾üœµ¤������3���vendor/symfony/finder/Comparator/DateComparator.php#��'‚`#��°Τ������5���vendor/symfony/finder/Comparator/NumberComparator.php{��'‚`{��€ÚùY¤������9���vendor/symfony/finder/Exception/AccessDeniedException.php„���'‚`„���½¾sœ¤������;���vendor/symfony/finder/Exception/AdapterFailureException.php¬��'‚`¬��wR¤������6���vendor/symfony/finder/Exception/ExceptionInterface.php„���'‚`„���Gz-¤������A���vendor/symfony/finder/Exception/OperationNotPermitedException.php)��'‚`)��x§e¤������@���vendor/symfony/finder/Exception/ShellCommandFailureException.phpº��'‚`º��˜þ˜¤������/���vendor/symfony/finder/Expression/Expression.php��'‚`��i¥:Ť������)���vendor/symfony/finder/Expression/Glob.phpf��'‚`f��DÞcj¤������*���vendor/symfony/finder/Expression/Regex.php��'‚`��§;M)¤������3���vendor/symfony/finder/Expression/ValueInterface.phpÍ��'‚`Í��\p4†¤������ ���vendor/symfony/finder/Finder.phpc.��'‚`c.��:ˆ5g¤���������vendor/symfony/finder/Glob.phpL��'‚`L��jÍ9פ������7���vendor/symfony/finder/Iterator/CustomFilterIterator.php]��'‚`]��ÎoÅƤ������:���vendor/symfony/finder/Iterator/DateRangeFilterIterator.phpx��'‚`x��ôP¤������;���vendor/symfony/finder/Iterator/DepthRangeFilterIterator.phpî��'‚`î��üÍ�q¤������A���vendor/symfony/finder/Iterator/ExcludeDirectoryFilterIterator.phpí��'‚`í��nõH¤������4���vendor/symfony/finder/Iterator/FilePathsIterator.php#��'‚`#��G?T½¤������9���vendor/symfony/finder/Iterator/FileTypeFilterIterator.phpZ��'‚`Z��(&ø¤������<���vendor/symfony/finder/Iterator/FilecontentFilterIterator.php5��'‚`5��ší¤������9���vendor/symfony/finder/Iterator/FilenameFilterIterator.phpr��'‚`r��tu¤������1���vendor/symfony/finder/Iterator/FilterIterator.phpÂ��'‚`Â���㯤������=���vendor/symfony/finder/Iterator/MultiplePcreFilterIterator.php*��'‚`*��Œž�¤������5���vendor/symfony/finder/Iterator/PathFilterIterator.phpÐ��'‚`Ð��‚c¤������=���vendor/symfony/finder/Iterator/RecursiveDirectoryIterator.php ��'‚` ��O}Cä¤������:���vendor/symfony/finder/Iterator/SizeRangeFilterIterator.phpe��'‚`e��Ÿ’áé¤������3���vendor/symfony/finder/Iterator/SortableIterator.php+��'‚`+��õÝË ¤���������vendor/symfony/finder/LICENSE+��'‚`+��²‹ g¤������'���vendor/symfony/finder/Shell/Command.php> ��'‚`> ��_~u ¤������%���vendor/symfony/finder/Shell/Shell.phpq��'‚`q��·ÓŠ0¤������%���vendor/symfony/finder/SplFileInfo.php��'‚`��þ�íù¤������'���vendor/symfony/polyfill-ctype/Ctype.phpH ��'‚`H ��³�Õݤ������%���vendor/symfony/polyfill-ctype/LICENSE+��'‚`+��…»E:¤������+���vendor/symfony/polyfill-ctype/bootstrap.phpú��'‚`ú��|p:¤������(���vendor/symfony/polyfill-mbstring/LICENSE+��'‚`+��øÛ{¤������-���vendor/symfony/polyfill-mbstring/Mbstring.php~G��'‚`~G��úì¡T¤������D���vendor/symfony/polyfill-mbstring/Resources/mb_convert_variables.php8Ë��'‚`Ë��Ú�.‚¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/lowerCase.php÷T��'‚`÷T��ß2ª?¤������F���vendor/symfony/polyfill-mbstring/Resources/unidata/titleCaseRegexp.phpã��'‚`ã��öy_•¤������@���vendor/symfony/polyfill-mbstring/Resources/unidata/upperCase.phpîU��'‚`îU��`þ8Q¤������.���vendor/symfony/polyfill-mbstring/bootstrap.php��'‚`��þJ¾¤������7���vendor/symfony/process/Exception/ExceptionInterface.phpf���'‚`f���]ö>T¤������=���vendor/symfony/process/Exception/InvalidArgumentException.php¨���'‚`¨���ÐÀ+_¤������3���vendor/symfony/process/Exception/LogicException.php”���'‚`”��� ³ãñ¤������;���vendor/symfony/process/Exception/ProcessFailedException.phpx��'‚`x��¨Ìzy¤������=���vendor/symfony/process/Exception/ProcessTimedOutException.php��'‚`��﫤������5���vendor/symfony/process/Exception/RuntimeException.php˜���'‚`˜���¢Ø:¤������+���vendor/symfony/process/ExecutableFinder.phpœ��'‚`œ��çÁ̤���������vendor/symfony/process/LICENSE+��'‚`+��²‹ g¤������.���vendor/symfony/process/PhpExecutableFinder.phpÍ��'‚`Í��í0ã¤������%���vendor/symfony/process/PhpProcess.phpù��'‚`ù��c¶ßĤ������.���vendor/symfony/process/Pipes/AbstractPipes.php¸��'‚`¸��xÓ,§¤������/���vendor/symfony/process/Pipes/PipesInterface.phpD��'‚`D��vØ������*���vendor/symfony/process/Pipes/UnixPipes.php7��'‚`7��bÜp„¤������-���vendor/symfony/process/Pipes/WindowsPipes.phpi ��'‚`i ��Ó
  58.  Ä¤������"���vendor/symfony/process/Process.php R��'‚` R��×Ó¥¹¤������)���vendor/symfony/process/ProcessBuilder.phpá
  59. ��'‚`á
  60. ��ñ6I•¤������'���vendor/symfony/process/ProcessUtils.phpJ��'‚`J��{ñC¤������ ���bin/composer8��'‚`8��³âéñ¤���������LICENSE.��'‚`.�� Õ¤������<?php
  61. namespace Composer\Autoload;
  62. use Composer\Config;
  63. use Composer\EventDispatcher\EventDispatcher;
  64. use Composer\Installer\InstallationManager;
  65. use Composer\IO\IOInterface;
  66. use Composer\Package\AliasPackage;
  67. use Composer\Package\PackageInterface;
  68. use Composer\Package\RootPackageInterface;
  69. use Composer\Repository\InstalledRepositoryInterface;
  70. use Composer\Repository\PlatformRepository;
  71. use Composer\Semver\Constraint\Bound;
  72. use Composer\Semver\Constraint\MatchAllConstraint;
  73. use Composer\Util\Filesystem;
  74. use Composer\Script\ScriptEvents;
  75. use Composer\Util\PackageSorter;
  76. class AutoloadGenerator
  77. {
  78. private $eventDispatcher;
  79. private $io;
  80. private $devMode = false;
  81. private $classMapAuthoritative = false;
  82. private $apcu = false;
  83. private $apcuPrefix;
  84. private $runScripts = false;
  85. private $ignorePlatformReqs = false;
  86. public function __construct(EventDispatcher $eventDispatcher, IOInterface $io = null)
  87. {
  88. $this->eventDispatcher = $eventDispatcher;
  89. $this->io = $io;
  90. }
  91. public function setDevMode($devMode = true)
  92. {
  93. $this->devMode = (bool) $devMode;
  94. }
  95. public function setClassMapAuthoritative($classMapAuthoritative)
  96. {
  97. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  98. }
  99. public function setApcu($apcu, $apcuPrefix = null)
  100. {
  101. $this->apcu = (bool) $apcu;
  102. $this->apcuPrefix = $apcuPrefix !== null ? (string) $apcuPrefix : $apcuPrefix;
  103. }
  104. public function setRunScripts($runScripts = true)
  105. {
  106. $this->runScripts = (bool) $runScripts;
  107. }
  108. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  109. {
  110. if (is_array($ignorePlatformReqs)) {
  111. $this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
  112. return PlatformRepository::isPlatformPackage($req);
  113. });
  114. } else {
  115. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  116. }
  117. }
  118. public function dump(Config $config, InstalledRepositoryInterface $localRepo, RootPackageInterface $rootPackage, InstallationManager $installationManager, $targetDir, $scanPsrPackages = false, $suffix = '')
  119. {
  120. if ($this->classMapAuthoritative) {
  121. $scanPsrPackages = true;
  122. }
  123. if ($this->runScripts) {
  124. $this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP, $this->devMode, array(), array(
  125. 'optimize' => (bool) $scanPsrPackages,
  126. ));
  127. }
  128. $filesystem = new Filesystem();
  129. $filesystem->ensureDirectoryExists($config->get('vendor-dir'));
  130. $basePath = $filesystem->normalizePath(realpath(realpath(getcwd())));
  131. $vendorPath = $filesystem->normalizePath(realpath(realpath($config->get('vendor-dir'))));
  132. $useGlobalIncludePath = (bool) $config->get('use-include-path');
  133. $prependAutoloader = $config->get('prepend-autoloader') === false ? 'false' : 'true';
  134. $targetDir = $vendorPath.'/'.$targetDir;
  135. $filesystem->ensureDirectoryExists($targetDir);
  136. $vendorPathCode = $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true);
  137. $vendorPathCode52 = str_replace('__DIR__', 'dirname(__FILE__)', $vendorPathCode);
  138. $vendorPathToTargetDirCode = $filesystem->findShortestPathCode($vendorPath, realpath($targetDir), true);
  139. $appBaseDirCode = $filesystem->findShortestPathCode($vendorPath, $basePath, true);
  140. $appBaseDirCode = str_replace('__DIR__', '$vendorDir', $appBaseDirCode);
  141. $namespacesFile = <<<EOF
  142. <?php
  143. // autoload_namespaces.php @generated by Composer
  144. \$vendorDir = $vendorPathCode52;
  145. \$baseDir = $appBaseDirCode;
  146. return array(
  147. EOF;
  148. $psr4File = <<<EOF
  149. <?php
  150. // autoload_psr4.php @generated by Composer
  151. \$vendorDir = $vendorPathCode52;
  152. \$baseDir = $appBaseDirCode;
  153. return array(
  154. EOF;
  155. $devPackageNames = $localRepo->getDevPackageNames();
  156. $packageMap = $this->buildPackageMap($installationManager, $rootPackage, $localRepo->getCanonicalPackages());
  157. if ($this->devMode) {
  158. $filteredDevPackages = false;
  159. } else {
  160. $filteredDevPackages = $devPackageNames ?: true;
  161. }
  162. $autoloads = $this->parseAutoloads($packageMap, $rootPackage, $filteredDevPackages);
  163. foreach ($autoloads['psr-0'] as $namespace => $paths) {
  164. $exportedPaths = array();
  165. foreach ($paths as $path) {
  166. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  167. }
  168. $exportedPrefix = var_export($namespace, true);
  169. $namespacesFile .= " $exportedPrefix => ";
  170. $namespacesFile .= "array(".implode(', ', $exportedPaths)."),\n";
  171. }
  172. $namespacesFile .= ");\n";
  173. foreach ($autoloads['psr-4'] as $namespace => $paths) {
  174. $exportedPaths = array();
  175. foreach ($paths as $path) {
  176. $exportedPaths[] = $this->getPathCode($filesystem, $basePath, $vendorPath, $path);
  177. }
  178. $exportedPrefix = var_export($namespace, true);
  179. $psr4File .= " $exportedPrefix => ";
  180. $psr4File .= "array(".implode(', ', $exportedPaths)."),\n";
  181. }
  182. $psr4File .= ");\n";
  183. $classmapFile = <<<EOF
  184. <?php
  185. // autoload_classmap.php @generated by Composer
  186. \$vendorDir = $vendorPathCode52;
  187. \$baseDir = $appBaseDirCode;
  188. return array(
  189. EOF;
  190. $targetDirLoader = null;
  191. $mainAutoload = $rootPackage->getAutoload();
  192. if ($rootPackage->getTargetDir() && !empty($mainAutoload['psr-0'])) {
  193. $levels = substr_count($filesystem->normalizePath($rootPackage->getTargetDir()), '/') + 1;
  194. $prefixes = implode(', ', array_map(function ($prefix) {
  195. return var_export($prefix, true);
  196. }, array_keys($mainAutoload['psr-0'])));
  197. $baseDirFromTargetDirCode = $filesystem->findShortestPathCode($targetDir, $basePath, true);
  198. $targetDirLoader = <<<EOF
  199. public static function autoload(\$class)
  200. {
  201. \$dir = $baseDirFromTargetDirCode . '/';
  202. \$prefixes = array($prefixes);
  203. foreach (\$prefixes as \$prefix) {
  204. if (0 !== strpos(\$class, \$prefix)) {
  205. continue;
  206. }
  207. \$path = \$dir . implode('/', array_slice(explode('\\\\', \$class), $levels)).'.php';
  208. if (!\$path = stream_resolve_include_path(\$path)) {
  209. return false;
  210. }
  211. require \$path;
  212. return true;
  213. }
  214. }
  215. EOF;
  216. }
  217. $excluded = null;
  218. if (!empty($autoloads['exclude-from-classmap'])) {
  219. $excluded = $autoloads['exclude-from-classmap'];
  220. }
  221. $classMap = array();
  222. $ambiguousClasses = array();
  223. $scannedFiles = array();
  224. foreach ($autoloads['classmap'] as $dir) {
  225. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, null, null, $classMap, $ambiguousClasses, $scannedFiles);
  226. }
  227. if ($scanPsrPackages) {
  228. $namespacesToScan = array();
  229. foreach (array('psr-4', 'psr-0') as $psrType) {
  230. foreach ($autoloads[$psrType] as $namespace => $paths) {
  231. $namespacesToScan[$namespace][] = array('paths' => $paths, 'type' => $psrType);
  232. }
  233. }
  234. krsort($namespacesToScan);
  235. foreach ($namespacesToScan as $namespace => $groups) {
  236. foreach ($groups as $group) {
  237. foreach ($group['paths'] as $dir) {
  238. $dir = $filesystem->normalizePath($filesystem->isAbsolutePath($dir) ? $dir : $basePath.'/'.$dir);
  239. if (!is_dir($dir)) {
  240. continue;
  241. }
  242. $classMap = $this->addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, $namespace, $group['type'], $classMap, $ambiguousClasses, $scannedFiles);
  243. }
  244. }
  245. }
  246. }
  247. foreach ($ambiguousClasses as $className => $ambigiousPaths) {
  248. $cleanPath = str_replace(array('$vendorDir . \'', '$baseDir . \'', "',\n"), array($vendorPath, $basePath, ''), $classMap[$className]);
  249. $this->io->writeError(
  250. '<warning>Warning: Ambiguous class resolution, "'.$className.'"'.
  251. ' was found '. (count($ambigiousPaths) + 1) .'x: in "'.$cleanPath.'" and "'. implode('", "', $ambigiousPaths) .'", the first will be used.</warning>'
  252. );
  253. }
  254. $classMap['Composer\\InstalledVersions'] = "\$vendorDir . '/composer/InstalledVersions.php',\n";
  255. ksort($classMap);
  256. foreach ($classMap as $class => $code) {
  257. $classmapFile .= ' '.var_export($class, true).' => '.$code;
  258. }
  259. $classmapFile .= ");\n";
  260. if (!$suffix) {
  261. if (!$config->get('autoloader-suffix') && is_readable($vendorPath.'/autoload.php')) {
  262. $content = file_get_contents($vendorPath.'/autoload.php');
  263. if (preg_match('{ComposerAutoloaderInit([^:\s]+)::}', $content, $match)) {
  264. $suffix = $match[1];
  265. }
  266. }
  267. if (!$suffix) {
  268. $suffix = $config->get('autoloader-suffix') ?: md5(uniqid('', true));
  269. }
  270. }
  271. $filesystem->filePutContentsIfModified($targetDir.'/autoload_namespaces.php', $namespacesFile);
  272. $filesystem->filePutContentsIfModified($targetDir.'/autoload_psr4.php', $psr4File);
  273. $filesystem->filePutContentsIfModified($targetDir.'/autoload_classmap.php', $classmapFile);
  274. $includePathFilePath = $targetDir.'/include_paths.php';
  275. if ($includePathFileContents = $this->getIncludePathsFile($packageMap, $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  276. $filesystem->filePutContentsIfModified($includePathFilePath, $includePathFileContents);
  277. } elseif (file_exists($includePathFilePath)) {
  278. unlink($includePathFilePath);
  279. }
  280. $includeFilesFilePath = $targetDir.'/autoload_files.php';
  281. if ($includeFilesFileContents = $this->getIncludeFilesFile($autoloads['files'], $filesystem, $basePath, $vendorPath, $vendorPathCode52, $appBaseDirCode)) {
  282. $filesystem->filePutContentsIfModified($includeFilesFilePath, $includeFilesFileContents);
  283. } elseif (file_exists($includeFilesFilePath)) {
  284. unlink($includeFilesFilePath);
  285. }
  286. $filesystem->filePutContentsIfModified($targetDir.'/autoload_static.php', $this->getStaticFile($suffix, $targetDir, $vendorPath, $basePath, $staticPhpVersion));
  287. $checkPlatform = $config->get('platform-check') && $this->ignorePlatformReqs !== true;
  288. $platformCheckContent = null;
  289. if ($checkPlatform) {
  290. $platformCheckContent = $this->getPlatformCheck($packageMap, $this->ignorePlatformReqs ?: array(), $config->get('platform-check'), $devPackageNames);
  291. if (null === $platformCheckContent) {
  292. $checkPlatform = false;
  293. }
  294. }
  295. if ($checkPlatform) {
  296. $filesystem->filePutContentsIfModified($targetDir.'/platform_check.php', $platformCheckContent);
  297. } elseif (file_exists($targetDir.'/platform_check.php')) {
  298. unlink($targetDir.'/platform_check.php');
  299. }
  300. $filesystem->filePutContentsIfModified($vendorPath.'/autoload.php', $this->getAutoloadFile($vendorPathToTargetDirCode, $suffix));
  301. $filesystem->filePutContentsIfModified($targetDir.'/autoload_real.php', $this->getAutoloadRealFile(true, (bool) $includePathFileContents, $targetDirLoader, (bool) $includeFilesFileContents, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform));
  302. $filesystem->safeCopy(__DIR__.'/ClassLoader.php', $targetDir.'/ClassLoader.php');
  303. $filesystem->safeCopy(__DIR__.'/../../../LICENSE', $targetDir.'/LICENSE');
  304. if ($this->runScripts) {
  305. $this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP, $this->devMode, array(), array(
  306. 'optimize' => (bool) $scanPsrPackages,
  307. ));
  308. }
  309. return count($classMap);
  310. }
  311. private function addClassMapCode($filesystem, $basePath, $vendorPath, $dir, $excluded, $namespaceFilter, $autoloadType, array $classMap, array &$ambiguousClasses, array &$scannedFiles)
  312. {
  313. foreach ($this->generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, true, $scannedFiles) as $class => $path) {
  314. $pathCode = $this->getPathCode($filesystem, $basePath, $vendorPath, $path).",\n";
  315. if (!isset($classMap[$class])) {
  316. $classMap[$class] = $pathCode;
  317. } elseif ($this->io && $classMap[$class] !== $pathCode && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($classMap[$class].' '.$path, '\\', '/'))) {
  318. $ambiguousClasses[$class][] = $path;
  319. }
  320. }
  321. return $classMap;
  322. }
  323. private function generateClassMap($dir, $excluded, $namespaceFilter, $autoloadType, $showAmbiguousWarning, array &$scannedFiles)
  324. {
  325. if ($excluded) {
  326. if (file_exists($dir)) {
  327. $dirMatch = preg_quote(strtr(realpath($dir), '\\', '/'));
  328. foreach ($excluded as $index => $pattern) {
  329. $pattern = preg_replace('{^(([^.+*?\[^\]$(){}=!<>|:\\\\#-]+|\\\\[.+*?\[^\]$(){}=!<>|:#-])*).*}', '$1', $pattern);
  330. if (0 !== strpos($pattern, $dirMatch) && 0 !== strpos($dirMatch, $pattern)) {
  331. unset($excluded[$index]);
  332. }
  333. }
  334. }
  335. $excluded = $excluded ? '{(' . implode('|', $excluded) . ')}' : null;
  336. }
  337. return ClassMapGenerator::createMap($dir, $excluded, $showAmbiguousWarning ? $this->io : null, $namespaceFilter, $autoloadType, $scannedFiles);
  338. }
  339. public function buildPackageMap(InstallationManager $installationManager, PackageInterface $rootPackage, array $packages)
  340. {
  341. $packageMap = array(array($rootPackage, ''));
  342. foreach ($packages as $package) {
  343. if ($package instanceof AliasPackage) {
  344. continue;
  345. }
  346. $this->validatePackage($package);
  347. $packageMap[] = array(
  348. $package,
  349. $installationManager->getInstallPath($package),
  350. );
  351. }
  352. return $packageMap;
  353. }
  354. protected function validatePackage(PackageInterface $package)
  355. {
  356. $autoload = $package->getAutoload();
  357. if (!empty($autoload['psr-4']) && null !== $package->getTargetDir()) {
  358. $name = $package->getName();
  359. $package->getTargetDir();
  360. throw new \InvalidArgumentException("PSR-4 autoloading is incompatible with the target-dir property, remove the target-dir in package '$name'.");
  361. }
  362. if (!empty($autoload['psr-4'])) {
  363. foreach ($autoload['psr-4'] as $namespace => $dirs) {
  364. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  365. throw new \InvalidArgumentException("psr-4 namespaces must end with a namespace separator, '$namespace' does not, use '$namespace\\'.");
  366. }
  367. }
  368. }
  369. }
  370. public function parseAutoloads(array $packageMap, PackageInterface $rootPackage, $filteredDevPackages = false)
  371. {
  372. $rootPackageMap = array_shift($packageMap);
  373. if (is_array($filteredDevPackages)) {
  374. $packageMap = array_filter($packageMap, function ($item) use ($filteredDevPackages) {
  375. return !in_array($item[0]->getName(), $filteredDevPackages, true);
  376. });
  377. } elseif ($filteredDevPackages) {
  378. $packageMap = $this->filterPackageMap($packageMap, $rootPackage);
  379. }
  380. $sortedPackageMap = $this->sortPackageMap($packageMap);
  381. $sortedPackageMap[] = $rootPackageMap;
  382. array_unshift($packageMap, $rootPackageMap);
  383. $psr0 = $this->parseAutoloadsType($packageMap, 'psr-0', $rootPackage);
  384. $psr4 = $this->parseAutoloadsType($packageMap, 'psr-4', $rootPackage);
  385. $classmap = $this->parseAutoloadsType(array_reverse($sortedPackageMap), 'classmap', $rootPackage);
  386. $files = $this->parseAutoloadsType($sortedPackageMap, 'files', $rootPackage);
  387. $exclude = $this->parseAutoloadsType($sortedPackageMap, 'exclude-from-classmap', $rootPackage);
  388. krsort($psr0);
  389. krsort($psr4);
  390. return array(
  391. 'psr-0' => $psr0,
  392. 'psr-4' => $psr4,
  393. 'classmap' => $classmap,
  394. 'files' => $files,
  395. 'exclude-from-classmap' => $exclude,
  396. );
  397. }
  398. public function createLoader(array $autoloads)
  399. {
  400. $loader = new ClassLoader();
  401. if (isset($autoloads['psr-0'])) {
  402. foreach ($autoloads['psr-0'] as $namespace => $path) {
  403. $loader->add($namespace, $path);
  404. }
  405. }
  406. if (isset($autoloads['psr-4'])) {
  407. foreach ($autoloads['psr-4'] as $namespace => $path) {
  408. $loader->addPsr4($namespace, $path);
  409. }
  410. }
  411. if (isset($autoloads['classmap'])) {
  412. $excluded = null;
  413. if (!empty($autoloads['exclude-from-classmap'])) {
  414. $excluded = $autoloads['exclude-from-classmap'];
  415. }
  416. $scannedFiles = array();
  417. foreach ($autoloads['classmap'] as $dir) {
  418. try {
  419. $loader->addClassMap($this->generateClassMap($dir, $excluded, null, null, false, $scannedFiles));
  420. } catch (\RuntimeException $e) {
  421. $this->io->writeError('<warning>'.$e->getMessage().'</warning>');
  422. }
  423. }
  424. }
  425. return $loader;
  426. }
  427. protected function getIncludePathsFile(array $packageMap, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  428. {
  429. $includePaths = array();
  430. foreach ($packageMap as $item) {
  431. list($package, $installPath) = $item;
  432. if (null !== $package->getTargetDir() && strlen($package->getTargetDir()) > 0) {
  433. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  434. }
  435. foreach ($package->getIncludePaths() as $includePath) {
  436. $includePath = trim($includePath, '/');
  437. $includePaths[] = empty($installPath) ? $includePath : $installPath.'/'.$includePath;
  438. }
  439. }
  440. if (!$includePaths) {
  441. return;
  442. }
  443. $includePathsCode = '';
  444. foreach ($includePaths as $path) {
  445. $includePathsCode .= " " . $this->getPathCode($filesystem, $basePath, $vendorPath, $path) . ",\n";
  446. }
  447. return <<<EOF
  448. <?php
  449. // include_paths.php @generated by Composer
  450. \$vendorDir = $vendorPathCode;
  451. \$baseDir = $appBaseDirCode;
  452. return array(
  453. $includePathsCode);
  454. EOF;
  455. }
  456. protected function getIncludeFilesFile(array $files, Filesystem $filesystem, $basePath, $vendorPath, $vendorPathCode, $appBaseDirCode)
  457. {
  458. $filesCode = '';
  459. foreach ($files as $fileIdentifier => $functionFile) {
  460. $filesCode .= ' ' . var_export($fileIdentifier, true) . ' => '
  461. . $this->getPathCode($filesystem, $basePath, $vendorPath, $functionFile) . ",\n";
  462. }
  463. if (!$filesCode) {
  464. return false;
  465. }
  466. return <<<EOF
  467. <?php
  468. // autoload_files.php @generated by Composer
  469. \$vendorDir = $vendorPathCode;
  470. \$baseDir = $appBaseDirCode;
  471. return array(
  472. $filesCode);
  473. EOF;
  474. }
  475. protected function getPathCode(Filesystem $filesystem, $basePath, $vendorPath, $path)
  476. {
  477. if (!$filesystem->isAbsolutePath($path)) {
  478. $path = $basePath . '/' . $path;
  479. }
  480. $path = $filesystem->normalizePath($path);
  481. $baseDir = '';
  482. if (strpos($path.'/', $vendorPath.'/') === 0) {
  483. $path = substr($path, strlen($vendorPath));
  484. $baseDir = '$vendorDir';
  485. if ($path !== false) {
  486. $baseDir .= " . ";
  487. }
  488. } else {
  489. $path = $filesystem->normalizePath($filesystem->findShortestPath($basePath, $path, true));
  490. if (!$filesystem->isAbsolutePath($path)) {
  491. $baseDir = '$baseDir . ';
  492. $path = '/' . $path;
  493. }
  494. }
  495. if (strpos($path, '.phar') !== false) {
  496. $baseDir = "'phar://' . " . $baseDir;
  497. }
  498. return $baseDir . (($path !== false) ? var_export($path, true) : "");
  499. }
  500. protected function getPlatformCheck(array $packageMap, array $ignorePlatformReqs, $checkPlatform, array $devPackageNames)
  501. {
  502. $lowestPhpVersion = Bound::zero();
  503. $requiredExtensions = array();
  504. $extensionProviders = array();
  505. foreach ($packageMap as $item) {
  506. $package = $item[0];
  507. foreach (array_merge($package->getReplaces(), $package->getProvides()) as $link) {
  508. if (preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  509. $extensionProviders[$match[1]][] = $link->getConstraint() ?: new MatchAllConstraint();
  510. }
  511. }
  512. }
  513. foreach ($packageMap as $item) {
  514. $package = $item[0];
  515. if (in_array($package->getName(), $devPackageNames, true)) {
  516. continue;
  517. }
  518. foreach ($package->getRequires() as $link) {
  519. if (in_array($link->getTarget(), $ignorePlatformReqs, true)) {
  520. continue;
  521. }
  522. if ('php' === $link->getTarget() && ($constraint = $link->getConstraint())) {
  523. if ($constraint->getLowerBound()->compareTo($lowestPhpVersion, '>')) {
  524. $lowestPhpVersion = $constraint->getLowerBound();
  525. }
  526. }
  527. if ($checkPlatform === true && preg_match('{^ext-(.+)$}iD', $link->getTarget(), $match)) {
  528. if (isset($extensionProviders[$match[1]])) {
  529. foreach ($extensionProviders[$match[1]] as $provided) {
  530. if (!$link->getConstraint() || $provided->matches($link->getConstraint())) {
  531. continue 2;
  532. }
  533. }
  534. }
  535. if ($match[1] === 'zend-opcache') {
  536. $match[1] = 'zend opcache';
  537. }
  538. $extension = var_export($match[1], true);
  539. if ($match[1] === 'pcntl' || $match[1] === 'readline') {
  540. $requiredExtensions[$extension] = "PHP_SAPI !== 'cli' || extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  541. } else {
  542. $requiredExtensions[$extension] = "extension_loaded($extension) || \$missingExtensions[] = $extension;\n";
  543. }
  544. }
  545. }
  546. }
  547. ksort($requiredExtensions);
  548. $formatToPhpVersionId = function (Bound $bound) {
  549. if ($bound->isZero()) {
  550. return 0;
  551. }
  552. if ($bound->isPositiveInfinity()) {
  553. return 99999;
  554. }
  555. $version = str_replace('-', '.', $bound->getVersion());
  556. $chunks = array_map('intval', explode('.', $version));
  557. return $chunks[0] * 10000 + $chunks[1] * 100 + $chunks[2];
  558. };
  559. $formatToHumanReadable = function (Bound $bound) {
  560. if ($bound->isZero()) {
  561. return 0;
  562. }
  563. if ($bound->isPositiveInfinity()) {
  564. return 99999;
  565. }
  566. $version = str_replace('-', '.', $bound->getVersion());
  567. $chunks = explode('.', $version);
  568. $chunks = array_slice($chunks, 0, 3);
  569. return implode('.', $chunks);
  570. };
  571. $requiredPhp = '';
  572. $requiredPhpError = '';
  573. if (!$lowestPhpVersion->isZero()) {
  574. $operator = $lowestPhpVersion->isInclusive() ? '>=' : '>';
  575. $requiredPhp = 'PHP_VERSION_ID '.$operator.' '.$formatToPhpVersionId($lowestPhpVersion);
  576. $requiredPhpError = '"'.$operator.' '.$formatToHumanReadable($lowestPhpVersion).'"';
  577. }
  578. if ($requiredPhp) {
  579. $requiredPhp = <<<PHP_CHECK
  580. if (!($requiredPhp)) {
  581. \$issues[] = 'Your Composer dependencies require a PHP version $requiredPhpError. You are running ' . PHP_VERSION . '.';
  582. }
  583. PHP_CHECK;
  584. }
  585. $requiredExtensions = implode('', $requiredExtensions);
  586. if ('' !== $requiredExtensions) {
  587. $requiredExtensions = <<<EXT_CHECKS
  588. \$missingExtensions = array();
  589. $requiredExtensions
  590. if (\$missingExtensions) {
  591. \$issues[] = 'Your Composer dependencies require the following PHP extensions to be installed: ' . implode(', ', \$missingExtensions) . '.';
  592. }
  593. EXT_CHECKS;
  594. }
  595. if (!$requiredPhp && !$requiredExtensions) {
  596. return null;
  597. }
  598. return <<<PLATFORM_CHECK
  599. <?php
  600. // platform_check.php @generated by Composer
  601. \$issues = array();
  602. ${requiredPhp}${requiredExtensions}
  603. if (\$issues) {
  604. if (!headers_sent()) {
  605. header('HTTP/1.1 500 Internal Server Error');
  606. }
  607. if (!ini_get('display_errors')) {
  608. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  609. fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, \$issues) . PHP_EOL.PHP_EOL);
  610. } elseif (!headers_sent()) {
  611. echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, \$issues)) . PHP_EOL.PHP_EOL;
  612. }
  613. }
  614. trigger_error(
  615. 'Composer detected issues in your platform: ' . implode(' ', \$issues),
  616. E_USER_ERROR
  617. );
  618. }
  619. PLATFORM_CHECK;
  620. }
  621. protected function getAutoloadFile($vendorPathToTargetDirCode, $suffix)
  622. {
  623. $lastChar = $vendorPathToTargetDirCode[strlen($vendorPathToTargetDirCode) - 1];
  624. if ("'" === $lastChar || '"' === $lastChar) {
  625. $vendorPathToTargetDirCode = substr($vendorPathToTargetDirCode, 0, -1).'/autoload_real.php'.$lastChar;
  626. } else {
  627. $vendorPathToTargetDirCode .= " . '/autoload_real.php'";
  628. }
  629. return <<<AUTOLOAD
  630. <?php
  631. // autoload.php @generated by Composer
  632. require_once $vendorPathToTargetDirCode;
  633. return ComposerAutoloaderInit$suffix::getLoader();
  634. AUTOLOAD;
  635. }
  636. protected function getAutoloadRealFile($useClassMap, $useIncludePath, $targetDirLoader, $useIncludeFiles, $vendorPathCode, $appBaseDirCode, $suffix, $useGlobalIncludePath, $prependAutoloader, $staticPhpVersion, $checkPlatform)
  637. {
  638. $file = <<<HEADER
  639. <?php
  640. // autoload_real.php @generated by Composer
  641. class ComposerAutoloaderInit$suffix
  642. {
  643. private static \$loader;
  644. public static function loadClassLoader(\$class)
  645. {
  646. if ('Composer\\Autoload\\ClassLoader' === \$class) {
  647. require __DIR__ . '/ClassLoader.php';
  648. }
  649. }
  650. /**
  651. * @return \Composer\Autoload\ClassLoader
  652. */
  653. public static function getLoader()
  654. {
  655. if (null !== self::\$loader) {
  656. return self::\$loader;
  657. }
  658. HEADER;
  659. if ($checkPlatform) {
  660. $file .= <<<'PLATFORM_CHECK'
  661. require __DIR__ . '/platform_check.php';
  662. PLATFORM_CHECK;
  663. }
  664. $file .= <<<CLASSLOADER_INIT
  665. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'), true, $prependAutoloader);
  666. self::\$loader = \$loader = new \\Composer\\Autoload\\ClassLoader(\\dirname(\\dirname(__FILE__)));
  667. spl_autoload_unregister(array('ComposerAutoloaderInit$suffix', 'loadClassLoader'));
  668. CLASSLOADER_INIT;
  669. if ($useIncludePath) {
  670. $file .= <<<'INCLUDE_PATH'
  671. $includePaths = require __DIR__ . '/include_paths.php';
  672. $includePaths[] = get_include_path();
  673. set_include_path(implode(PATH_SEPARATOR, $includePaths));
  674. INCLUDE_PATH;
  675. }
  676. $file .= <<<STATIC_INIT
  677. \$useStaticLoader = PHP_VERSION_ID >= $staticPhpVersion && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  678. if (\$useStaticLoader) {
  679. require __DIR__ . '/autoload_static.php';
  680. call_user_func(\Composer\Autoload\ComposerStaticInit$suffix::getInitializer(\$loader));
  681. } else {
  682. STATIC_INIT;
  683. if (!$this->classMapAuthoritative) {
  684. $file .= <<<'PSR04'
  685. $map = require __DIR__ . '/autoload_namespaces.php';
  686. foreach ($map as $namespace => $path) {
  687. $loader->set($namespace, $path);
  688. }
  689. $map = require __DIR__ . '/autoload_psr4.php';
  690. foreach ($map as $namespace => $path) {
  691. $loader->setPsr4($namespace, $path);
  692. }
  693. PSR04;
  694. }
  695. if ($useClassMap) {
  696. $file .= <<<'CLASSMAP'
  697. $classMap = require __DIR__ . '/autoload_classmap.php';
  698. if ($classMap) {
  699. $loader->addClassMap($classMap);
  700. }
  701. CLASSMAP;
  702. }
  703. $file .= " }\n\n";
  704. if ($this->classMapAuthoritative) {
  705. $file .= <<<'CLASSMAPAUTHORITATIVE'
  706. $loader->setClassMapAuthoritative(true);
  707. CLASSMAPAUTHORITATIVE;
  708. }
  709. if ($this->apcu) {
  710. $apcuPrefix = var_export(($this->apcuPrefix !== null ? $this->apcuPrefix : substr(base64_encode(md5(uniqid('', true), true)), 0, -3)), true);
  711. $file .= <<<APCU
  712. \$loader->setApcuPrefix($apcuPrefix);
  713. APCU;
  714. }
  715. if ($useGlobalIncludePath) {
  716. $file .= <<<'INCLUDEPATH'
  717. $loader->setUseIncludePath(true);
  718. INCLUDEPATH;
  719. }
  720. if ($targetDirLoader) {
  721. $file .= <<<REGISTER_TARGET_DIR_AUTOLOAD
  722. spl_autoload_register(array('ComposerAutoloaderInit$suffix', 'autoload'), true, true);
  723. REGISTER_TARGET_DIR_AUTOLOAD;
  724. }
  725. $file .= <<<REGISTER_LOADER
  726. \$loader->register($prependAutoloader);
  727. REGISTER_LOADER;
  728. if ($useIncludeFiles) {
  729. $file .= <<<INCLUDE_FILES
  730. if (\$useStaticLoader) {
  731. \$includeFiles = Composer\Autoload\ComposerStaticInit$suffix::\$files;
  732. } else {
  733. \$includeFiles = require __DIR__ . '/autoload_files.php';
  734. }
  735. foreach (\$includeFiles as \$fileIdentifier => \$file) {
  736. composerRequire$suffix(\$fileIdentifier, \$file);
  737. }
  738. INCLUDE_FILES;
  739. }
  740. $file .= <<<METHOD_FOOTER
  741. return \$loader;
  742. }
  743. METHOD_FOOTER;
  744. $file .= $targetDirLoader;
  745. if ($useIncludeFiles) {
  746. return $file . <<<FOOTER
  747. }
  748. function composerRequire$suffix(\$fileIdentifier, \$file)
  749. {
  750. if (empty(\$GLOBALS['__composer_autoload_files'][\$fileIdentifier])) {
  751. require \$file;
  752. \$GLOBALS['__composer_autoload_files'][\$fileIdentifier] = true;
  753. }
  754. }
  755. FOOTER;
  756. }
  757. return $file . <<<FOOTER
  758. }
  759. FOOTER;
  760. }
  761. protected function getStaticFile($suffix, $targetDir, $vendorPath, $basePath, &$staticPhpVersion)
  762. {
  763. $staticPhpVersion = 50600;
  764. $file = <<<HEADER
  765. <?php
  766. // autoload_static.php @generated by Composer
  767. namespace Composer\Autoload;
  768. class ComposerStaticInit$suffix
  769. {
  770. HEADER;
  771. $loader = new ClassLoader();
  772. $map = require $targetDir . '/autoload_namespaces.php';
  773. foreach ($map as $namespace => $path) {
  774. $loader->set($namespace, $path);
  775. }
  776. $map = require $targetDir . '/autoload_psr4.php';
  777. foreach ($map as $namespace => $path) {
  778. $loader->setPsr4($namespace, $path);
  779. }
  780. $classMap = require $targetDir . '/autoload_classmap.php';
  781. if ($classMap) {
  782. $loader->addClassMap($classMap);
  783. }
  784. $filesystem = new Filesystem();
  785. $vendorPathCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  786. $vendorPharPathCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $vendorPath, true, true) . " . '/";
  787. $appBaseDirCode = ' => ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  788. $appBaseDirPharCode = ' => \'phar://\' . ' . $filesystem->findShortestPathCode(realpath($targetDir), $basePath, true, true) . " . '/";
  789. $absoluteVendorPathCode = ' => ' . substr(var_export(rtrim($vendorDir, '\\/') . '/', true), 0, -1);
  790. $absoluteVendorPharPathCode = ' => ' . substr(var_export(rtrim('phar://' . $vendorDir, '\\/') . '/', true), 0, -1);
  791. $absoluteAppBaseDirCode = ' => ' . substr(var_export(rtrim($baseDir, '\\/') . '/', true), 0, -1);
  792. $absoluteAppBaseDirPharCode = ' => ' . substr(var_export(rtrim('phar://' . $baseDir, '\\/') . '/', true), 0, -1);
  793. $initializer = '';
  794. $prefix = "\0Composer\Autoload\ClassLoader\0";
  795. $prefixLen = strlen($prefix);
  796. if (file_exists($targetDir . '/autoload_files.php')) {
  797. $maps = array('files' => require $targetDir . '/autoload_files.php');
  798. } else {
  799. $maps = array();
  800. }
  801. foreach ((array) $loader as $prop => $value) {
  802. if ($value && 0 === strpos($prop, $prefix)) {
  803. $maps[substr($prop, $prefixLen)] = $value;
  804. }
  805. }
  806. foreach ($maps as $prop => $value) {
  807. if (count($value) > 32767) {
  808. $staticPhpVersion = 70000;
  809. }
  810. $value = strtr(
  811. var_export($value, true),
  812. array(
  813. $absoluteVendorPathCode => $vendorPathCode,
  814. $absoluteVendorPharPathCode => $vendorPharPathCode,
  815. $absoluteAppBaseDirCode => $appBaseDirCode,
  816. $absoluteAppBaseDirPharCode => $appBaseDirPharCode,
  817. )
  818. );
  819. $value = ltrim(preg_replace('/^ */m', ' $0$0', $value));
  820. $file .= sprintf(" public static $%s = %s;\n\n", $prop, $value);
  821. if ('files' !== $prop) {
  822. $initializer .= " \$loader->$prop = ComposerStaticInit$suffix::\$$prop;\n";
  823. }
  824. }
  825. return $file . <<<INITIALIZER
  826. public static function getInitializer(ClassLoader \$loader)
  827. {
  828. return \Closure::bind(function () use (\$loader) {
  829. $initializer
  830. }, null, ClassLoader::class);
  831. }
  832. }
  833. INITIALIZER;
  834. }
  835. protected function parseAutoloadsType(array $packageMap, $type, RootPackageInterface $rootPackage)
  836. {
  837. $autoloads = array();
  838. foreach ($packageMap as $item) {
  839. list($package, $installPath) = $item;
  840. $autoload = $package->getAutoload();
  841. if ($this->devMode && $package === $rootPackage) {
  842. $autoload = array_merge_recursive($autoload, $package->getDevAutoload());
  843. }
  844. if (!isset($autoload[$type]) || !is_array($autoload[$type])) {
  845. continue;
  846. }
  847. if (null !== $package->getTargetDir() && $package !== $rootPackage) {
  848. $installPath = substr($installPath, 0, -strlen('/'.$package->getTargetDir()));
  849. }
  850. foreach ($autoload[$type] as $namespace => $paths) {
  851. foreach ((array) $paths as $path) {
  852. if (($type === 'files' || $type === 'classmap' || $type === 'exclude-from-classmap') && $package->getTargetDir() && !is_readable($installPath.'/'.$path)) {
  853. if ($package === $rootPackage) {
  854. $targetDir = str_replace('\\<dirsep\\>', '[\\\\/]', preg_quote(str_replace(array('/', '\\'), '<dirsep>', $package->getTargetDir())));
  855. $path = ltrim(preg_replace('{^'.$targetDir.'}', '', ltrim($path, '\\/')), '\\/');
  856. } else {
  857. $path = $package->getTargetDir() . '/' . $path;
  858. }
  859. }
  860. if ($type === 'exclude-from-classmap') {
  861. $path = preg_replace('{/+}', '/', preg_quote(trim(strtr($path, '\\', '/'), '/')));
  862. $path = strtr($path, array('\\*\\*' => '.+?', '\\*' => '[^/]+?'));
  863. $updir = null;
  864. $path = preg_replace_callback(
  865. '{^((?:(?:\\\\\\.){1,2}+/)+)}',
  866. function ($matches) use (&$updir) {
  867. if (isset($matches[1])) {
  868. $updir = str_replace('\\.', '.', $matches[1]);
  869. }
  870. return '';
  871. },
  872. $path
  873. );
  874. if (empty($installPath)) {
  875. $installPath = strtr(getcwd(), '\\', '/');
  876. }
  877. $resolvedPath = realpath($installPath . '/' . $updir);
  878. $autoloads[] = preg_quote(strtr($resolvedPath, '\\', '/')) . '/' . $path . '($|/)';
  879. continue;
  880. }
  881. $relativePath = empty($installPath) ? (empty($path) ? '.' : $path) : $installPath.'/'.$path;
  882. if ($type === 'files') {
  883. $autoloads[$this->getFileIdentifier($package, $path)] = $relativePath;
  884. continue;
  885. }
  886. if ($type === 'classmap') {
  887. $autoloads[] = $relativePath;
  888. continue;
  889. }
  890. $autoloads[$namespace][] = $relativePath;
  891. }
  892. }
  893. }
  894. return $autoloads;
  895. }
  896. protected function getFileIdentifier(PackageInterface $package, $path)
  897. {
  898. return md5($package->getName() . ':' . $path);
  899. }
  900. protected function filterPackageMap(array $packageMap, RootPackageInterface $rootPackage)
  901. {
  902. $packages = array();
  903. $include = array();
  904. $replacedBy = array();
  905. foreach ($packageMap as $item) {
  906. $package = $item[0];
  907. $name = $package->getName();
  908. $packages[$name] = $package;
  909. foreach ($package->getReplaces() as $replace) {
  910. $replacedBy[$replace->getTarget()] = $name;
  911. }
  912. }
  913. $add = function (PackageInterface $package) use (&$add, $packages, &$include, $replacedBy) {
  914. foreach ($package->getRequires() as $link) {
  915. $target = $link->getTarget();
  916. if (isset($replacedBy[$target])) {
  917. $target = $replacedBy[$target];
  918. }
  919. if (!isset($include[$target])) {
  920. $include[$target] = true;
  921. if (isset($packages[$target])) {
  922. $add($packages[$target]);
  923. }
  924. }
  925. }
  926. };
  927. $add($rootPackage);
  928. return array_filter(
  929. $packageMap,
  930. function ($item) use ($include) {
  931. $package = $item[0];
  932. foreach ($package->getNames() as $name) {
  933. if (isset($include[$name])) {
  934. return true;
  935. }
  936. }
  937. return false;
  938. }
  939. );
  940. }
  941. protected function sortPackageMap(array $packageMap)
  942. {
  943. $packages = array();
  944. $paths = array();
  945. foreach ($packageMap as $item) {
  946. list($package, $path) = $item;
  947. $name = $package->getName();
  948. $packages[$name] = $package;
  949. $paths[$name] = $path;
  950. }
  951. $sortedPackages = PackageSorter::sortPackages($packages);
  952. $sortedPackageMap = array();
  953. foreach ($sortedPackages as $package) {
  954. $name = $package->getName();
  955. $sortedPackageMap[] = array($packages[$name], $paths[$name]);
  956. }
  957. return $sortedPackageMap;
  958. }
  959. }
  960. <?php
  961. namespace Composer\Autoload;
  962. use Symfony\Component\Finder\Finder;
  963. use Composer\IO\IOInterface;
  964. use Composer\Util\Filesystem;
  965. class ClassMapGenerator
  966. {
  967. public static function dump($dirs, $file)
  968. {
  969. $maps = array();
  970. foreach ($dirs as $dir) {
  971. $maps = array_merge($maps, static::createMap($dir));
  972. }
  973. file_put_contents($file, sprintf('<?php return %s;', var_export($maps, true)));
  974. }
  975. public static function createMap($path, $excluded = null, IOInterface $io = null, $namespace = null, $autoloadType = null, &$scannedFiles = array())
  976. {
  977. $basePath = $path;
  978. if (is_string($path)) {
  979. if (is_file($path)) {
  980. $path = array(new \SplFileInfo($path));
  981. } elseif (is_dir($path) || strpos($path, '*') !== false) {
  982. $path = Finder::create()->files()->followLinks()->name('/\.(php|inc|hh)$/')->in($path);
  983. } else {
  984. throw new \RuntimeException(
  985. 'Could not scan for classes inside "'.$path.
  986. '" which does not appear to be a file nor a folder'
  987. );
  988. }
  989. } elseif (null !== $autoloadType) {
  990. throw new \RuntimeException('Path must be a string when specifying an autoload type');
  991. }
  992. $map = array();
  993. $filesystem = new Filesystem();
  994. $cwd = realpath(getcwd());
  995. foreach ($path as $file) {
  996. $filePath = $file->getPathname();
  997. if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
  998. continue;
  999. }
  1000. if (!$filesystem->isAbsolutePath($filePath)) {
  1001. $filePath = $cwd . '/' . $filePath;
  1002. $filePath = $filesystem->normalizePath($filePath);
  1003. } else {
  1004. $filePath = preg_replace('{[\\\\/]{2,}}', '/', $filePath);
  1005. }
  1006. $realPath = realpath($filePath);
  1007. if (isset($scannedFiles[$realPath])) {
  1008. continue;
  1009. }
  1010. if ($excluded && preg_match($excluded, strtr($realPath, '\\', '/'))) {
  1011. continue;
  1012. }
  1013. if ($excluded && preg_match($excluded, strtr($filePath, '\\', '/'))) {
  1014. continue;
  1015. }
  1016. $classes = self::findClasses($filePath);
  1017. if (null !== $autoloadType) {
  1018. $classes = self::filterByNamespace($classes, $filePath, $namespace, $autoloadType, $basePath, $io);
  1019. if ($classes) {
  1020. $scannedFiles[$realPath] = true;
  1021. }
  1022. } else {
  1023. $scannedFiles[$realPath] = true;
  1024. }
  1025. foreach ($classes as $class) {
  1026. if (null === $autoloadType && null !== $namespace && '' !== $namespace && 0 !== strpos($class, $namespace)) {
  1027. continue;
  1028. }
  1029. if (!isset($map[$class])) {
  1030. $map[$class] = $filePath;
  1031. } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($map[$class].' '.$filePath, '\\', '/'))) {
  1032. $io->writeError(
  1033. '<warning>Warning: Ambiguous class resolution, "'.$class.'"'.
  1034. ' was found in both "'.$map[$class].'" and "'.$filePath.'", the first will be used.</warning>'
  1035. );
  1036. }
  1037. }
  1038. }
  1039. return $map;
  1040. }
  1041. private static function filterByNamespace($classes, $filePath, $baseNamespace, $namespaceType, $basePath, $io)
  1042. {
  1043. $validClasses = array();
  1044. $rejectedClasses = array();
  1045. $realSubPath = substr($filePath, strlen($basePath) + 1);
  1046. $realSubPath = substr($realSubPath, 0, strrpos($realSubPath, '.'));
  1047. foreach ($classes as $class) {
  1048. if ('' !== $baseNamespace && 0 !== strpos($class, $baseNamespace)) {
  1049. continue;
  1050. }
  1051. if ('psr-0' === $namespaceType) {
  1052. $namespaceLength = strrpos($class, '\\');
  1053. if (false !== $namespaceLength) {
  1054. $namespace = substr($class, 0, $namespaceLength + 1);
  1055. $className = substr($class, $namespaceLength + 1);
  1056. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $namespace)
  1057. . str_replace('_', DIRECTORY_SEPARATOR, $className);
  1058. } else {
  1059. $subPath = str_replace('_', DIRECTORY_SEPARATOR, $class);
  1060. }
  1061. } elseif ('psr-4' === $namespaceType) {
  1062. $subNamespace = ('' !== $baseNamespace) ? substr($class, strlen($baseNamespace)) : $class;
  1063. $subPath = str_replace('\\', DIRECTORY_SEPARATOR, $subNamespace);
  1064. } else {
  1065. throw new \RuntimeException("namespaceType must be psr-0 or psr-4, $namespaceType given");
  1066. }
  1067. if ($subPath === $realSubPath) {
  1068. $validClasses[] = $class;
  1069. } else {
  1070. $rejectedClasses[] = $class;
  1071. }
  1072. }
  1073. if (empty($validClasses)) {
  1074. foreach ($rejectedClasses as $class) {
  1075. if ($io) {
  1076. $io->writeError("<warning>Class $class located in ".preg_replace('{^'.preg_quote(getcwd()).'}', '.', $filePath, 1)." does not comply with $namespaceType autoloading standard. Skipping.</warning>");
  1077. }
  1078. }
  1079. return array();
  1080. }
  1081. return $validClasses;
  1082. }
  1083. private static function findClasses($path)
  1084. {
  1085. $extraTypes = PHP_VERSION_ID < 50400 ? '' : '|trait';
  1086. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '3.3', '>=')) {
  1087. $extraTypes .= '|enum';
  1088. }
  1089. $contents = @php_strip_whitespace($path);
  1090. if (!$contents) {
  1091. if (!file_exists($path)) {
  1092. $message = 'File at "%s" does not exist, check your classmap definitions';
  1093. } elseif (!is_readable($path)) {
  1094. $message = 'File at "%s" is not readable, check its permissions';
  1095. } elseif ('' === trim(file_get_contents($path))) {
  1096. return array();
  1097. } else {
  1098. $message = 'File at "%s" could not be parsed as PHP, it may be binary or corrupted';
  1099. }
  1100. $error = error_get_last();
  1101. if (isset($error['message'])) {
  1102. $message .= PHP_EOL . 'The following message may be helpful:' . PHP_EOL . $error['message'];
  1103. }
  1104. throw new \RuntimeException(sprintf($message, $path));
  1105. }
  1106. if (!preg_match('{\b(?:class|interface'.$extraTypes.')\s}i', $contents)) {
  1107. return array();
  1108. }
  1109. $contents = preg_replace('{<<<[ \t]*([\'"]?)(\w+)\\1(?:\r\n|\n|\r)(?:.*?)(?:\r\n|\n|\r)(?:\s*)\\2(?=\s+|[;,.)])}s', 'null', $contents);
  1110. $contents = preg_replace('{"[^"\\\\]*+(\\\\.[^"\\\\]*+)*+"|\'[^\'\\\\]*+(\\\\.[^\'\\\\]*+)*+\'}s', 'null', $contents);
  1111. if (strpos($contents, '<?') !== 0) {
  1112. $contents = preg_replace('{^.+?<\?}s', '<?', $contents, 1, $replacements);
  1113. if ($replacements === 0) {
  1114. return array();
  1115. }
  1116. }
  1117. $contents = preg_replace('{\?>(?:[^<]++|<(?!\?))*+<\?}s', '?><?', $contents);
  1118. $pos = strrpos($contents, '?>');
  1119. if (false !== $pos && false === strpos(substr($contents, $pos), '<?')) {
  1120. $contents = substr($contents, 0, $pos);
  1121. }
  1122. if (preg_match('{(<\?)(?!(php|hh))}i', $contents)) {
  1123. $contents = preg_replace('{//.* | /\*(?:[^*]++|\*(?!/))*\*/}x', '', $contents);
  1124. }
  1125. preg_match_all('{
  1126. (?:
  1127. \b(?<![\$:>])(?P<type>class|interface'.$extraTypes.') \s++ (?P<name>[a-zA-Z_\x7f-\xff:][a-zA-Z0-9_\x7f-\xff:\-]*+)
  1128. | \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*+ [\{;]
  1129. )
  1130. }ix', $contents, $matches);
  1131. $classes = array();
  1132. $namespace = '';
  1133. for ($i = 0, $len = count($matches['type']); $i < $len; $i++) {
  1134. if (!empty($matches['ns'][$i])) {
  1135. $namespace = str_replace(array(' ', "\t", "\r", "\n"), '', $matches['nsname'][$i]) . '\\';
  1136. } else {
  1137. $name = $matches['name'][$i];
  1138. if ($name === 'extends' || $name === 'implements') {
  1139. continue;
  1140. }
  1141. if ($name[0] === ':') {
  1142. $name = 'xhp'.substr(str_replace(array('-', ':'), array('_', '__'), $name), 1);
  1143. } elseif ($matches['type'][$i] === 'enum') {
  1144. $name = rtrim($name, ':');
  1145. }
  1146. $classes[] = ltrim($namespace . $name, '\\');
  1147. }
  1148. }
  1149. return $classes;
  1150. }
  1151. }
  1152. <?php
  1153. namespace Composer;
  1154. use Composer\IO\IOInterface;
  1155. use Composer\Util\Filesystem;
  1156. use Composer\Util\Silencer;
  1157. use Symfony\Component\Finder\Finder;
  1158. class Cache
  1159. {
  1160. private static $cacheCollected = false;
  1161. private $io;
  1162. private $root;
  1163. private $enabled = true;
  1164. private $allowlist;
  1165. private $filesystem;
  1166. private $readOnly;
  1167. public function __construct(IOInterface $io, $cacheDir, $allowlist = 'a-z0-9.', Filesystem $filesystem = null, $readOnly = false)
  1168. {
  1169. $this->io = $io;
  1170. $this->root = rtrim($cacheDir, '/\\') . '/';
  1171. $this->allowlist = $allowlist;
  1172. $this->filesystem = $filesystem ?: new Filesystem();
  1173. $this->readOnly = (bool) $readOnly;
  1174. if (!self::isUsable($cacheDir)) {
  1175. $this->enabled = false;
  1176. return;
  1177. }
  1178. if (
  1179. (!is_dir($this->root) && !Silencer::call('mkdir', $this->root, 0777, true))
  1180. || !is_writable($this->root)
  1181. ) {
  1182. $this->io->writeError('<warning>Cannot create cache directory ' . $this->root . ', or directory is not writable. Proceeding without cache</warning>');
  1183. $this->enabled = false;
  1184. }
  1185. }
  1186. public function setReadOnly($readOnly)
  1187. {
  1188. $this->readOnly = (bool) $readOnly;
  1189. }
  1190. public function isReadOnly()
  1191. {
  1192. return $this->readOnly;
  1193. }
  1194. public static function isUsable($path)
  1195. {
  1196. return !preg_match('{(^|[\\\\/])(\$null|nul|NUL|/dev/null)([\\\\/]|$)}', $path);
  1197. }
  1198. public function isEnabled()
  1199. {
  1200. return $this->enabled;
  1201. }
  1202. public function getRoot()
  1203. {
  1204. return $this->root;
  1205. }
  1206. public function read($file)
  1207. {
  1208. if ($this->enabled) {
  1209. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1210. if (file_exists($this->root . $file)) {
  1211. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1212. return file_get_contents($this->root . $file);
  1213. }
  1214. }
  1215. return false;
  1216. }
  1217. public function write($file, $contents)
  1218. {
  1219. if ($this->enabled && !$this->readOnly) {
  1220. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1221. $this->io->writeError('Writing '.$this->root . $file.' into cache', true, IOInterface::DEBUG);
  1222. $tempFileName = $this->root . $file . uniqid('.', true) . '.tmp';
  1223. try {
  1224. return file_put_contents($tempFileName, $contents) !== false && rename($tempFileName, $this->root . $file);
  1225. } catch (\ErrorException $e) {
  1226. $this->io->writeError('<warning>Failed to write into cache: '.$e->getMessage().'</warning>', true, IOInterface::DEBUG);
  1227. if (preg_match('{^file_put_contents\(\): Only ([0-9]+) of ([0-9]+) bytes written}', $e->getMessage(), $m)) {
  1228. unlink($tempFileName);
  1229. $message = sprintf(
  1230. '<warning>Writing %1$s into cache failed after %2$u of %3$u bytes written, only %4$u bytes of free space available</warning>',
  1231. $tempFileName,
  1232. $m[1],
  1233. $m[2],
  1234. @disk_free_space(dirname($tempFileName))
  1235. );
  1236. $this->io->writeError($message);
  1237. return false;
  1238. }
  1239. throw $e;
  1240. }
  1241. }
  1242. return false;
  1243. }
  1244. public function copyFrom($file, $source)
  1245. {
  1246. if ($this->enabled && !$this->readOnly) {
  1247. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1248. $this->filesystem->ensureDirectoryExists(dirname($this->root . $file));
  1249. if (!file_exists($source)) {
  1250. $this->io->writeError('<error>'.$source.' does not exist, can not write into cache</error>');
  1251. } elseif ($this->io->isDebug()) {
  1252. $this->io->writeError('Writing '.$this->root . $file.' into cache from '.$source);
  1253. }
  1254. return copy($source, $this->root . $file);
  1255. }
  1256. return false;
  1257. }
  1258. public function copyTo($file, $target)
  1259. {
  1260. if ($this->enabled) {
  1261. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1262. if (file_exists($this->root . $file)) {
  1263. try {
  1264. touch($this->root . $file, filemtime($this->root . $file), time());
  1265. } catch (\ErrorException $e) {
  1266. Silencer::call('touch', $this->root . $file);
  1267. }
  1268. $this->io->writeError('Reading '.$this->root . $file.' from cache', true, IOInterface::DEBUG);
  1269. return copy($this->root . $file, $target);
  1270. }
  1271. }
  1272. return false;
  1273. }
  1274. public function gcIsNecessary()
  1275. {
  1276. return (!self::$cacheCollected && !mt_rand(0, 50));
  1277. }
  1278. public function remove($file)
  1279. {
  1280. if ($this->enabled) {
  1281. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1282. if (file_exists($this->root . $file)) {
  1283. return $this->filesystem->unlink($this->root . $file);
  1284. }
  1285. }
  1286. return false;
  1287. }
  1288. public function clear()
  1289. {
  1290. if ($this->enabled) {
  1291. $this->filesystem->emptyDirectory($this->root);
  1292. return true;
  1293. }
  1294. return false;
  1295. }
  1296. public function gc($ttl, $maxSize)
  1297. {
  1298. if ($this->enabled) {
  1299. $expire = new \DateTime();
  1300. $expire->modify('-'.$ttl.' seconds');
  1301. $finder = $this->getFinder()->date('until '.$expire->format('Y-m-d H:i:s'));
  1302. foreach ($finder as $file) {
  1303. $this->filesystem->unlink($file->getPathname());
  1304. }
  1305. $totalSize = $this->filesystem->size($this->root);
  1306. if ($totalSize > $maxSize) {
  1307. $iterator = $this->getFinder()->sortByAccessedTime()->getIterator();
  1308. while ($totalSize > $maxSize && $iterator->valid()) {
  1309. $filepath = $iterator->current()->getPathname();
  1310. $totalSize -= $this->filesystem->size($filepath);
  1311. $this->filesystem->unlink($filepath);
  1312. $iterator->next();
  1313. }
  1314. }
  1315. self::$cacheCollected = true;
  1316. return true;
  1317. }
  1318. return false;
  1319. }
  1320. public function sha1($file)
  1321. {
  1322. if ($this->enabled) {
  1323. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1324. if (file_exists($this->root . $file)) {
  1325. return sha1_file($this->root . $file);
  1326. }
  1327. }
  1328. return false;
  1329. }
  1330. public function sha256($file)
  1331. {
  1332. if ($this->enabled) {
  1333. $file = preg_replace('{[^'.$this->allowlist.']}i', '-', $file);
  1334. if (file_exists($this->root . $file)) {
  1335. return hash_file('sha256', $this->root . $file);
  1336. }
  1337. }
  1338. return false;
  1339. }
  1340. protected function getFinder()
  1341. {
  1342. return Finder::create()->in($this->root)->files();
  1343. }
  1344. }
  1345. <?php
  1346. namespace Composer\Command;
  1347. use Symfony\Component\Console\Input\InputInterface;
  1348. use Symfony\Component\Console\Output\OutputInterface;
  1349. class AboutCommand extends BaseCommand
  1350. {
  1351. protected function configure()
  1352. {
  1353. $this
  1354. ->setName('about')
  1355. ->setDescription('Shows the short information about Composer.')
  1356. ->setHelp(
  1357. <<<EOT
  1358. <info>php composer.phar about</info>
  1359. EOT
  1360. )
  1361. ;
  1362. }
  1363. protected function execute(InputInterface $input, OutputInterface $output)
  1364. {
  1365. $this->getIO()->write(
  1366. <<<EOT
  1367. <info>Composer - Dependency Manager for PHP</info>
  1368. <comment>Composer is a dependency manager tracking local dependencies of your projects and libraries.
  1369. See https://getcomposer.org/ for more information.</comment>
  1370. EOT
  1371. );
  1372. return 0;
  1373. }
  1374. }
  1375. <?php
  1376. namespace Composer\Command;
  1377. use Composer\Factory;
  1378. use Composer\IO\IOInterface;
  1379. use Composer\Config;
  1380. use Composer\Composer;
  1381. use Composer\Repository\CompositeRepository;
  1382. use Composer\Repository\RepositoryFactory;
  1383. use Composer\Script\ScriptEvents;
  1384. use Composer\Plugin\CommandEvent;
  1385. use Composer\Plugin\PluginEvents;
  1386. use Composer\Util\Filesystem;
  1387. use Composer\Util\Loop;
  1388. use Composer\Util\ProcessExecutor;
  1389. use Symfony\Component\Console\Input\InputArgument;
  1390. use Symfony\Component\Console\Input\InputInterface;
  1391. use Symfony\Component\Console\Input\InputOption;
  1392. use Symfony\Component\Console\Output\OutputInterface;
  1393. class ArchiveCommand extends BaseCommand
  1394. {
  1395. protected function configure()
  1396. {
  1397. $this
  1398. ->setName('archive')
  1399. ->setDescription('Creates an archive of this composer package.')
  1400. ->setDefinition(array(
  1401. new InputArgument('package', InputArgument::OPTIONAL, 'The package to archive instead of the current project'),
  1402. new InputArgument('version', InputArgument::OPTIONAL, 'A version constraint to find the package to archive'),
  1403. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the resulting archive: tar or zip'),
  1404. new InputOption('dir', null, InputOption::VALUE_REQUIRED, 'Write the archive to this directory'),
  1405. new InputOption('file', null, InputOption::VALUE_REQUIRED, 'Write the archive with the given file name.'
  1406. .' Note that the format will be appended.'),
  1407. new InputOption('ignore-filters', false, InputOption::VALUE_NONE, 'Ignore filters when saving package'),
  1408. ))
  1409. ->setHelp(
  1410. <<<EOT
  1411. The <info>archive</info> command creates an archive of the specified format
  1412. containing the files and directories of the Composer project or the specified
  1413. package in the specified version and writes it to the specified directory.
  1414. <info>php composer.phar archive [--format=zip] [--dir=/foo] [package [version]]</info>
  1415. Read more at https://getcomposer.org/doc/03-cli.md#archive
  1416. EOT
  1417. )
  1418. ;
  1419. }
  1420. protected function execute(InputInterface $input, OutputInterface $output)
  1421. {
  1422. $composer = $this->getComposer(false);
  1423. $config = null;
  1424. if ($composer) {
  1425. $config = $composer->getConfig();
  1426. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'archive', $input, $output);
  1427. $eventDispatcher = $composer->getEventDispatcher();
  1428. $eventDispatcher->dispatch($commandEvent->getName(), $commandEvent);
  1429. $eventDispatcher->dispatchScript(ScriptEvents::PRE_ARCHIVE_CMD);
  1430. }
  1431. if (!$config) {
  1432. $config = Factory::createConfig();
  1433. }
  1434. if (null === $input->getOption('format')) {
  1435. $input->setOption('format', $config->get('archive-format'));
  1436. }
  1437. if (null === $input->getOption('dir')) {
  1438. $input->setOption('dir', $config->get('archive-dir'));
  1439. }
  1440. $returnCode = $this->archive(
  1441. $this->getIO(),
  1442. $config,
  1443. $input->getArgument('package'),
  1444. $input->getArgument('version'),
  1445. $input->getOption('format'),
  1446. $input->getOption('dir'),
  1447. $input->getOption('file'),
  1448. $input->getOption('ignore-filters'),
  1449. $composer
  1450. );
  1451. if (0 === $returnCode && $composer) {
  1452. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ARCHIVE_CMD);
  1453. }
  1454. return $returnCode;
  1455. }
  1456. protected function archive(IOInterface $io, Config $config, $packageName = null, $version = null, $format = 'tar', $dest = '.', $fileName = null, $ignoreFilters = false, Composer $composer = null)
  1457. {
  1458. if ($composer) {
  1459. $archiveManager = $composer->getArchiveManager();
  1460. } else {
  1461. $factory = new Factory;
  1462. $process = new ProcessExecutor();
  1463. $httpDownloader = Factory::createHttpDownloader($io, $config);
  1464. $downloadManager = $factory->createDownloadManager($io, $config, $httpDownloader, $process);
  1465. $archiveManager = $factory->createArchiveManager($config, $downloadManager, new Loop($httpDownloader, $process));
  1466. }
  1467. if ($packageName) {
  1468. $package = $this->selectPackage($io, $packageName, $version);
  1469. if (!$package) {
  1470. return 1;
  1471. }
  1472. } else {
  1473. $package = $this->getComposer()->getPackage();
  1474. }
  1475. $io->writeError('<info>Creating the archive into "'.$dest.'".</info>');
  1476. $packagePath = $archiveManager->archive($package, $format, $dest, $fileName, $ignoreFilters);
  1477. $fs = new Filesystem;
  1478. $shortPath = $fs->findShortestPath(getcwd(), $packagePath, true);
  1479. $io->writeError('Created: ', false);
  1480. $io->write(strlen($shortPath) < strlen($packagePath) ? $shortPath : $packagePath);
  1481. return 0;
  1482. }
  1483. protected function selectPackage(IOInterface $io, $packageName, $version = null)
  1484. {
  1485. $io->writeError('<info>Searching for the specified package.</info>');
  1486. if ($composer = $this->getComposer(false)) {
  1487. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  1488. $repo = new CompositeRepository(array_merge(array($localRepo), $composer->getRepositoryManager()->getRepositories()));
  1489. } else {
  1490. $defaultRepos = RepositoryFactory::defaultRepos($this->getIO());
  1491. $io->writeError('No composer.json found in the current directory, searching packages from ' . implode(', ', array_keys($defaultRepos)));
  1492. $repo = new CompositeRepository($defaultRepos);
  1493. }
  1494. $packages = $repo->findPackages($packageName, $version);
  1495. if (count($packages) > 1) {
  1496. $package = reset($packages);
  1497. $io->writeError('<info>Found multiple matches, selected '.$package->getPrettyString().'.</info>');
  1498. $io->writeError('Alternatives were '.implode(', ', array_map(function ($p) {
  1499. return $p->getPrettyString();
  1500. }, $packages)).'.');
  1501. $io->writeError('<comment>Please use a more specific constraint to pick a different package.</comment>');
  1502. } elseif ($packages) {
  1503. $package = reset($packages);
  1504. $io->writeError('<info>Found an exact match '.$package->getPrettyString().'.</info>');
  1505. } else {
  1506. $io->writeError('<error>Could not find a package matching '.$packageName.'.</error>');
  1507. return false;
  1508. }
  1509. return $package;
  1510. }
  1511. }
  1512. <?php
  1513. namespace Composer\Command;
  1514. use Composer\Composer;
  1515. use Composer\Config;
  1516. use Composer\Console\Application;
  1517. use Composer\Factory;
  1518. use Composer\IO\IOInterface;
  1519. use Composer\IO\NullIO;
  1520. use Composer\Plugin\PreCommandRunEvent;
  1521. use Composer\Package\Version\VersionParser;
  1522. use Composer\Plugin\PluginEvents;
  1523. use Symfony\Component\Console\Helper\Table;
  1524. use Symfony\Component\Console\Input\InputInterface;
  1525. use Symfony\Component\Console\Output\OutputInterface;
  1526. use Symfony\Component\Console\Command\Command;
  1527. abstract class BaseCommand extends Command
  1528. {
  1529. private $composer;
  1530. private $io;
  1531. public function getComposer($required = true, $disablePlugins = null)
  1532. {
  1533. if (null === $this->composer) {
  1534. $application = $this->getApplication();
  1535. if ($application instanceof Application) {
  1536. $this->composer = $application->getComposer($required, $disablePlugins);
  1537. } elseif ($required) {
  1538. throw new \RuntimeException(
  1539. 'Could not create a Composer\Composer instance, you must inject '.
  1540. 'one if this command is not used with a Composer\Console\Application instance'
  1541. );
  1542. }
  1543. }
  1544. return $this->composer;
  1545. }
  1546. public function setComposer(Composer $composer)
  1547. {
  1548. $this->composer = $composer;
  1549. }
  1550. public function resetComposer()
  1551. {
  1552. $this->composer = null;
  1553. $this->getApplication()->resetComposer();
  1554. }
  1555. public function isProxyCommand()
  1556. {
  1557. return false;
  1558. }
  1559. public function getIO()
  1560. {
  1561. if (null === $this->io) {
  1562. $application = $this->getApplication();
  1563. if ($application instanceof Application) {
  1564. $this->io = $application->getIO();
  1565. } else {
  1566. $this->io = new NullIO();
  1567. }
  1568. }
  1569. return $this->io;
  1570. }
  1571. public function setIO(IOInterface $io)
  1572. {
  1573. $this->io = $io;
  1574. }
  1575. protected function initialize(InputInterface $input, OutputInterface $output)
  1576. {
  1577. $disablePlugins = $input->hasParameterOption('--no-plugins');
  1578. $composer = $this->getComposer(false, $disablePlugins);
  1579. if (null === $composer) {
  1580. $composer = Factory::createGlobal($this->getIO(), $disablePlugins);
  1581. }
  1582. if ($composer) {
  1583. $preCommandRunEvent = new PreCommandRunEvent(PluginEvents::PRE_COMMAND_RUN, $input, $this->getName());
  1584. $composer->getEventDispatcher()->dispatch($preCommandRunEvent->getName(), $preCommandRunEvent);
  1585. }
  1586. if (true === $input->hasParameterOption(array('--no-ansi')) && $input->hasOption('no-progress')) {
  1587. $input->setOption('no-progress', true);
  1588. }
  1589. parent::initialize($input, $output);
  1590. }
  1591. protected function getPreferredInstallOptions(Config $config, InputInterface $input, $keepVcsRequiresPreferSource = false)
  1592. {
  1593. $preferSource = false;
  1594. $preferDist = false;
  1595. switch ($config->get('preferred-install')) {
  1596. case 'source':
  1597. $preferSource = true;
  1598. break;
  1599. case 'dist':
  1600. $preferDist = true;
  1601. break;
  1602. case 'auto':
  1603. default:
  1604. break;
  1605. }
  1606. if ($input->getOption('prefer-source') || $input->getOption('prefer-dist') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'))) {
  1607. $preferSource = $input->getOption('prefer-source') || ($keepVcsRequiresPreferSource && $input->hasOption('keep-vcs') && $input->getOption('keep-vcs'));
  1608. $preferDist = (bool) $input->getOption('prefer-dist');
  1609. }
  1610. return array($preferSource, $preferDist);
  1611. }
  1612. protected function formatRequirements(array $requirements)
  1613. {
  1614. $requires = array();
  1615. $requirements = $this->normalizeRequirements($requirements);
  1616. foreach ($requirements as $requirement) {
  1617. if (!isset($requirement['version'])) {
  1618. throw new \UnexpectedValueException('Option '.$requirement['name'] .' is missing a version constraint, use e.g. '.$requirement['name'].':^1.0');
  1619. }
  1620. $requires[$requirement['name']] = $requirement['version'];
  1621. }
  1622. return $requires;
  1623. }
  1624. protected function normalizeRequirements(array $requirements)
  1625. {
  1626. $parser = new VersionParser();
  1627. return $parser->parseNameVersionPairs($requirements);
  1628. }
  1629. protected function renderTable(array $table, OutputInterface $output)
  1630. {
  1631. $renderer = new Table($output);
  1632. $renderer->setStyle('compact');
  1633. $rendererStyle = $renderer->getStyle();
  1634. if (method_exists($rendererStyle, 'setVerticalBorderChars')) {
  1635. $rendererStyle->setVerticalBorderChars('');
  1636. } else {
  1637. $rendererStyle->setVerticalBorderChar('');
  1638. }
  1639. $rendererStyle->setCellRowContentFormat('%s ');
  1640. $renderer->setRows($table)->render();
  1641. }
  1642. }
  1643. <?php
  1644. namespace Composer\Command;
  1645. use Composer\Package\Link;
  1646. use Composer\Package\PackageInterface;
  1647. use Composer\Package\RootPackage;
  1648. use Composer\Repository\InstalledArrayRepository;
  1649. use Composer\Repository\CompositeRepository;
  1650. use Composer\Repository\RootPackageRepository;
  1651. use Composer\Repository\InstalledRepository;
  1652. use Composer\Repository\PlatformRepository;
  1653. use Composer\Repository\RepositoryFactory;
  1654. use Composer\Plugin\CommandEvent;
  1655. use Composer\Plugin\PluginEvents;
  1656. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  1657. use Composer\Package\Version\VersionParser;
  1658. use Symfony\Component\Console\Input\InputArgument;
  1659. use Symfony\Component\Console\Input\InputInterface;
  1660. use Symfony\Component\Console\Input\InputOption;
  1661. use Symfony\Component\Console\Output\OutputInterface;
  1662. class BaseDependencyCommand extends BaseCommand
  1663. {
  1664. const ARGUMENT_PACKAGE = 'package';
  1665. const ARGUMENT_CONSTRAINT = 'constraint';
  1666. const OPTION_RECURSIVE = 'recursive';
  1667. const OPTION_TREE = 'tree';
  1668. protected $colors;
  1669. protected function configure()
  1670. {
  1671. $this->setDefinition(array(
  1672. new InputArgument(self::ARGUMENT_PACKAGE, InputArgument::REQUIRED, 'Package to inspect'),
  1673. new InputArgument(self::ARGUMENT_CONSTRAINT, InputArgument::OPTIONAL, 'Optional version constraint', '*'),
  1674. new InputOption(self::OPTION_RECURSIVE, 'r', InputOption::VALUE_NONE, 'Recursively resolves up to the root package'),
  1675. new InputOption(self::OPTION_TREE, 't', InputOption::VALUE_NONE, 'Prints the results as a nested tree'),
  1676. ));
  1677. }
  1678. protected function doExecute(InputInterface $input, OutputInterface $output, $inverted = false)
  1679. {
  1680. $composer = $this->getComposer();
  1681. $commandEvent = new CommandEvent(PluginEvents::COMMAND, $this->getName(), $input, $output);
  1682. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  1683. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  1684. $installedRepo = new InstalledRepository(array(
  1685. new RootPackageRepository($composer->getPackage()),
  1686. $composer->getRepositoryManager()->getLocalRepository(),
  1687. new PlatformRepository(array(), $platformOverrides),
  1688. ));
  1689. list($needle, $textConstraint) = array_pad(
  1690. explode(':', $input->getArgument(self::ARGUMENT_PACKAGE)),
  1691. 2,
  1692. $input->getArgument(self::ARGUMENT_CONSTRAINT)
  1693. );
  1694. $packages = $installedRepo->findPackagesWithReplacersAndProviders($needle);
  1695. if (empty($packages)) {
  1696. throw new \InvalidArgumentException(sprintf('Could not find package "%s" in your project', $needle));
  1697. }
  1698. if (!$installedRepo->findPackage($needle, $textConstraint)) {
  1699. $defaultRepos = new CompositeRepository(RepositoryFactory::defaultRepos($this->getIO()));
  1700. if ($match = $defaultRepos->findPackage($needle, $textConstraint)) {
  1701. $installedRepo->addRepository(new InstalledArrayRepository(array(clone $match)));
  1702. }
  1703. }
  1704. $needles = array($needle);
  1705. if ($inverted) {
  1706. foreach ($packages as $package) {
  1707. $needles = array_merge($needles, array_map(function (Link $link) {
  1708. return $link->getTarget();
  1709. }, $package->getReplaces()));
  1710. }
  1711. }
  1712. if ('*' !== $textConstraint) {
  1713. $versionParser = new VersionParser();
  1714. $constraint = $versionParser->parseConstraints($textConstraint);
  1715. } else {
  1716. $constraint = null;
  1717. }
  1718. $renderTree = $input->getOption(self::OPTION_TREE);
  1719. $recursive = $renderTree || $input->getOption(self::OPTION_RECURSIVE);
  1720. $results = $installedRepo->getDependents($needles, $constraint, $inverted, $recursive);
  1721. if (empty($results)) {
  1722. $extra = (null !== $constraint) ? sprintf(' in versions %smatching %s', $inverted ? 'not ' : '', $textConstraint) : '';
  1723. $this->getIO()->writeError(sprintf(
  1724. '<info>There is no installed package depending on "%s"%s</info>',
  1725. $needle,
  1726. $extra
  1727. ));
  1728. } elseif ($renderTree) {
  1729. $this->initStyles($output);
  1730. $root = $packages[0];
  1731. $this->getIO()->write(sprintf('<info>%s</info> %s %s', $root->getPrettyName(), $root->getPrettyVersion(), $root->getDescription()));
  1732. $this->printTree($results);
  1733. } else {
  1734. $this->printTable($output, $results);
  1735. }
  1736. return 0;
  1737. }
  1738. protected function printTable(OutputInterface $output, $results)
  1739. {
  1740. $table = array();
  1741. $doubles = array();
  1742. do {
  1743. $queue = array();
  1744. $rows = array();
  1745. foreach ($results as $result) {
  1746. list($package, $link, $children) = $result;
  1747. $unique = (string) $link;
  1748. if (isset($doubles[$unique])) {
  1749. continue;
  1750. }
  1751. $doubles[$unique] = true;
  1752. $version = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '-' : $package->getPrettyVersion();
  1753. $rows[] = array($package->getPrettyName(), $version, $link->getDescription(), sprintf('%s (%s)', $link->getTarget(), $link->getPrettyConstraint()));
  1754. if ($children) {
  1755. $queue = array_merge($queue, $children);
  1756. }
  1757. }
  1758. $results = $queue;
  1759. $table = array_merge($rows, $table);
  1760. } while (!empty($results));
  1761. $this->renderTable($table, $output);
  1762. }
  1763. protected function initStyles(OutputInterface $output)
  1764. {
  1765. $this->colors = array(
  1766. 'green',
  1767. 'yellow',
  1768. 'cyan',
  1769. 'magenta',
  1770. 'blue',
  1771. );
  1772. foreach ($this->colors as $color) {
  1773. $style = new OutputFormatterStyle($color);
  1774. $output->getFormatter()->setStyle($color, $style);
  1775. }
  1776. }
  1777. protected function printTree($results, $prefix = '', $level = 1)
  1778. {
  1779. $count = count($results);
  1780. $idx = 0;
  1781. foreach ($results as $result) {
  1782. list($package, $link, $children) = $result;
  1783. $color = $this->colors[$level % count($this->colors)];
  1784. $prevColor = $this->colors[($level - 1) % count($this->colors)];
  1785. $isLast = (++$idx == $count);
  1786. $versionText = $package->getPrettyVersion() === RootPackage::DEFAULT_PRETTY_VERSION ? '' : $package->getPrettyVersion();
  1787. $packageText = rtrim(sprintf('<%s>%s</%1$s> %s', $color, $package->getPrettyName(), $versionText));
  1788. $linkText = sprintf('%s <%s>%s</%2$s> %s', $link->getDescription(), $prevColor, $link->getTarget(), $link->getPrettyConstraint());
  1789. $circularWarn = $children === false ? '(circular dependency aborted here)' : '';
  1790. $this->writeTreeLine(rtrim(sprintf("%s%s%s (%s) %s", $prefix, $isLast ? '└──' : '├──', $packageText, $linkText, $circularWarn)));
  1791. if ($children) {
  1792. $this->printTree($children, $prefix . ($isLast ? ' ' : '│ '), $level + 1);
  1793. }
  1794. }
  1795. }
  1796. private function writeTreeLine($line)
  1797. {
  1798. $io = $this->getIO();
  1799. if (!$io->isDecorated()) {
  1800. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  1801. }
  1802. $io->write($line);
  1803. }
  1804. }
  1805. <?php
  1806. namespace Composer\Command;
  1807. use Composer\Package\Link;
  1808. use Composer\Semver\Constraint\Constraint;
  1809. use Symfony\Component\Console\Input\InputInterface;
  1810. use Symfony\Component\Console\Input\InputOption;
  1811. use Symfony\Component\Console\Output\OutputInterface;
  1812. use Composer\Repository\PlatformRepository;
  1813. use Composer\Repository\RootPackageRepository;
  1814. use Composer\Repository\InstalledRepository;
  1815. class CheckPlatformReqsCommand extends BaseCommand
  1816. {
  1817. protected function configure()
  1818. {
  1819. $this->setName('check-platform-reqs')
  1820. ->setDescription('Check that platform requirements are satisfied.')
  1821. ->setDefinition(array(
  1822. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables checking of require-dev packages requirements.'),
  1823. new InputOption('lock', null, InputOption::VALUE_NONE, 'Checks requirements only from the lock file, not from installed packages.'),
  1824. ))
  1825. ->setHelp(
  1826. <<<EOT
  1827. Checks that your PHP and extensions versions match the platform requirements of the installed packages.
  1828. 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.
  1829. <info>php composer.phar check-platform-reqs</info>
  1830. EOT
  1831. );
  1832. }
  1833. protected function execute(InputInterface $input, OutputInterface $output)
  1834. {
  1835. $composer = $this->getComposer();
  1836. $requires = array();
  1837. $removePackages = array();
  1838. if ($input->getOption('lock')) {
  1839. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements using the lock file</info>');
  1840. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  1841. } else {
  1842. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  1843. if (!$installedRepo->getPackages()) {
  1844. $this->getIO()->writeError('<warning>No vendor dir present, checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements from the lock file</warning>');
  1845. $installedRepo = $composer->getLocker()->getLockedRepository(!$input->getOption('no-dev'));
  1846. } else {
  1847. if ($input->getOption('no-dev')) {
  1848. $removePackages = $installedRepo->getDevPackageNames();
  1849. }
  1850. $this->getIO()->writeError('<info>Checking '.($input->getOption('no-dev') ? 'non-dev ' : '').'platform requirements for packages in the vendor dir</info>');
  1851. }
  1852. }
  1853. if (!$input->getOption('no-dev')) {
  1854. $requires += $composer->getPackage()->getDevRequires();
  1855. }
  1856. foreach ($requires as $require => $link) {
  1857. $requires[$require] = array($link);
  1858. }
  1859. $installedRepo = new InstalledRepository(array($installedRepo, new RootPackageRepository($composer->getPackage())));
  1860. foreach ($installedRepo->getPackages() as $package) {
  1861. if (in_array($package->getName(), $removePackages, true)) {
  1862. continue;
  1863. }
  1864. foreach ($package->getRequires() as $require => $link) {
  1865. $requires[$require][] = $link;
  1866. }
  1867. }
  1868. ksort($requires);
  1869. $installedRepo->addRepository(new PlatformRepository(array(), array()));
  1870. $results = array();
  1871. $exitCode = 0;
  1872. foreach ($requires as $require => $links) {
  1873. if (PlatformRepository::isPlatformPackage($require)) {
  1874. $candidates = $installedRepo->findPackagesWithReplacersAndProviders($require);
  1875. if ($candidates) {
  1876. $reqResults = array();
  1877. foreach ($candidates as $candidate) {
  1878. $candidateConstraint = null;
  1879. if ($candidate->getName() === $require) {
  1880. $candidateConstraint = new Constraint('=', $candidate->getVersion());
  1881. $candidateConstraint->setPrettyString($candidate->getPrettyVersion());
  1882. } else {
  1883. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  1884. if ($link->getTarget() === $require) {
  1885. $candidateConstraint = $link->getConstraint();
  1886. break;
  1887. }
  1888. }
  1889. }
  1890. if (!$candidateConstraint) {
  1891. continue;
  1892. }
  1893. foreach ($links as $link) {
  1894. if (!$link->getConstraint()->matches($candidateConstraint)) {
  1895. $reqResults[] = array(
  1896. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  1897. $candidateConstraint->getPrettyString(),
  1898. $link,
  1899. '<error>failed</error>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  1900. );
  1901. continue 2;
  1902. }
  1903. }
  1904. $results[] = array(
  1905. $candidate->getName() === $require ? $candidate->getPrettyName() : $require,
  1906. $candidateConstraint->getPrettyString(),
  1907. null,
  1908. '<info>success</info>'.($candidate->getName() === $require ? '' : ' <comment>provided by '.$candidate->getPrettyName().'</comment>'),
  1909. );
  1910. continue 2;
  1911. }
  1912. $results = array_merge($results, $reqResults);
  1913. $exitCode = max($exitCode, 1);
  1914. continue;
  1915. }
  1916. $results[] = array(
  1917. $require,
  1918. 'n/a',
  1919. $links[0],
  1920. '<error>missing</error>',
  1921. );
  1922. $exitCode = max($exitCode, 2);
  1923. }
  1924. }
  1925. $this->printTable($output, $results);
  1926. return $exitCode;
  1927. }
  1928. protected function printTable(OutputInterface $output, $results)
  1929. {
  1930. $rows = array();
  1931. foreach ($results as $result) {
  1932. list($platformPackage, $version, $link, $status) = $result;
  1933. $rows[] = array(
  1934. $platformPackage,
  1935. $version,
  1936. $link ? sprintf('%s %s %s (%s)', $link->getSource(), $link->getDescription(), $link->getTarget(), $link->getPrettyConstraint()) : '',
  1937. $status,
  1938. );
  1939. }
  1940. $this->renderTable($rows, $output);
  1941. }
  1942. }
  1943. <?php
  1944. namespace Composer\Command;
  1945. use Composer\Cache;
  1946. use Composer\Factory;
  1947. use Symfony\Component\Console\Input\InputInterface;
  1948. use Symfony\Component\Console\Output\OutputInterface;
  1949. class ClearCacheCommand extends BaseCommand
  1950. {
  1951. protected function configure()
  1952. {
  1953. $this
  1954. ->setName('clear-cache')
  1955. ->setAliases(array('clearcache', 'cc'))
  1956. ->setDescription('Clears composer\'s internal package cache.')
  1957. ->setHelp(
  1958. <<<EOT
  1959. The <info>clear-cache</info> deletes all cached packages from composer's
  1960. cache directory.
  1961. Read more at https://getcomposer.org/doc/03-cli.md#clear-cache-clearcache-cc
  1962. EOT
  1963. )
  1964. ;
  1965. }
  1966. protected function execute(InputInterface $input, OutputInterface $output)
  1967. {
  1968. $config = Factory::createConfig();
  1969. $io = $this->getIO();
  1970. $cachePaths = array(
  1971. 'cache-vcs-dir' => $config->get('cache-vcs-dir'),
  1972. 'cache-repo-dir' => $config->get('cache-repo-dir'),
  1973. 'cache-files-dir' => $config->get('cache-files-dir'),
  1974. 'cache-dir' => $config->get('cache-dir'),
  1975. );
  1976. foreach ($cachePaths as $key => $cachePath) {
  1977. $cachePath = realpath($cachePath);
  1978. if (!$cachePath) {
  1979. $io->writeError("<info>Cache directory does not exist ($key): $cachePath</info>");
  1980. continue;
  1981. }
  1982. $cache = new Cache($io, $cachePath);
  1983. $cache->setReadOnly($config->get('cache-read-only'));
  1984. if (!$cache->isEnabled()) {
  1985. $io->writeError("<info>Cache is not enabled ($key): $cachePath</info>");
  1986. continue;
  1987. }
  1988. $io->writeError("<info>Clearing cache ($key): $cachePath</info>");
  1989. $cache->clear();
  1990. }
  1991. $io->writeError('<info>All caches cleared.</info>');
  1992. return 0;
  1993. }
  1994. }
  1995. <?php
  1996. namespace Composer\Command;
  1997. use Composer\Util\Platform;
  1998. use Composer\Util\Silencer;
  1999. use Symfony\Component\Console\Input\InputInterface;
  2000. use Symfony\Component\Console\Input\InputArgument;
  2001. use Symfony\Component\Console\Input\InputOption;
  2002. use Symfony\Component\Console\Output\OutputInterface;
  2003. use Composer\Config;
  2004. use Composer\Config\JsonConfigSource;
  2005. use Composer\Factory;
  2006. use Composer\IO\IOInterface;
  2007. use Composer\Json\JsonFile;
  2008. use Composer\Semver\VersionParser;
  2009. use Composer\Package\BasePackage;
  2010. class ConfigCommand extends BaseCommand
  2011. {
  2012. protected $config;
  2013. protected $configFile;
  2014. protected $configSource;
  2015. protected $authConfigFile;
  2016. protected $authConfigSource;
  2017. protected function configure()
  2018. {
  2019. $this
  2020. ->setName('config')
  2021. ->setDescription('Sets config options.')
  2022. ->setDefinition(array(
  2023. new InputOption('global', 'g', InputOption::VALUE_NONE, 'Apply command to the global config file'),
  2024. new InputOption('editor', 'e', InputOption::VALUE_NONE, 'Open editor'),
  2025. new InputOption('auth', 'a', InputOption::VALUE_NONE, 'Affect auth config file (only used for --editor)'),
  2026. new InputOption('unset', null, InputOption::VALUE_NONE, 'Unset the given setting-key'),
  2027. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List configuration settings'),
  2028. new InputOption('file', 'f', InputOption::VALUE_REQUIRED, 'If you want to choose a different composer.json or config.json'),
  2029. new InputOption('absolute', null, InputOption::VALUE_NONE, 'Returns absolute paths when fetching *-dir config values instead of relative'),
  2030. new InputOption('json', 'j', InputOption::VALUE_NONE, 'JSON decode the setting value, to be used with extra.* keys'),
  2031. 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'),
  2032. new InputOption('append', null, InputOption::VALUE_NONE, 'When adding a repository, append it (lowest priority) to the existing ones instead of prepending it (highest priority)'),
  2033. new InputArgument('setting-key', null, 'Setting key'),
  2034. new InputArgument('setting-value', InputArgument::IS_ARRAY, 'Setting value'),
  2035. ))
  2036. ->setHelp(
  2037. <<<EOT
  2038. This command allows you to edit composer config settings and repositories
  2039. in either the local composer.json file or the global config.json file.
  2040. Additionally it lets you edit most properties in the local composer.json.
  2041. To set a config setting:
  2042. <comment>%command.full_name% bin-dir bin/</comment>
  2043. To read a config setting:
  2044. <comment>%command.full_name% bin-dir</comment>
  2045. Outputs: <info>bin</info>
  2046. To edit the global config.json file:
  2047. <comment>%command.full_name% --global</comment>
  2048. To add a repository:
  2049. <comment>%command.full_name% repositories.foo vcs https://bar.com</comment>
  2050. To remove a repository (repo is a short alias for repositories):
  2051. <comment>%command.full_name% --unset repo.foo</comment>
  2052. To disable packagist:
  2053. <comment>%command.full_name% repo.packagist false</comment>
  2054. You can alter repositories in the global config.json file by passing in the
  2055. <info>--global</info> option.
  2056. To add or edit suggested packages you can use:
  2057. <comment>%command.full_name% suggest.package reason for the suggestion</comment>
  2058. To add or edit extra properties you can use:
  2059. <comment>%command.full_name% extra.property value</comment>
  2060. Or to add a complex value you can use json with:
  2061. <comment>%command.full_name% extra.property --json '{"foo":true, "bar": []}'</comment>
  2062. To edit the file in an external editor:
  2063. <comment>%command.full_name% --editor</comment>
  2064. To choose your editor you can set the "EDITOR" env variable.
  2065. To get a list of configuration values in the file:
  2066. <comment>%command.full_name% --list</comment>
  2067. You can always pass more than one option. As an example, if you want to edit the
  2068. global config.json file.
  2069. <comment>%command.full_name% --editor --global</comment>
  2070. Read more at https://getcomposer.org/doc/03-cli.md#config
  2071. EOT
  2072. )
  2073. ;
  2074. }
  2075. protected function initialize(InputInterface $input, OutputInterface $output)
  2076. {
  2077. parent::initialize($input, $output);
  2078. if ($input->getOption('global') && null !== $input->getOption('file')) {
  2079. throw new \RuntimeException('--file and --global can not be combined');
  2080. }
  2081. $io = $this->getIO();
  2082. $this->config = Factory::createConfig($io);
  2083. $configFile = $input->getOption('global')
  2084. ? ($this->config->get('home') . '/config.json')
  2085. : ($input->getOption('file') ?: Factory::getComposerFile());
  2086. if (
  2087. ($configFile === 'composer.json' || $configFile === './composer.json')
  2088. && !file_exists($configFile)
  2089. && realpath(getcwd()) === realpath($this->config->get('home'))
  2090. ) {
  2091. file_put_contents($configFile, "{\n}\n");
  2092. }
  2093. $this->configFile = new JsonFile($configFile, null, $io);
  2094. $this->configSource = new JsonConfigSource($this->configFile);
  2095. $authConfigFile = $input->getOption('global')
  2096. ? ($this->config->get('home') . '/auth.json')
  2097. : dirname(realpath($configFile)) . '/auth.json';
  2098. $this->authConfigFile = new JsonFile($authConfigFile, null, $io);
  2099. $this->authConfigSource = new JsonConfigSource($this->authConfigFile, true);
  2100. if ($input->getOption('global') && !$this->configFile->exists()) {
  2101. touch($this->configFile->getPath());
  2102. $this->configFile->write(array('config' => new \ArrayObject));
  2103. Silencer::call('chmod', $this->configFile->getPath(), 0600);
  2104. }
  2105. if ($input->getOption('global') && !$this->authConfigFile->exists()) {
  2106. touch($this->authConfigFile->getPath());
  2107. $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));
  2108. Silencer::call('chmod', $this->authConfigFile->getPath(), 0600);
  2109. }
  2110. if (!$this->configFile->exists()) {
  2111. throw new \RuntimeException(sprintf('File "%s" cannot be found in the current directory', $configFile));
  2112. }
  2113. }
  2114. protected function execute(InputInterface $input, OutputInterface $output)
  2115. {
  2116. if ($input->getOption('editor')) {
  2117. $editor = escapeshellcmd(getenv('EDITOR'));
  2118. if (!$editor) {
  2119. if (Platform::isWindows()) {
  2120. $editor = 'notepad';
  2121. } else {
  2122. foreach (array('editor', 'vim', 'vi', 'nano', 'pico', 'ed') as $candidate) {
  2123. if (exec('which '.$candidate)) {
  2124. $editor = $candidate;
  2125. break;
  2126. }
  2127. }
  2128. }
  2129. }
  2130. $file = $input->getOption('auth') ? $this->authConfigFile->getPath() : $this->configFile->getPath();
  2131. system($editor . ' ' . $file . (Platform::isWindows() ? '' : ' > `tty`'));
  2132. return 0;
  2133. }
  2134. if (!$input->getOption('global')) {
  2135. $this->config->merge($this->configFile->read());
  2136. $this->config->merge(array('config' => $this->authConfigFile->exists() ? $this->authConfigFile->read() : array()));
  2137. }
  2138. if ($input->getOption('list')) {
  2139. $this->listConfiguration($this->config->all(), $this->config->raw(), $output);
  2140. return 0;
  2141. }
  2142. $settingKey = $input->getArgument('setting-key');
  2143. if (!$settingKey || !is_string($settingKey)) {
  2144. return 0;
  2145. }
  2146. if (array() !== $input->getArgument('setting-value') && $input->getOption('unset')) {
  2147. throw new \RuntimeException('You can not combine a setting value with --unset');
  2148. }
  2149. if (array() === $input->getArgument('setting-value') && !$input->getOption('unset')) {
  2150. $properties = array('name', 'type', 'description', 'homepage', 'version', 'minimum-stability', 'prefer-stable', 'keywords', 'license', 'extra');
  2151. $rawData = $this->configFile->read();
  2152. $data = $this->config->all();
  2153. if (preg_match('/^repos?(?:itories)?(?:\.(.+))?/', $settingKey, $matches)) {
  2154. if (!isset($matches[1]) || $matches[1] === '') {
  2155. $value = isset($data['repositories']) ? $data['repositories'] : array();
  2156. } else {
  2157. if (!isset($data['repositories'][$matches[1]])) {
  2158. throw new \InvalidArgumentException('There is no '.$matches[1].' repository defined');
  2159. }
  2160. $value = $data['repositories'][$matches[1]];
  2161. }
  2162. } elseif (strpos($settingKey, '.')) {
  2163. $bits = explode('.', $settingKey);
  2164. if ($bits[0] === 'extra') {
  2165. $data = $rawData;
  2166. } else {
  2167. $data = $data['config'];
  2168. }
  2169. $match = false;
  2170. foreach ($bits as $bit) {
  2171. $key = isset($key) ? $key.'.'.$bit : $bit;
  2172. $match = false;
  2173. if (isset($data[$key])) {
  2174. $match = true;
  2175. $data = $data[$key];
  2176. unset($key);
  2177. }
  2178. }
  2179. if (!$match) {
  2180. throw new \RuntimeException($settingKey.' is not defined.');
  2181. }
  2182. $value = $data;
  2183. } elseif (isset($data['config'][$settingKey])) {
  2184. $value = $this->config->get($settingKey, $input->getOption('absolute') ? 0 : Config::RELATIVE_PATHS);
  2185. } elseif (isset($rawData[$settingKey]) && in_array($settingKey, $properties, true)) {
  2186. $value = $rawData[$settingKey];
  2187. } else {
  2188. throw new \RuntimeException($settingKey.' is not defined');
  2189. }
  2190. if (is_array($value)) {
  2191. $value = json_encode($value);
  2192. }
  2193. $this->getIO()->write($value, true, IOInterface::QUIET);
  2194. return 0;
  2195. }
  2196. $values = $input->getArgument('setting-value');
  2197. $booleanValidator = function ($val) {
  2198. return in_array($val, array('true', 'false', '1', '0'), true);
  2199. };
  2200. $booleanNormalizer = function ($val) {
  2201. return $val !== 'false' && (bool) $val;
  2202. };
  2203. $uniqueConfigValues = array(
  2204. 'process-timeout' => array('is_numeric', 'intval'),
  2205. 'use-include-path' => array($booleanValidator, $booleanNormalizer),
  2206. 'use-github-api' => array($booleanValidator, $booleanNormalizer),
  2207. 'preferred-install' => array(
  2208. function ($val) {
  2209. return in_array($val, array('auto', 'source', 'dist'), true);
  2210. },
  2211. function ($val) {
  2212. return $val;
  2213. },
  2214. ),
  2215. 'store-auths' => array(
  2216. function ($val) {
  2217. return in_array($val, array('true', 'false', 'prompt'), true);
  2218. },
  2219. function ($val) {
  2220. if ('prompt' === $val) {
  2221. return 'prompt';
  2222. }
  2223. return $val !== 'false' && (bool) $val;
  2224. },
  2225. ),
  2226. 'notify-on-install' => array($booleanValidator, $booleanNormalizer),
  2227. 'vendor-dir' => array('is_string', function ($val) {
  2228. return $val;
  2229. }),
  2230. 'bin-dir' => array('is_string', function ($val) {
  2231. return $val;
  2232. }),
  2233. 'archive-dir' => array('is_string', function ($val) {
  2234. return $val;
  2235. }),
  2236. 'archive-format' => array('is_string', function ($val) {
  2237. return $val;
  2238. }),
  2239. 'data-dir' => array('is_string', function ($val) {
  2240. return $val;
  2241. }),
  2242. 'cache-dir' => array('is_string', function ($val) {
  2243. return $val;
  2244. }),
  2245. 'cache-files-dir' => array('is_string', function ($val) {
  2246. return $val;
  2247. }),
  2248. 'cache-repo-dir' => array('is_string', function ($val) {
  2249. return $val;
  2250. }),
  2251. 'cache-vcs-dir' => array('is_string', function ($val) {
  2252. return $val;
  2253. }),
  2254. 'cache-ttl' => array('is_numeric', 'intval'),
  2255. 'cache-files-ttl' => array('is_numeric', 'intval'),
  2256. 'cache-files-maxsize' => array(
  2257. function ($val) {
  2258. return preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $val) > 0;
  2259. },
  2260. function ($val) {
  2261. return $val;
  2262. },
  2263. ),
  2264. 'bin-compat' => array(
  2265. function ($val) {
  2266. return in_array($val, array('auto', 'full'));
  2267. },
  2268. function ($val) {
  2269. return $val;
  2270. },
  2271. ),
  2272. 'discard-changes' => array(
  2273. function ($val) {
  2274. return in_array($val, array('stash', 'true', 'false', '1', '0'), true);
  2275. },
  2276. function ($val) {
  2277. if ('stash' === $val) {
  2278. return 'stash';
  2279. }
  2280. return $val !== 'false' && (bool) $val;
  2281. },
  2282. ),
  2283. 'autoloader-suffix' => array('is_string', function ($val) {
  2284. return $val === 'null' ? null : $val;
  2285. }),
  2286. 'sort-packages' => array($booleanValidator, $booleanNormalizer),
  2287. 'optimize-autoloader' => array($booleanValidator, $booleanNormalizer),
  2288. 'classmap-authoritative' => array($booleanValidator, $booleanNormalizer),
  2289. 'apcu-autoloader' => array($booleanValidator, $booleanNormalizer),
  2290. 'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
  2291. 'disable-tls' => array($booleanValidator, $booleanNormalizer),
  2292. 'secure-http' => array($booleanValidator, $booleanNormalizer),
  2293. 'cafile' => array(
  2294. function ($val) {
  2295. return file_exists($val) && is_readable($val);
  2296. },
  2297. function ($val) {
  2298. return $val === 'null' ? null : $val;
  2299. },
  2300. ),
  2301. 'capath' => array(
  2302. function ($val) {
  2303. return is_dir($val) && is_readable($val);
  2304. },
  2305. function ($val) {
  2306. return $val === 'null' ? null : $val;
  2307. },
  2308. ),
  2309. 'github-expose-hostname' => array($booleanValidator, $booleanNormalizer),
  2310. 'htaccess-protect' => array($booleanValidator, $booleanNormalizer),
  2311. 'lock' => array($booleanValidator, $booleanNormalizer),
  2312. 'platform-check' => array(
  2313. function ($val) {
  2314. return in_array($val, array('php-only', 'true', 'false', '1', '0'), true);
  2315. },
  2316. function ($val) {
  2317. if ('php-only' === $val) {
  2318. return 'php-only';
  2319. }
  2320. return $val !== 'false' && (bool) $val;
  2321. },
  2322. ),
  2323. );
  2324. $multiConfigValues = array(
  2325. 'github-protocols' => array(
  2326. function ($vals) {
  2327. if (!is_array($vals)) {
  2328. return 'array expected';
  2329. }
  2330. foreach ($vals as $val) {
  2331. if (!in_array($val, array('git', 'https', 'ssh'))) {
  2332. return 'valid protocols include: git, https, ssh';
  2333. }
  2334. }
  2335. return true;
  2336. },
  2337. function ($vals) {
  2338. return $vals;
  2339. },
  2340. ),
  2341. 'github-domains' => array(
  2342. function ($vals) {
  2343. if (!is_array($vals)) {
  2344. return 'array expected';
  2345. }
  2346. return true;
  2347. },
  2348. function ($vals) {
  2349. return $vals;
  2350. },
  2351. ),
  2352. 'gitlab-domains' => array(
  2353. function ($vals) {
  2354. if (!is_array($vals)) {
  2355. return 'array expected';
  2356. }
  2357. return true;
  2358. },
  2359. function ($vals) {
  2360. return $vals;
  2361. },
  2362. ),
  2363. );
  2364. if ($input->getOption('unset') && (isset($uniqueConfigValues[$settingKey]) || isset($multiConfigValues[$settingKey]))) {
  2365. if ($settingKey === 'disable-tls' && $this->config->get('disable-tls')) {
  2366. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2367. }
  2368. $this->configSource->removeConfigSetting($settingKey);
  2369. return 0;
  2370. }
  2371. if (isset($uniqueConfigValues[$settingKey])) {
  2372. $this->handleSingleValue($settingKey, $uniqueConfigValues[$settingKey], $values, 'addConfigSetting');
  2373. return 0;
  2374. }
  2375. if (isset($multiConfigValues[$settingKey])) {
  2376. $this->handleMultiValue($settingKey, $multiConfigValues[$settingKey], $values, 'addConfigSetting');
  2377. return 0;
  2378. }
  2379. if (preg_match('/^preferred-install\.(.+)/', $settingKey, $matches)) {
  2380. if ($input->getOption('unset')) {
  2381. $this->configSource->removeConfigSetting($settingKey);
  2382. return 0;
  2383. }
  2384. list($validator) = $uniqueConfigValues['preferred-install'];
  2385. if (!$validator($values[0])) {
  2386. throw new \RuntimeException('Invalid value for '.$settingKey.'. Should be one of: auto, source, or dist');
  2387. }
  2388. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2389. return 0;
  2390. }
  2391. $uniqueProps = array(
  2392. 'name' => array('is_string', function ($val) {
  2393. return $val;
  2394. }),
  2395. 'type' => array('is_string', function ($val) {
  2396. return $val;
  2397. }),
  2398. 'description' => array('is_string', function ($val) {
  2399. return $val;
  2400. }),
  2401. 'homepage' => array('is_string', function ($val) {
  2402. return $val;
  2403. }),
  2404. 'version' => array('is_string', function ($val) {
  2405. return $val;
  2406. }),
  2407. 'minimum-stability' => array(
  2408. function ($val) {
  2409. return isset(BasePackage::$stabilities[VersionParser::normalizeStability($val)]);
  2410. },
  2411. function ($val) {
  2412. return VersionParser::normalizeStability($val);
  2413. },
  2414. ),
  2415. 'prefer-stable' => array($booleanValidator, $booleanNormalizer),
  2416. );
  2417. $multiProps = array(
  2418. 'keywords' => array(
  2419. function ($vals) {
  2420. if (!is_array($vals)) {
  2421. return 'array expected';
  2422. }
  2423. return true;
  2424. },
  2425. function ($vals) {
  2426. return $vals;
  2427. },
  2428. ),
  2429. 'license' => array(
  2430. function ($vals) {
  2431. if (!is_array($vals)) {
  2432. return 'array expected';
  2433. }
  2434. return true;
  2435. },
  2436. function ($vals) {
  2437. return $vals;
  2438. },
  2439. ),
  2440. );
  2441. if ($input->getOption('global') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]) || strpos($settingKey, 'extra.') === 0)) {
  2442. 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');
  2443. }
  2444. if ($input->getOption('unset') && (isset($uniqueProps[$settingKey]) || isset($multiProps[$settingKey]))) {
  2445. $this->configSource->removeProperty($settingKey);
  2446. return 0;
  2447. }
  2448. if (isset($uniqueProps[$settingKey])) {
  2449. $this->handleSingleValue($settingKey, $uniqueProps[$settingKey], $values, 'addProperty');
  2450. return 0;
  2451. }
  2452. if (isset($multiProps[$settingKey])) {
  2453. $this->handleMultiValue($settingKey, $multiProps[$settingKey], $values, 'addProperty');
  2454. return 0;
  2455. }
  2456. if (preg_match('/^repos?(?:itories)?\.(.+)/', $settingKey, $matches)) {
  2457. if ($input->getOption('unset')) {
  2458. $this->configSource->removeRepository($matches[1]);
  2459. return 0;
  2460. }
  2461. if (2 === count($values)) {
  2462. $this->configSource->addRepository($matches[1], array(
  2463. 'type' => $values[0],
  2464. 'url' => $values[1],
  2465. ), $input->getOption('append'));
  2466. return 0;
  2467. }
  2468. if (1 === count($values)) {
  2469. $value = strtolower($values[0]);
  2470. if (true === $booleanValidator($value)) {
  2471. if (false === $booleanNormalizer($value)) {
  2472. $this->configSource->addRepository($matches[1], false, $input->getOption('append'));
  2473. return 0;
  2474. }
  2475. } else {
  2476. $value = JsonFile::parseJson($values[0]);
  2477. $this->configSource->addRepository($matches[1], $value, $input->getOption('append'));
  2478. return 0;
  2479. }
  2480. }
  2481. throw new \RuntimeException('You must pass the type and a url. Example: php composer.phar config repositories.foo vcs https://bar.com');
  2482. }
  2483. if (preg_match('/^extra\.(.+)/', $settingKey, $matches)) {
  2484. if ($input->getOption('unset')) {
  2485. $this->configSource->removeProperty($settingKey);
  2486. return 0;
  2487. }
  2488. $value = $values[0];
  2489. if ($input->getOption('json')) {
  2490. $value = JsonFile::parseJson($value);
  2491. if ($input->getOption('merge')) {
  2492. $currentValue = $this->configFile->read();
  2493. $bits = explode('.', $settingKey);
  2494. foreach ($bits as $bit) {
  2495. $currentValue = isset($currentValue[$bit]) ? $currentValue[$bit] : null;
  2496. }
  2497. if (is_array($currentValue)) {
  2498. $value = array_merge($currentValue, $value);
  2499. }
  2500. }
  2501. }
  2502. $this->configSource->addProperty($settingKey, $value);
  2503. return 0;
  2504. }
  2505. if (preg_match('/^suggest\.(.+)/', $settingKey, $matches)) {
  2506. if ($input->getOption('unset')) {
  2507. $this->configSource->removeProperty($settingKey);
  2508. return 0;
  2509. }
  2510. $this->configSource->addProperty($settingKey, implode(' ', $values));
  2511. return 0;
  2512. }
  2513. if (in_array($settingKey, array('suggest', 'extra'), true) && $input->getOption('unset')) {
  2514. $this->configSource->removeProperty($settingKey);
  2515. return 0;
  2516. }
  2517. if (preg_match('/^platform\.(.+)/', $settingKey, $matches)) {
  2518. if ($input->getOption('unset')) {
  2519. $this->configSource->removeConfigSetting($settingKey);
  2520. return 0;
  2521. }
  2522. $this->configSource->addConfigSetting($settingKey, $values[0]);
  2523. return 0;
  2524. }
  2525. if ($settingKey === 'platform' && $input->getOption('unset')) {
  2526. $this->configSource->removeConfigSetting($settingKey);
  2527. return 0;
  2528. }
  2529. if (preg_match('/^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|http-basic|bearer)\.(.+)/', $settingKey, $matches)) {
  2530. if ($input->getOption('unset')) {
  2531. $this->authConfigSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2532. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2533. return 0;
  2534. }
  2535. if ($matches[1] === 'bitbucket-oauth') {
  2536. if (2 !== count($values)) {
  2537. throw new \RuntimeException('Expected two arguments (consumer-key, consumer-secret), got '.count($values));
  2538. }
  2539. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2540. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('consumer-key' => $values[0], 'consumer-secret' => $values[1]));
  2541. } elseif ($matches[1] === 'gitlab-token' && 2 === count($values)) {
  2542. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2543. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'token' => $values[1]));
  2544. } elseif (in_array($matches[1], array('github-oauth', 'gitlab-oauth', 'gitlab-token', 'bearer'), true)) {
  2545. if (1 !== count($values)) {
  2546. throw new \RuntimeException('Too many arguments, expected only one token');
  2547. }
  2548. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2549. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], $values[0]);
  2550. } elseif ($matches[1] === 'http-basic') {
  2551. if (2 !== count($values)) {
  2552. throw new \RuntimeException('Expected two arguments (username, password), got '.count($values));
  2553. }
  2554. $this->configSource->removeConfigSetting($matches[1].'.'.$matches[2]);
  2555. $this->authConfigSource->addConfigSetting($matches[1].'.'.$matches[2], array('username' => $values[0], 'password' => $values[1]));
  2556. }
  2557. return 0;
  2558. }
  2559. if (preg_match('/^scripts\.(.+)/', $settingKey, $matches)) {
  2560. if ($input->getOption('unset')) {
  2561. $this->configSource->removeProperty($settingKey);
  2562. return 0;
  2563. }
  2564. $this->configSource->addProperty($settingKey, count($values) > 1 ? $values : $values[0]);
  2565. return 0;
  2566. }
  2567. throw new \InvalidArgumentException('Setting '.$settingKey.' does not exist or is not supported by this command');
  2568. }
  2569. protected function handleSingleValue($key, array $callbacks, array $values, $method)
  2570. {
  2571. list($validator, $normalizer) = $callbacks;
  2572. if (1 !== count($values)) {
  2573. throw new \RuntimeException('You can only pass one value. Example: php composer.phar config process-timeout 300');
  2574. }
  2575. if (true !== $validation = $validator($values[0])) {
  2576. throw new \RuntimeException(sprintf(
  2577. '"%s" is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2578. $values[0]
  2579. ));
  2580. }
  2581. $normalizedValue = $normalizer($values[0]);
  2582. if ($key === 'disable-tls') {
  2583. if (!$normalizedValue && $this->config->get('disable-tls')) {
  2584. $this->getIO()->writeError('<info>You are now running Composer with SSL/TLS protection enabled.</info>');
  2585. } elseif ($normalizedValue && !$this->config->get('disable-tls')) {
  2586. $this->getIO()->writeError('<warning>You are now running Composer with SSL/TLS protection disabled.</warning>');
  2587. }
  2588. }
  2589. return call_user_func(array($this->configSource, $method), $key, $normalizedValue);
  2590. }
  2591. protected function handleMultiValue($key, array $callbacks, array $values, $method)
  2592. {
  2593. list($validator, $normalizer) = $callbacks;
  2594. if (true !== $validation = $validator($values)) {
  2595. throw new \RuntimeException(sprintf(
  2596. '%s is an invalid value'.($validation ? ' ('.$validation.')' : ''),
  2597. json_encode($values)
  2598. ));
  2599. }
  2600. return call_user_func(array($this->configSource, $method), $key, $normalizer($values));
  2601. }
  2602. protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null)
  2603. {
  2604. $origK = $k;
  2605. $io = $this->getIO();
  2606. foreach ($contents as $key => $value) {
  2607. if ($k === null && !in_array($key, array('config', 'repositories'))) {
  2608. continue;
  2609. }
  2610. $rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null;
  2611. if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) {
  2612. $k .= preg_replace('{^config\.}', '', $key . '.');
  2613. $this->listConfiguration($value, $rawVal, $output, $k);
  2614. $k = $origK;
  2615. continue;
  2616. }
  2617. if (is_array($value)) {
  2618. $value = array_map(function ($val) {
  2619. return is_array($val) ? json_encode($val) : $val;
  2620. }, $value);
  2621. $value = '['.implode(', ', $value).']';
  2622. }
  2623. if (is_bool($value)) {
  2624. $value = var_export($value, true);
  2625. }
  2626. if (is_string($rawVal) && $rawVal != $value) {
  2627. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>', true, IOInterface::QUIET);
  2628. } else {
  2629. $io->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>', true, IOInterface::QUIET);
  2630. }
  2631. }
  2632. }
  2633. }
  2634. <?php
  2635. namespace Composer\Command;
  2636. use Composer\Config;
  2637. use Composer\Factory;
  2638. use Composer\Installer;
  2639. use Composer\Installer\ProjectInstaller;
  2640. use Composer\Installer\SuggestedPackagesReporter;
  2641. use Composer\IO\IOInterface;
  2642. use Composer\Package\BasePackage;
  2643. use Composer\DependencyResolver\Operation\InstallOperation;
  2644. use Composer\Package\Version\VersionSelector;
  2645. use Composer\Package\AliasPackage;
  2646. use Composer\Repository\RepositoryFactory;
  2647. use Composer\Repository\CompositeRepository;
  2648. use Composer\Repository\PlatformRepository;
  2649. use Composer\Repository\InstalledFilesystemRepository;
  2650. use Composer\Repository\RepositorySet;
  2651. use Composer\Script\ScriptEvents;
  2652. use Composer\Util\Silencer;
  2653. use Symfony\Component\Console\Input\InputArgument;
  2654. use Symfony\Component\Console\Input\InputInterface;
  2655. use Symfony\Component\Console\Input\InputOption;
  2656. use Symfony\Component\Console\Output\OutputInterface;
  2657. use Symfony\Component\Finder\Finder;
  2658. use Composer\Json\JsonFile;
  2659. use Composer\Config\JsonConfigSource;
  2660. use Composer\Util\Filesystem;
  2661. use Composer\Util\ProcessExecutor;
  2662. use Composer\Package\Version\VersionParser;
  2663. class CreateProjectCommand extends BaseCommand
  2664. {
  2665. protected $suggestedPackagesReporter;
  2666. protected function configure()
  2667. {
  2668. $this
  2669. ->setName('create-project')
  2670. ->setDescription('Creates new project from a package into given directory.')
  2671. ->setDefinition(array(
  2672. new InputArgument('package', InputArgument::OPTIONAL, 'Package name to be installed'),
  2673. new InputArgument('directory', InputArgument::OPTIONAL, 'Directory where the files should be created'),
  2674. new InputArgument('version', InputArgument::OPTIONAL, 'Version, will default to latest'),
  2675. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum-stability allowed (unless a version is specified).'),
  2676. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  2677. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  2678. 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'),
  2679. new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'DEPRECATED: Use --repository instead.'),
  2680. 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.'),
  2681. new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
  2682. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  2683. new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
  2684. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'),
  2685. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  2686. 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.'),
  2687. new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deleting the vcs folder.'),
  2688. new InputOption('remove-vcs', null, InputOption::VALUE_NONE, 'Whether to force deletion of the vcs folder without prompting.'),
  2689. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Whether to skip installation of the package dependencies.'),
  2690. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  2691. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  2692. new InputOption('ask', null, InputOption::VALUE_NONE, 'Whether to ask for project directory.'),
  2693. ))
  2694. ->setHelp(
  2695. <<<EOT
  2696. The <info>create-project</info> command creates a new project from a given
  2697. package into a new directory. If executed without params and in a directory
  2698. with a composer.json file it installs the packages for the current project.
  2699. You can use this command to bootstrap new projects or setup a clean
  2700. version-controlled installation for developers of your project.
  2701. <info>php composer.phar create-project vendor/project target-directory [version]</info>
  2702. You can also specify the version with the package name using = or : as separator.
  2703. <info>php composer.phar create-project vendor/project:version target-directory</info>
  2704. To install unstable packages, either specify the version you want, or use the
  2705. --stability=dev (where dev can be one of RC, beta, alpha or dev).
  2706. To setup a developer workable version you should create the project using the source
  2707. controlled code by appending the <info>'--prefer-source'</info> flag.
  2708. To install a package from another repository than the default one you
  2709. can pass the <info>'--repository=https://myrepository.org'</info> flag.
  2710. Read more at https://getcomposer.org/doc/03-cli.md#create-project
  2711. EOT
  2712. )
  2713. ;
  2714. }
  2715. protected function execute(InputInterface $input, OutputInterface $output)
  2716. {
  2717. $config = Factory::createConfig();
  2718. $io = $this->getIO();
  2719. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input, true);
  2720. if ($input->getOption('dev')) {
  2721. $io->writeError('<warning>You are using the deprecated option "dev". Dev packages are installed by default now.</warning>');
  2722. }
  2723. if ($input->getOption('no-custom-installers')) {
  2724. $io->writeError('<warning>You are using the deprecated option "no-custom-installers". Use "no-plugins" instead.</warning>');
  2725. $input->setOption('no-plugins', true);
  2726. }
  2727. if ($input->isInteractive() && $input->getOption('ask')) {
  2728. $parts = explode("/", strtolower($input->getArgument('package')), 2);
  2729. $input->setArgument('directory', $io->ask('New project directory [<comment>'.array_pop($parts).'</comment>]: '));
  2730. }
  2731. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  2732. return $this->installProject(
  2733. $io,
  2734. $config,
  2735. $input,
  2736. $input->getArgument('package'),
  2737. $input->getArgument('directory'),
  2738. $input->getArgument('version'),
  2739. $input->getOption('stability'),
  2740. $preferSource,
  2741. $preferDist,
  2742. !$input->getOption('no-dev'),
  2743. $input->getOption('repository') ?: $input->getOption('repository-url'),
  2744. $input->getOption('no-plugins'),
  2745. $input->getOption('no-scripts'),
  2746. $input->getOption('no-progress'),
  2747. $input->getOption('no-install'),
  2748. $ignorePlatformReqs,
  2749. !$input->getOption('no-secure-http'),
  2750. $input->getOption('add-repository')
  2751. );
  2752. }
  2753. 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)
  2754. {
  2755. $oldCwd = getcwd();
  2756. if ($repositories !== null && !is_array($repositories)) {
  2757. $repositories = (array) $repositories;
  2758. }
  2759. $io->loadConfiguration($config);
  2760. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($io);
  2761. if ($packageName !== null) {
  2762. $installedFromVcs = $this->installRootPackage($io, $config, $packageName, $directory, $packageVersion, $stability, $preferSource, $preferDist, $installDevPackages, $repositories, $disablePlugins, $noScripts, $noProgress, $ignorePlatformReqs, $secureHttp);
  2763. } else {
  2764. $installedFromVcs = false;
  2765. }
  2766. if ($repositories !== null && $addRepository && is_file('composer.lock')) {
  2767. unlink('composer.lock');
  2768. }
  2769. $composer = Factory::create($io, null, $disablePlugins);
  2770. if ($repositories !== null && $addRepository) {
  2771. foreach ($repositories as $index => $repo) {
  2772. $repoConfig = RepositoryFactory::configFromString($io, $composer->getConfig(), $repo, true);
  2773. $composerJsonRepositoriesConfig = $composer->getConfig()->getRepositories();
  2774. $name = RepositoryFactory::generateRepositoryName($index, $repoConfig, $composerJsonRepositoriesConfig);
  2775. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  2776. if (
  2777. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  2778. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  2779. ) {
  2780. $configSource->addRepository('packagist.org', false);
  2781. } else {
  2782. $configSource->addRepository($name, $repoConfig, false);
  2783. }
  2784. $composer = Factory::create($io, null, $disablePlugins);
  2785. }
  2786. }
  2787. $process = new ProcessExecutor($io);
  2788. $fs = new Filesystem($process);
  2789. if ($noScripts === false) {
  2790. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_ROOT_PACKAGE_INSTALL, $installDevPackages);
  2791. }
  2792. $config = $composer->getConfig();
  2793. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  2794. if ($noInstall === false) {
  2795. $composer->getInstallationManager()->setOutputProgress(!$noProgress);
  2796. $installer = Installer::create($io, $composer);
  2797. $installer->setPreferSource($preferSource)
  2798. ->setPreferDist($preferDist)
  2799. ->setDevMode($installDevPackages)
  2800. ->setRunScripts(!$noScripts)
  2801. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  2802. ->setSuggestedPackagesReporter($this->suggestedPackagesReporter)
  2803. ->setOptimizeAutoloader($config->get('optimize-autoloader'))
  2804. ->setClassMapAuthoritative($config->get('classmap-authoritative'))
  2805. ->setApcuAutoloader($config->get('apcu-autoloader'));
  2806. if (!$composer->getLocker()->isLocked()) {
  2807. $installer->setUpdate(true);
  2808. }
  2809. if ($disablePlugins) {
  2810. $installer->disablePlugins();
  2811. }
  2812. $status = $installer->run();
  2813. if (0 !== $status) {
  2814. return $status;
  2815. }
  2816. }
  2817. $hasVcs = $installedFromVcs;
  2818. if (
  2819. !$input->getOption('keep-vcs')
  2820. && $installedFromVcs
  2821. && (
  2822. $input->getOption('remove-vcs')
  2823. || !$io->isInteractive()
  2824. || $io->askConfirmation('<info>Do you want to remove the existing VCS (.git, .svn..) history?</info> [<comment>Y,n</comment>]? ')
  2825. )
  2826. ) {
  2827. $finder = new Finder();
  2828. $finder->depth(0)->directories()->in(getcwd())->ignoreVCS(false)->ignoreDotFiles(false);
  2829. foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg', '.fslckout', '_FOSSIL_') as $vcsName) {
  2830. $finder->name($vcsName);
  2831. }
  2832. try {
  2833. $dirs = iterator_to_array($finder);
  2834. unset($finder);
  2835. foreach ($dirs as $dir) {
  2836. if (!$fs->removeDirectory($dir)) {
  2837. throw new \RuntimeException('Could not remove '.$dir);
  2838. }
  2839. }
  2840. } catch (\Exception $e) {
  2841. $io->writeError('<error>An error occurred while removing the VCS metadata: '.$e->getMessage().'</error>');
  2842. }
  2843. $hasVcs = false;
  2844. }
  2845. if (!$hasVcs) {
  2846. $package = $composer->getPackage();
  2847. $configSource = new JsonConfigSource(new JsonFile('composer.json'));
  2848. foreach (BasePackage::$supportedLinkTypes as $type => $meta) {
  2849. foreach ($package->{'get'.$meta['method']}() as $link) {
  2850. if ($link->getPrettyConstraint() === 'self.version') {
  2851. $configSource->addLink($type, $link->getTarget(), $package->getPrettyVersion());
  2852. }
  2853. }
  2854. }
  2855. }
  2856. if ($noScripts === false) {
  2857. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_CREATE_PROJECT_CMD, $installDevPackages);
  2858. }
  2859. chdir($oldCwd);
  2860. $vendorComposerDir = $config->get('vendor-dir').'/composer';
  2861. if (is_dir($vendorComposerDir) && $fs->isDirEmpty($vendorComposerDir)) {
  2862. Silencer::call('rmdir', $vendorComposerDir);
  2863. $vendorDir = $config->get('vendor-dir');
  2864. if (is_dir($vendorDir) && $fs->isDirEmpty($vendorDir)) {
  2865. Silencer::call('rmdir', $vendorDir);
  2866. }
  2867. }
  2868. return 0;
  2869. }
  2870. 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)
  2871. {
  2872. if (!$secureHttp) {
  2873. $config->merge(array('config' => array('secure-http' => false)));
  2874. }
  2875. $parser = new VersionParser();
  2876. $requirements = $parser->parseNameVersionPairs(array($packageName));
  2877. $name = strtolower($requirements[0]['name']);
  2878. if (!$packageVersion && isset($requirements[0]['version'])) {
  2879. $packageVersion = $requirements[0]['version'];
  2880. }
  2881. if (null === $directory) {
  2882. $parts = explode("/", $name, 2);
  2883. $directory = getcwd() . DIRECTORY_SEPARATOR . array_pop($parts);
  2884. }
  2885. $process = new ProcessExecutor($io);
  2886. $fs = new Filesystem($process);
  2887. if (!$fs->isAbsolutePath($directory)) {
  2888. $directory = getcwd() . DIRECTORY_SEPARATOR . $directory;
  2889. }
  2890. $io->writeError('<info>Creating a "' . $packageName . '" project at "' . $fs->findShortestPath(getcwd(), $directory, true) . '"</info>');
  2891. if (file_exists($directory)) {
  2892. if (!is_dir($directory)) {
  2893. throw new \InvalidArgumentException('Cannot create project directory at "'.$directory.'", it exists as a file.');
  2894. }
  2895. if (!$fs->isDirEmpty($directory)) {
  2896. throw new \InvalidArgumentException('Project directory "'.$directory.'" is not empty.');
  2897. }
  2898. }
  2899. if (null === $stability) {
  2900. if (preg_match('{^[^,\s]*?@('.implode('|', array_keys(BasePackage::$stabilities)).')$}i', $packageVersion, $match)) {
  2901. $stability = $match[1];
  2902. } else {
  2903. $stability = VersionParser::parseStability($packageVersion);
  2904. }
  2905. }
  2906. $stability = VersionParser::normalizeStability($stability);
  2907. if (!isset(BasePackage::$stabilities[$stability])) {
  2908. throw new \InvalidArgumentException('Invalid stability provided ('.$stability.'), must be one of: '.implode(', ', array_keys(BasePackage::$stabilities)));
  2909. }
  2910. $composer = Factory::create($io, $config->all(), $disablePlugins);
  2911. $config = $composer->getConfig();
  2912. $rm = $composer->getRepositoryManager();
  2913. $repositorySet = new RepositorySet($stability);
  2914. if (null === $repositories) {
  2915. $repositorySet->addRepository(new CompositeRepository(RepositoryFactory::defaultRepos($io, $config, $rm)));
  2916. } else {
  2917. foreach ($repositories as $repo) {
  2918. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  2919. if (
  2920. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  2921. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  2922. ) {
  2923. continue;
  2924. }
  2925. $repositorySet->addRepository(RepositoryFactory::createRepo($io, $config, $repoConfig, $rm));
  2926. }
  2927. }
  2928. $platformOverrides = $config->get('platform') ?: array();
  2929. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  2930. $versionSelector = new VersionSelector($repositorySet, $platformRepo);
  2931. $package = $versionSelector->findBestCandidate($name, $packageVersion, $stability, $ignorePlatformReqs);
  2932. if (!$package) {
  2933. $errorMessage = "Could not find package $name with " . ($packageVersion ? "version $packageVersion" : "stability $stability");
  2934. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, $packageVersion, $stability, true)) {
  2935. throw new \InvalidArgumentException($errorMessage .' in a version installable using your PHP version, PHP extensions and Composer version.');
  2936. }
  2937. throw new \InvalidArgumentException($errorMessage .'.');
  2938. }
  2939. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  2940. @mkdir($directory, 0777, true);
  2941. if ($realDir = realpath($directory)) {
  2942. pcntl_async_signals(true);
  2943. pcntl_signal(SIGINT, function () use ($realDir) {
  2944. $fs = new Filesystem();
  2945. $fs->removeDirectory($realDir);
  2946. exit(130);
  2947. });
  2948. }
  2949. }
  2950. if (function_exists('sapi_windows_set_ctrl_handler')) {
  2951. @mkdir($directory, 0777, true);
  2952. if ($realDir = realpath($directory)) {
  2953. sapi_windows_set_ctrl_handler(function () use ($realDir) {
  2954. $fs = new Filesystem();
  2955. $fs->removeDirectory($realDir);
  2956. exit(130);
  2957. });
  2958. }
  2959. }
  2960. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  2961. $package = $package->getAliasOf();
  2962. }
  2963. $io->writeError('<info>Installing ' . $package->getName() . ' (' . $package->getFullPrettyVersion(false) . ')</info>');
  2964. if ($disablePlugins) {
  2965. $io->writeError('<info>Plugins have been disabled.</info>');
  2966. }
  2967. if ($package instanceof AliasPackage) {
  2968. $package = $package->getAliasOf();
  2969. }
  2970. $dm = $composer->getDownloadManager();
  2971. $dm->setPreferSource($preferSource)
  2972. ->setPreferDist($preferDist);
  2973. $projectInstaller = new ProjectInstaller($directory, $dm, $fs);
  2974. $im = $composer->getInstallationManager();
  2975. $im->setOutputProgress(!$noProgress);
  2976. $im->addInstaller($projectInstaller);
  2977. $im->execute(new InstalledFilesystemRepository(new JsonFile('php://memory')), array(new InstallOperation($package)));
  2978. $im->notifyInstalls($io);
  2979. $this->suggestedPackagesReporter->addSuggestionsFromPackage($package);
  2980. $installedFromVcs = 'source' === $package->getInstallationSource();
  2981. $io->writeError('<info>Created project in ' . $directory . '</info>');
  2982. chdir($directory);
  2983. $_SERVER['COMPOSER_ROOT_VERSION'] = $package->getPrettyVersion();
  2984. putenv('COMPOSER_ROOT_VERSION='.$_SERVER['COMPOSER_ROOT_VERSION']);
  2985. return $installedFromVcs;
  2986. }
  2987. }
  2988. <?php
  2989. namespace Composer\Command;
  2990. use Symfony\Component\Console\Input\InputInterface;
  2991. use Symfony\Component\Console\Output\OutputInterface;
  2992. class DependsCommand extends BaseDependencyCommand
  2993. {
  2994. protected function configure()
  2995. {
  2996. parent::configure();
  2997. $this
  2998. ->setName('depends')
  2999. ->setAliases(array('why'))
  3000. ->setDescription('Shows which packages cause the given package to be installed.')
  3001. ->setHelp(
  3002. <<<EOT
  3003. Displays detailed information about where a package is referenced.
  3004. <info>php composer.phar depends composer/composer</info>
  3005. Read more at https://getcomposer.org/doc/03-cli.md#depends-why-
  3006. EOT
  3007. )
  3008. ;
  3009. }
  3010. protected function execute(InputInterface $input, OutputInterface $output)
  3011. {
  3012. return parent::doExecute($input, $output);
  3013. }
  3014. }
  3015. <?php
  3016. namespace Composer\Command;
  3017. use Composer\Composer;
  3018. use Composer\Factory;
  3019. use Composer\Config;
  3020. use Composer\Downloader\TransportException;
  3021. use Composer\Repository\PlatformRepository;
  3022. use Composer\Plugin\CommandEvent;
  3023. use Composer\Plugin\PluginEvents;
  3024. use Composer\Util\ConfigValidator;
  3025. use Composer\Util\IniHelper;
  3026. use Composer\Util\ProcessExecutor;
  3027. use Composer\Util\HttpDownloader;
  3028. use Composer\Util\StreamContextFactory;
  3029. use Composer\SelfUpdate\Keys;
  3030. use Composer\SelfUpdate\Versions;
  3031. use Composer\IO\NullIO;
  3032. use Symfony\Component\Console\Input\InputInterface;
  3033. use Symfony\Component\Console\Output\OutputInterface;
  3034. use Symfony\Component\Process\ExecutableFinder;
  3035. class DiagnoseCommand extends BaseCommand
  3036. {
  3037. protected $httpDownloader;
  3038. protected $process;
  3039. protected $exitCode = 0;
  3040. protected function configure()
  3041. {
  3042. $this
  3043. ->setName('diagnose')
  3044. ->setDescription('Diagnoses the system to identify common errors.')
  3045. ->setHelp(
  3046. <<<EOT
  3047. The <info>diagnose</info> command checks common errors to help debugging problems.
  3048. The process exit code will be 1 in case of warnings and 2 for errors.
  3049. Read more at https://getcomposer.org/doc/03-cli.md#diagnose
  3050. EOT
  3051. )
  3052. ;
  3053. }
  3054. protected function execute(InputInterface $input, OutputInterface $output)
  3055. {
  3056. $composer = $this->getComposer(false);
  3057. $io = $this->getIO();
  3058. if ($composer) {
  3059. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
  3060. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3061. $io->write('Checking composer.json: ', false);
  3062. $this->outputResult($this->checkComposerSchema());
  3063. }
  3064. if ($composer) {
  3065. $config = $composer->getConfig();
  3066. } else {
  3067. $config = Factory::createConfig();
  3068. }
  3069. $config->merge(array('config' => array('secure-http' => false)));
  3070. $config->prohibitUrlByConfig('http://repo.packagist.org', new NullIO);
  3071. $this->httpDownloader = Factory::createHttpDownloader($io, $config);
  3072. $this->process = new ProcessExecutor($io);
  3073. $io->write('Checking platform settings: ', false);
  3074. $this->outputResult($this->checkPlatform());
  3075. $io->write('Checking git settings: ', false);
  3076. $this->outputResult($this->checkGit());
  3077. $io->write('Checking http connectivity to packagist: ', false);
  3078. $this->outputResult($this->checkHttp('http', $config));
  3079. $io->write('Checking https connectivity to packagist: ', false);
  3080. $this->outputResult($this->checkHttp('https', $config));
  3081. $opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
  3082. if (!empty($opts['http']['proxy'])) {
  3083. $io->write('Checking HTTP proxy: ', false);
  3084. $this->outputResult($this->checkHttpProxy());
  3085. }
  3086. if ($oauth = $config->get('github-oauth')) {
  3087. foreach ($oauth as $domain => $token) {
  3088. $io->write('Checking '.$domain.' oauth access: ', false);
  3089. $this->outputResult($this->checkGithubOauth($domain, $token));
  3090. }
  3091. } else {
  3092. $io->write('Checking github.com rate limit: ', false);
  3093. try {
  3094. $rate = $this->getGithubRateLimit('github.com');
  3095. if (!is_array($rate)) {
  3096. $this->outputResult($rate);
  3097. } elseif (10 > $rate['remaining']) {
  3098. $io->write('<warning>WARNING</warning>');
  3099. $io->write(sprintf(
  3100. '<comment>Github has a rate limit on their API. '
  3101. . 'You currently have <options=bold>%u</options=bold> '
  3102. . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
  3103. . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL
  3104. . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>',
  3105. $rate['remaining'],
  3106. $rate['limit']
  3107. ));
  3108. } else {
  3109. $this->outputResult(true);
  3110. }
  3111. } catch (\Exception $e) {
  3112. if ($e instanceof TransportException && $e->getCode() === 401) {
  3113. $this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
  3114. } else {
  3115. $this->outputResult($e);
  3116. }
  3117. }
  3118. }
  3119. $io->write('Checking disk free space: ', false);
  3120. $this->outputResult($this->checkDiskSpace($config));
  3121. if (strpos(__FILE__, 'phar:') === 0) {
  3122. $io->write('Checking pubkeys: ', false);
  3123. $this->outputResult($this->checkPubKeys($config));
  3124. $io->write('Checking composer version: ', false);
  3125. $this->outputResult($this->checkVersion($config));
  3126. }
  3127. $io->write(sprintf('Composer version: <comment>%s</comment>', Composer::getVersion()));
  3128. $platformOverrides = $config->get('platform') ?: array();
  3129. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  3130. $phpPkg = $platformRepo->findPackage('php', '*');
  3131. $phpVersion = $phpPkg->getPrettyVersion();
  3132. if (false !== strpos($phpPkg->getDescription(), 'overridden')) {
  3133. $phpVersion .= ' - ' . $phpPkg->getDescription();
  3134. }
  3135. $io->write(sprintf('PHP version: <comment>%s</comment>', $phpVersion));
  3136. if (defined('PHP_BINARY')) {
  3137. $io->write(sprintf('PHP binary path: <comment>%s</comment>', PHP_BINARY));
  3138. }
  3139. $io->write('OpenSSL version: ' . (defined('OPENSSL_VERSION_TEXT') ? '<comment>'.OPENSSL_VERSION_TEXT.'</comment>' : '<error>missing</error>'));
  3140. $io->write('cURL version: ' . $this->getCurlVersion());
  3141. $finder = new ExecutableFinder;
  3142. $hasSystemUnzip = (bool) $finder->find('unzip');
  3143. $io->write(
  3144. 'zip: ' . (extension_loaded('zip') ? '<comment>extension present</comment>' : '<comment>extension not loaded</comment>')
  3145. . ', ' . ($hasSystemUnzip ? '<comment>unzip present</comment>' : '<comment>unzip not available</comment>')
  3146. );
  3147. return $this->exitCode;
  3148. }
  3149. private function checkComposerSchema()
  3150. {
  3151. $validator = new ConfigValidator($this->getIO());
  3152. list($errors, , $warnings) = $validator->validate(Factory::getComposerFile());
  3153. if ($errors || $warnings) {
  3154. $messages = array(
  3155. 'error' => $errors,
  3156. 'warning' => $warnings,
  3157. );
  3158. $output = '';
  3159. foreach ($messages as $style => $msgs) {
  3160. foreach ($msgs as $msg) {
  3161. $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
  3162. }
  3163. }
  3164. return rtrim($output);
  3165. }
  3166. return true;
  3167. }
  3168. private function checkGit()
  3169. {
  3170. $this->process->execute('git config color.ui', $output);
  3171. if (strtolower(trim($output)) === 'always') {
  3172. 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>';
  3173. }
  3174. return true;
  3175. }
  3176. private function checkHttp($proto, Config $config)
  3177. {
  3178. $result = $this->checkConnectivity();
  3179. if ($result !== true) {
  3180. return $result;
  3181. }
  3182. $result = array();
  3183. if ($proto === 'https' && $config->get('disable-tls') === true) {
  3184. $tlsWarning = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  3185. }
  3186. try {
  3187. $this->httpDownloader->get($proto . '://repo.packagist.org/packages.json');
  3188. } catch (TransportException $e) {
  3189. if ($hints = HttpDownloader::getExceptionHints($e)) {
  3190. foreach ($hints as $hint) {
  3191. $result[] = $hint;
  3192. }
  3193. }
  3194. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  3195. }
  3196. if (isset($tlsWarning)) {
  3197. $result[] = $tlsWarning;
  3198. }
  3199. if (count($result) > 0) {
  3200. return $result;
  3201. }
  3202. return true;
  3203. }
  3204. private function checkHttpProxy()
  3205. {
  3206. $result = $this->checkConnectivity();
  3207. if ($result !== true) {
  3208. return $result;
  3209. }
  3210. $protocol = extension_loaded('openssl') ? 'https' : 'http';
  3211. try {
  3212. $json = $this->httpDownloader->get($protocol . '://repo.packagist.org/packages.json')->decodeJson();
  3213. $hash = reset($json['provider-includes']);
  3214. $hash = $hash['sha256'];
  3215. $path = str_replace('%hash%', $hash, key($json['provider-includes']));
  3216. $provider = $this->httpDownloader->get($protocol . '://repo.packagist.org/'.$path)->getBody();
  3217. if (hash('sha256', $provider) !== $hash) {
  3218. return 'It seems that your proxy is modifying http traffic on the fly';
  3219. }
  3220. } catch (\Exception $e) {
  3221. return $e;
  3222. }
  3223. return true;
  3224. }
  3225. private function checkGithubOauth($domain, $token)
  3226. {
  3227. $result = $this->checkConnectivity();
  3228. if ($result !== true) {
  3229. return $result;
  3230. }
  3231. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3232. try {
  3233. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/' : 'https://'.$domain.'/api/v3/';
  3234. return $this->httpDownloader->get($url, array(
  3235. 'retry-auth-failure' => false,
  3236. )) ? true : 'Unexpected error';
  3237. } catch (\Exception $e) {
  3238. if ($e instanceof TransportException && $e->getCode() === 401) {
  3239. return '<comment>The oauth token for '.$domain.' seems invalid, run "composer config --global --unset github-oauth.'.$domain.'" to remove it</comment>';
  3240. }
  3241. return $e;
  3242. }
  3243. }
  3244. private function getGithubRateLimit($domain, $token = null)
  3245. {
  3246. $result = $this->checkConnectivity();
  3247. if ($result !== true) {
  3248. return $result;
  3249. }
  3250. if ($token) {
  3251. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  3252. }
  3253. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/rate_limit' : 'https://'.$domain.'/api/rate_limit';
  3254. $data = $this->httpDownloader->get($url, array('retry-auth-failure' => false))->decodeJson();
  3255. return $data['resources']['core'];
  3256. }
  3257. private function checkDiskSpace($config)
  3258. {
  3259. $minSpaceFree = 1024 * 1024;
  3260. if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  3261. || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  3262. ) {
  3263. return '<error>The disk hosting '.$dir.' is full</error>';
  3264. }
  3265. return true;
  3266. }
  3267. private function checkPubKeys($config)
  3268. {
  3269. $home = $config->get('home');
  3270. $errors = array();
  3271. $io = $this->getIO();
  3272. if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
  3273. $io->write('');
  3274. }
  3275. if (file_exists($home.'/keys.tags.pub')) {
  3276. $io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
  3277. } else {
  3278. $errors[] = '<error>Missing pubkey for tags verification</error>';
  3279. }
  3280. if (file_exists($home.'/keys.dev.pub')) {
  3281. $io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
  3282. } else {
  3283. $errors[] = '<error>Missing pubkey for dev verification</error>';
  3284. }
  3285. if ($errors) {
  3286. $errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
  3287. }
  3288. return $errors ?: true;
  3289. }
  3290. private function checkVersion($config)
  3291. {
  3292. $result = $this->checkConnectivity();
  3293. if ($result !== true) {
  3294. return $result;
  3295. }
  3296. $versionsUtil = new Versions($config, $this->httpDownloader);
  3297. try {
  3298. $latest = $versionsUtil->getLatest();
  3299. } catch (\Exception $e) {
  3300. return $e;
  3301. }
  3302. if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
  3303. return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';
  3304. }
  3305. return true;
  3306. }
  3307. private function getCurlVersion()
  3308. {
  3309. if (extension_loaded('curl')) {
  3310. if (!HttpDownloader::isCurlEnabled()) {
  3311. return '<error>disabled via disable_functions, using php streams fallback, which reduces performance</error>';
  3312. }
  3313. $version = curl_version();
  3314. return '<comment>'.$version['version'].'</comment> '.
  3315. 'libz <comment>'.(isset($version['libz_version']) ? $version['libz_version'] : 'missing').'</comment> '.
  3316. 'ssl <comment>'.(isset($version['ssl_version']) ? $version['ssl_version'] : 'missing').'</comment>';
  3317. }
  3318. return '<error>missing, using php streams fallback, which reduces performance</error>';
  3319. }
  3320. private function outputResult($result)
  3321. {
  3322. $io = $this->getIO();
  3323. if (true === $result) {
  3324. $io->write('<info>OK</info>');
  3325. return;
  3326. }
  3327. $hadError = false;
  3328. $hadWarning = false;
  3329. if ($result instanceof \Exception) {
  3330. $result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
  3331. }
  3332. if (!$result) {
  3333. $hadError = true;
  3334. } else {
  3335. if (!is_array($result)) {
  3336. $result = array($result);
  3337. }
  3338. foreach ($result as $message) {
  3339. if (false !== strpos($message, '<error>')) {
  3340. $hadError = true;
  3341. } elseif (false !== strpos($message, '<warning>')) {
  3342. $hadWarning = true;
  3343. }
  3344. }
  3345. }
  3346. if ($hadError) {
  3347. $io->write('<error>FAIL</error>');
  3348. $this->exitCode = max($this->exitCode, 2);
  3349. } elseif ($hadWarning) {
  3350. $io->write('<warning>WARNING</warning>');
  3351. $this->exitCode = max($this->exitCode, 1);
  3352. }
  3353. if ($result) {
  3354. foreach ($result as $message) {
  3355. $io->write($message);
  3356. }
  3357. }
  3358. }
  3359. private function checkPlatform()
  3360. {
  3361. $output = '';
  3362. $out = function ($msg, $style) use (&$output) {
  3363. $output .= '<'.$style.'>'.$msg.'</'.$style.'>'.PHP_EOL;
  3364. };
  3365. $errors = array();
  3366. $warnings = array();
  3367. $displayIniMessage = false;
  3368. $iniMessage = PHP_EOL.PHP_EOL.IniHelper::getMessage();
  3369. $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.';
  3370. if (!function_exists('json_decode')) {
  3371. $errors['json'] = true;
  3372. }
  3373. if (!extension_loaded('Phar')) {
  3374. $errors['phar'] = true;
  3375. }
  3376. if (!extension_loaded('filter')) {
  3377. $errors['filter'] = true;
  3378. }
  3379. if (!extension_loaded('hash')) {
  3380. $errors['hash'] = true;
  3381. }
  3382. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  3383. $errors['iconv_mbstring'] = true;
  3384. }
  3385. if (!filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  3386. $errors['allow_url_fopen'] = true;
  3387. }
  3388. if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) {
  3389. $errors['ioncube'] = ioncube_loader_version();
  3390. }
  3391. if (PHP_VERSION_ID < 50302) {
  3392. $errors['php'] = PHP_VERSION;
  3393. }
  3394. if (!isset($errors['php']) && PHP_VERSION_ID < 50304) {
  3395. $warnings['php'] = PHP_VERSION;
  3396. }
  3397. if (!extension_loaded('openssl')) {
  3398. $errors['openssl'] = true;
  3399. }
  3400. if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
  3401. $warnings['openssl_version'] = true;
  3402. }
  3403. if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && filter_var(ini_get('apc.enable_cli'), FILTER_VALIDATE_BOOLEAN)) {
  3404. $warnings['apc_cli'] = true;
  3405. }
  3406. if (!extension_loaded('zlib')) {
  3407. $warnings['zlib'] = true;
  3408. }
  3409. ob_start();
  3410. phpinfo(INFO_GENERAL);
  3411. $phpinfo = ob_get_clean();
  3412. if (preg_match('{Configure Command(?: *</td><td class="v">| *=> *)(.*?)(?:</td>|$)}m', $phpinfo, $match)) {
  3413. $configure = $match[1];
  3414. if (false !== strpos($configure, '--enable-sigchild')) {
  3415. $warnings['sigchild'] = true;
  3416. }
  3417. if (false !== strpos($configure, '--with-curlwrappers')) {
  3418. $warnings['curlwrappers'] = true;
  3419. }
  3420. }
  3421. if (filter_var(ini_get('xdebug.profiler_enabled'), FILTER_VALIDATE_BOOLEAN)) {
  3422. $warnings['xdebug_profile'] = true;
  3423. } elseif (extension_loaded('xdebug')) {
  3424. $warnings['xdebug_loaded'] = true;
  3425. }
  3426. if (defined('PHP_WINDOWS_VERSION_BUILD')
  3427. && (version_compare(PHP_VERSION, '7.2.23', '<')
  3428. || (version_compare(PHP_VERSION, '7.3.0', '>=')
  3429. && version_compare(PHP_VERSION, '7.3.10', '<')))) {
  3430. $warnings['onedrive'] = PHP_VERSION;
  3431. }
  3432. if (!empty($errors)) {
  3433. foreach ($errors as $error => $current) {
  3434. switch ($error) {
  3435. case 'json':
  3436. $text = PHP_EOL."The json extension is missing.".PHP_EOL;
  3437. $text .= "Install it or recompile php without --disable-json";
  3438. break;
  3439. case 'phar':
  3440. $text = PHP_EOL."The phar extension is missing.".PHP_EOL;
  3441. $text .= "Install it or recompile php without --disable-phar";
  3442. break;
  3443. case 'filter':
  3444. $text = PHP_EOL."The filter extension is missing.".PHP_EOL;
  3445. $text .= "Install it or recompile php without --disable-filter";
  3446. break;
  3447. case 'hash':
  3448. $text = PHP_EOL."The hash extension is missing.".PHP_EOL;
  3449. $text .= "Install it or recompile php without --disable-hash";
  3450. break;
  3451. case 'iconv_mbstring':
  3452. $text = PHP_EOL."The iconv OR mbstring extension is required and both are missing.".PHP_EOL;
  3453. $text .= "Install either of them or recompile php without --disable-iconv";
  3454. break;
  3455. case 'php':
  3456. $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 5.3.2 or higher.";
  3457. break;
  3458. case 'allow_url_fopen':
  3459. $text = PHP_EOL."The allow_url_fopen setting is incorrect.".PHP_EOL;
  3460. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3461. $text .= " allow_url_fopen = On";
  3462. $displayIniMessage = true;
  3463. break;
  3464. case 'ioncube':
  3465. $text = PHP_EOL."Your ionCube Loader extension ($current) is incompatible with Phar files.".PHP_EOL;
  3466. $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;
  3467. $text .= " zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so";
  3468. $displayIniMessage = true;
  3469. break;
  3470. case 'openssl':
  3471. $text = PHP_EOL."The openssl extension is missing, which means that secure HTTPS transfers are impossible.".PHP_EOL;
  3472. $text .= "If possible you should enable it or recompile php with --with-openssl";
  3473. break;
  3474. default:
  3475. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown error type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $error));
  3476. }
  3477. $out($text, 'error');
  3478. }
  3479. $output .= PHP_EOL;
  3480. }
  3481. if (!empty($warnings)) {
  3482. foreach ($warnings as $warning => $current) {
  3483. switch ($warning) {
  3484. case 'apc_cli':
  3485. $text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
  3486. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  3487. $text .= " apc.enable_cli = Off";
  3488. $displayIniMessage = true;
  3489. break;
  3490. case 'zlib':
  3491. $text = 'The zlib extension is not loaded, this can slow down Composer a lot.'.PHP_EOL;
  3492. $text .= 'If possible, enable it or recompile php with --with-zlib'.PHP_EOL;
  3493. $displayIniMessage = true;
  3494. break;
  3495. case 'sigchild':
  3496. $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
  3497. $text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
  3498. $text .= " https://bugs.php.net/bug.php?id=22999";
  3499. break;
  3500. case 'curlwrappers':
  3501. $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
  3502. $text .= " Recompile it without this flag if possible";
  3503. break;
  3504. case 'php':
  3505. $text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL;
  3506. $text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
  3507. break;
  3508. case 'openssl_version':
  3509. $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
  3510. $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
  3511. $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
  3512. $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
  3513. break;
  3514. case 'xdebug_loaded':
  3515. $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
  3516. $text .= " Disabling it when using Composer is recommended.";
  3517. break;
  3518. case 'xdebug_profile':
  3519. $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
  3520. $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
  3521. $text .= " xdebug.profiler_enabled = 0";
  3522. $displayIniMessage = true;
  3523. break;
  3524. case 'onedrive':
  3525. $text = "The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.".PHP_EOL;
  3526. $text .= "Upgrade your PHP ({$current}) to use this location with Composer.".PHP_EOL;
  3527. break;
  3528. default:
  3529. throw new \InvalidArgumentException(sprintf("DiagnoseCommand: Unknown warning type \"%s\". Please report at https://github.com/composer/composer/issues/new.", $warning));
  3530. }
  3531. $out($text, 'comment');
  3532. }
  3533. }
  3534. if ($displayIniMessage) {
  3535. $out($iniMessage, 'comment');
  3536. }
  3537. return !$warnings && !$errors ? true : $output;
  3538. }
  3539. private function checkConnectivity()
  3540. {
  3541. if (!ini_get('allow_url_fopen')) {
  3542. return '<info>Skipped because allow_url_fopen is missing.</info>';
  3543. }
  3544. return true;
  3545. }
  3546. }
  3547. <?php
  3548. namespace Composer\Command;
  3549. use Composer\Plugin\CommandEvent;
  3550. use Composer\Plugin\PluginEvents;
  3551. use Symfony\Component\Console\Input\InputInterface;
  3552. use Symfony\Component\Console\Input\InputOption;
  3553. use Symfony\Component\Console\Output\OutputInterface;
  3554. class DumpAutoloadCommand extends BaseCommand
  3555. {
  3556. protected function configure()
  3557. {
  3558. $this
  3559. ->setName('dump-autoload')
  3560. ->setAliases(array('dumpautoload'))
  3561. ->setDescription('Dumps the autoloader.')
  3562. ->setDefinition(array(
  3563. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  3564. new InputOption('optimize', 'o', InputOption::VALUE_NONE, 'Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.'),
  3565. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize`.'),
  3566. new InputOption('apcu', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  3567. new InputOption('apcu-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu'),
  3568. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables autoload-dev rules.'),
  3569. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  3570. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  3571. ))
  3572. ->setHelp(
  3573. <<<EOT
  3574. <info>php composer.phar dump-autoload</info>
  3575. Read more at https://getcomposer.org/doc/03-cli.md#dump-autoload-dumpautoload-
  3576. EOT
  3577. )
  3578. ;
  3579. }
  3580. protected function execute(InputInterface $input, OutputInterface $output)
  3581. {
  3582. $composer = $this->getComposer();
  3583. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
  3584. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  3585. $installationManager = $composer->getInstallationManager();
  3586. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  3587. $package = $composer->getPackage();
  3588. $config = $composer->getConfig();
  3589. $optimize = $input->getOption('optimize') || $config->get('optimize-autoloader');
  3590. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  3591. $apcuPrefix = $input->getOption('apcu-prefix');
  3592. $apcu = $apcuPrefix !== null || $input->getOption('apcu') || $config->get('apcu-autoloader');
  3593. if ($authoritative) {
  3594. $this->getIO()->write('<info>Generating optimized autoload files (authoritative)</info>');
  3595. } elseif ($optimize) {
  3596. $this->getIO()->write('<info>Generating optimized autoload files</info>');
  3597. } else {
  3598. $this->getIO()->write('<info>Generating autoload files</info>');
  3599. }
  3600. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  3601. $generator = $composer->getAutoloadGenerator();
  3602. $generator->setDevMode(!$input->getOption('no-dev'));
  3603. $generator->setClassMapAuthoritative($authoritative);
  3604. $generator->setApcu($apcu, $apcuPrefix);
  3605. $generator->setRunScripts(!$input->getOption('no-scripts'));
  3606. $generator->setIgnorePlatformRequirements($ignorePlatformReqs);
  3607. $numberOfClasses = $generator->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
  3608. if ($authoritative) {
  3609. $this->getIO()->write('<info>Generated optimized autoload files (authoritative) containing '. $numberOfClasses .' classes</info>');
  3610. } elseif ($optimize) {
  3611. $this->getIO()->write('<info>Generated optimized autoload files containing '. $numberOfClasses .' classes</info>');
  3612. } else {
  3613. $this->getIO()->write('<info>Generated autoload files</info>');
  3614. }
  3615. return 0;
  3616. }
  3617. }
  3618. <?php
  3619. namespace Composer\Command;
  3620. use Symfony\Component\Console\Input\InputInterface;
  3621. use Symfony\Component\Console\Input\InputOption;
  3622. use Symfony\Component\Console\Output\OutputInterface;
  3623. use Symfony\Component\Console\Input\InputArgument;
  3624. class ExecCommand extends BaseCommand
  3625. {
  3626. protected function configure()
  3627. {
  3628. $this
  3629. ->setName('exec')
  3630. ->setDescription('Executes a vendored binary/script.')
  3631. ->setDefinition(array(
  3632. new InputOption('list', 'l', InputOption::VALUE_NONE),
  3633. new InputArgument('binary', InputArgument::OPTIONAL, 'The binary to run, e.g. phpunit'),
  3634. new InputArgument(
  3635. 'args',
  3636. InputArgument::IS_ARRAY | InputArgument::OPTIONAL,
  3637. 'Arguments to pass to the binary. Use <info>--</info> to separate from composer arguments'
  3638. ),
  3639. ))
  3640. ->setHelp(
  3641. <<<EOT
  3642. Executes a vendored binary/script.
  3643. Read more at https://getcomposer.org/doc/03-cli.md#exec
  3644. EOT
  3645. )
  3646. ;
  3647. }
  3648. protected function execute(InputInterface $input, OutputInterface $output)
  3649. {
  3650. $composer = $this->getComposer();
  3651. $binDir = $composer->getConfig()->get('bin-dir');
  3652. if ($input->getOption('list') || !$input->getArgument('binary')) {
  3653. $bins = glob($binDir . '/*');
  3654. $bins = array_merge($bins, array_map(function ($e) {
  3655. return "$e (local)";
  3656. }, $composer->getPackage()->getBinaries()));
  3657. if (!$bins) {
  3658. throw new \RuntimeException("No binaries found in composer.json or in bin-dir ($binDir)");
  3659. }
  3660. $this->getIO()->write(
  3661. <<<EOT
  3662. <comment>Available binaries:</comment>
  3663. EOT
  3664. );
  3665. foreach ($bins as $bin) {
  3666. if (isset($previousBin) && $bin === $previousBin.'.bat') {
  3667. continue;
  3668. }
  3669. $previousBin = $bin;
  3670. $bin = basename($bin);
  3671. $this->getIO()->write(
  3672. <<<EOT
  3673. <info>- $bin</info>
  3674. EOT
  3675. );
  3676. }
  3677. return 0;
  3678. }
  3679. $binary = $input->getArgument('binary');
  3680. $dispatcher = $composer->getEventDispatcher();
  3681. $dispatcher->addListener('__exec_command', $binary);
  3682. if ($output->getVerbosity() === OutputInterface::VERBOSITY_NORMAL) {
  3683. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  3684. }
  3685. if (getcwd() !== $this->getApplication()->getInitialWorkingDirectory()) {
  3686. try {
  3687. chdir($this->getApplication()->getInitialWorkingDirectory());
  3688. } catch (\Exception $e) {
  3689. throw new \RuntimeException('Could not switch back to working directory "'.$this->getApplication()->getInitialWorkingDirectory().'"', 0, $e);
  3690. }
  3691. }
  3692. return $dispatcher->dispatchScript('__exec_command', true, $input->getArgument('args'));
  3693. }
  3694. }
  3695. <?php
  3696. namespace Composer\Command;
  3697. use Composer\Package\CompletePackageInterface;
  3698. use Composer\Package\AliasPackage;
  3699. use Composer\Package\BasePackage;
  3700. use Composer\Semver\Constraint\MatchAllConstraint;
  3701. use Composer\Repository\CompositeRepository;
  3702. use Symfony\Component\Console\Input\InputInterface;
  3703. use Symfony\Component\Console\Output\OutputInterface;
  3704. class FundCommand extends BaseCommand
  3705. {
  3706. protected function configure()
  3707. {
  3708. $this->setName('fund')
  3709. ->setDescription('Discover how to help fund the maintenance of your dependencies.')
  3710. ;
  3711. }
  3712. protected function execute(InputInterface $input, OutputInterface $output)
  3713. {
  3714. $composer = $this->getComposer();
  3715. $repo = $composer->getRepositoryManager()->getLocalRepository();
  3716. $remoteRepos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  3717. $fundings = array();
  3718. $packagesToLoad = array();
  3719. foreach ($repo->getPackages() as $package) {
  3720. if ($package instanceof AliasPackage) {
  3721. continue;
  3722. }
  3723. $packagesToLoad[$package->getName()] = new MatchAllConstraint();
  3724. }
  3725. $result = $remoteRepos->loadPackages($packagesToLoad, array('dev' => BasePackage::STABILITY_DEV), array());
  3726. foreach ($result['packages'] as $package) {
  3727. if (
  3728. !$package instanceof AliasPackage
  3729. && $package instanceof CompletePackageInterface
  3730. && $package->isDefaultBranch()
  3731. && $package->getFunding()
  3732. && isset($packagesToLoad[$package->getName()])
  3733. ) {
  3734. $fundings = $this->insertFundingData($fundings, $package);
  3735. unset($packagesToLoad[$package->getName()]);
  3736. }
  3737. }
  3738. foreach ($repo->getPackages() as $package) {
  3739. if ($package instanceof AliasPackage || !isset($packagesToLoad[$package->getName()])) {
  3740. continue;
  3741. }
  3742. if ($package instanceof CompletePackageInterface && $package->getFunding()) {
  3743. $fundings = $this->insertFundingData($fundings, $package);
  3744. }
  3745. }
  3746. ksort($fundings);
  3747. $io = $this->getIO();
  3748. if ($fundings) {
  3749. $prev = null;
  3750. $io->write('The following packages were found in your dependencies which publish funding information:');
  3751. foreach ($fundings as $vendor => $links) {
  3752. $io->write('');
  3753. $io->write(sprintf("<comment>%s</comment>", $vendor));
  3754. foreach ($links as $url => $packages) {
  3755. $line = sprintf(' <info>%s</info>', implode(', ', $packages));
  3756. if ($prev !== $line) {
  3757. $io->write($line);
  3758. $prev = $line;
  3759. }
  3760. $io->write(sprintf(' %s', $url));
  3761. }
  3762. }
  3763. $io->write("");
  3764. $io->write("Please consider following these links and sponsoring the work of package authors!");
  3765. $io->write("Thank you!");
  3766. } else {
  3767. $io->write("No funding links were found in your package dependencies. This doesn't mean they don't need your support!");
  3768. }
  3769. return 0;
  3770. }
  3771. private function insertFundingData(array $fundings, CompletePackageInterface $package)
  3772. {
  3773. foreach ($package->getFunding() as $fundingOption) {
  3774. list($vendor, $packageName) = explode('/', $package->getPrettyName());
  3775. if (empty($fundingOption['url'])) {
  3776. continue;
  3777. }
  3778. $url = $fundingOption['url'];
  3779. if (!empty($fundingOption['type']) && $fundingOption['type'] === 'github' && preg_match('{^https://github.com/([^/]+)$}', $url, $match)) {
  3780. $url = 'https://github.com/sponsors/'.$match[1];
  3781. }
  3782. $fundings[$vendor][$url][] = $packageName;
  3783. }
  3784. return $fundings;
  3785. }
  3786. }
  3787. <?php
  3788. namespace Composer\Command;
  3789. use Composer\Factory;
  3790. use Composer\Util\Filesystem;
  3791. use Symfony\Component\Console\Input\InputInterface;
  3792. use Symfony\Component\Console\Input\InputArgument;
  3793. use Symfony\Component\Console\Input\StringInput;
  3794. use Symfony\Component\Console\Output\OutputInterface;
  3795. class GlobalCommand extends BaseCommand
  3796. {
  3797. protected function configure()
  3798. {
  3799. $this
  3800. ->setName('global')
  3801. ->setDescription('Allows running commands in the global composer dir ($COMPOSER_HOME).')
  3802. ->setDefinition(array(
  3803. new InputArgument('command-name', InputArgument::REQUIRED, ''),
  3804. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  3805. ))
  3806. ->setHelp(
  3807. <<<EOT
  3808. Use this command as a wrapper to run other Composer commands
  3809. within the global context of COMPOSER_HOME.
  3810. You can use this to install CLI utilities globally, all you need
  3811. is to add the COMPOSER_HOME/vendor/bin dir to your PATH env var.
  3812. COMPOSER_HOME is c:\Users\<user>\AppData\Roaming\Composer on Windows
  3813. and /home/<user>/.composer on unix systems.
  3814. If your system uses freedesktop.org standards, then it will first check
  3815. XDG_CONFIG_HOME or default to /home/<user>/.config/composer
  3816. Note: This path may vary depending on customizations to bin-dir in
  3817. composer.json or the environmental variable COMPOSER_BIN_DIR.
  3818. Read more at https://getcomposer.org/doc/03-cli.md#global
  3819. EOT
  3820. )
  3821. ;
  3822. }
  3823. public function run(InputInterface $input, OutputInterface $output)
  3824. {
  3825. $tokens = preg_split('{\s+}', $input->__toString());
  3826. $args = array();
  3827. foreach ($tokens as $token) {
  3828. if ($token && $token[0] !== '-') {
  3829. $args[] = $token;
  3830. if (count($args) >= 2) {
  3831. break;
  3832. }
  3833. }
  3834. }
  3835. if (count($args) < 2) {
  3836. return parent::run($input, $output);
  3837. }
  3838. if (getenv('COMPOSER')) {
  3839. putenv('COMPOSER');
  3840. unset($_SERVER['COMPOSER']);
  3841. }
  3842. $config = Factory::createConfig();
  3843. $home = $config->get('home');
  3844. if (!is_dir($home)) {
  3845. $fs = new Filesystem();
  3846. $fs->ensureDirectoryExists($home);
  3847. if (!is_dir($home)) {
  3848. throw new \RuntimeException('Could not create home directory');
  3849. }
  3850. }
  3851. try {
  3852. chdir($home);
  3853. } catch (\Exception $e) {
  3854. throw new \RuntimeException('Could not switch to home directory "'.$home.'"', 0, $e);
  3855. }
  3856. $this->getIO()->writeError('<info>Changed current directory to '.$home.'</info>');
  3857. $input = new StringInput(preg_replace('{\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\b}', '', $input->__toString(), 1));
  3858. $this->getApplication()->resetComposer();
  3859. return $this->getApplication()->run($input, $output);
  3860. }
  3861. public function isProxyCommand()
  3862. {
  3863. return true;
  3864. }
  3865. }
  3866. <?php
  3867. namespace Composer\Command;
  3868. use Composer\Package\CompletePackageInterface;
  3869. use Composer\Repository\RepositoryInterface;
  3870. use Composer\Repository\RootPackageRepository;
  3871. use Composer\Repository\RepositoryFactory;
  3872. use Composer\Util\Platform;
  3873. use Composer\Util\ProcessExecutor;
  3874. use Symfony\Component\Console\Input\InputArgument;
  3875. use Symfony\Component\Console\Input\InputOption;
  3876. use Symfony\Component\Console\Input\InputInterface;
  3877. use Symfony\Component\Console\Output\OutputInterface;
  3878. class HomeCommand extends BaseCommand
  3879. {
  3880. protected function configure()
  3881. {
  3882. $this
  3883. ->setName('browse')
  3884. ->setAliases(array('home'))
  3885. ->setDescription('Opens the package\'s repository URL or homepage in your browser.')
  3886. ->setDefinition(array(
  3887. new InputArgument('packages', InputArgument::IS_ARRAY, 'Package(s) to browse to.'),
  3888. new InputOption('homepage', 'H', InputOption::VALUE_NONE, 'Open the homepage instead of the repository URL.'),
  3889. new InputOption('show', 's', InputOption::VALUE_NONE, 'Only show the homepage or repository URL.'),
  3890. ))
  3891. ->setHelp(
  3892. <<<EOT
  3893. The home command opens or shows a package's repository URL or
  3894. homepage in your default browser.
  3895. To open the homepage by default, use -H or --homepage.
  3896. To show instead of open the repository or homepage URL, use -s or --show.
  3897. Read more at https://getcomposer.org/doc/03-cli.md#browse-home
  3898. EOT
  3899. );
  3900. }
  3901. protected function execute(InputInterface $input, OutputInterface $output)
  3902. {
  3903. $repos = $this->initializeRepos();
  3904. $io = $this->getIO();
  3905. $return = 0;
  3906. $packages = $input->getArgument('packages');
  3907. if (!$packages) {
  3908. $io->writeError('No package specified, opening homepage for the root package');
  3909. $packages = array($this->getComposer()->getPackage()->getName());
  3910. }
  3911. foreach ($packages as $packageName) {
  3912. $handled = false;
  3913. $packageExists = false;
  3914. foreach ($repos as $repo) {
  3915. foreach ($repo->findPackages($packageName) as $package) {
  3916. $packageExists = true;
  3917. if ($package instanceof CompletePackageInterface && $this->handlePackage($package, $input->getOption('homepage'), $input->getOption('show'))) {
  3918. $handled = true;
  3919. break 2;
  3920. }
  3921. }
  3922. }
  3923. if (!$packageExists) {
  3924. $return = 1;
  3925. $io->writeError('<warning>Package '.$packageName.' not found</warning>');
  3926. }
  3927. if (!$handled) {
  3928. $return = 1;
  3929. $io->writeError('<warning>'.($input->getOption('homepage') ? 'Invalid or missing homepage' : 'Invalid or missing repository URL').' for '.$packageName.'</warning>');
  3930. }
  3931. }
  3932. return $return;
  3933. }
  3934. private function handlePackage(CompletePackageInterface $package, $showHomepage, $showOnly)
  3935. {
  3936. $support = $package->getSupport();
  3937. $url = isset($support['source']) ? $support['source'] : $package->getSourceUrl();
  3938. if (!$url || $showHomepage) {
  3939. $url = $package->getHomepage();
  3940. }
  3941. if (!$url || !filter_var($url, FILTER_VALIDATE_URL)) {
  3942. return false;
  3943. }
  3944. if ($showOnly) {
  3945. $this->getIO()->write(sprintf('<info>%s</info>', $url));
  3946. } else {
  3947. $this->openBrowser($url);
  3948. }
  3949. return true;
  3950. }
  3951. private function openBrowser($url)
  3952. {
  3953. $url = ProcessExecutor::escape($url);
  3954. $process = new ProcessExecutor($this->getIO());
  3955. if (Platform::isWindows()) {
  3956. return $process->execute('start "web" explorer "' . $url . '"', $output);
  3957. }
  3958. $linux = $process->execute('which xdg-open', $output);
  3959. $osx = $process->execute('which open', $output);
  3960. if (0 === $linux) {
  3961. $process->execute('xdg-open ' . $url, $output);
  3962. } elseif (0 === $osx) {
  3963. $process->execute('open ' . $url, $output);
  3964. } else {
  3965. $this->getIO()->writeError('No suitable browser opening command found, open yourself: ' . $url);
  3966. }
  3967. }
  3968. private function initializeRepos()
  3969. {
  3970. $composer = $this->getComposer(false);
  3971. if ($composer) {
  3972. return array_merge(
  3973. array(new RootPackageRepository($composer->getPackage())),
  3974. array($composer->getRepositoryManager()->getLocalRepository()),
  3975. $composer->getRepositoryManager()->getRepositories()
  3976. );
  3977. }
  3978. return RepositoryFactory::defaultRepos($this->getIO());
  3979. }
  3980. }
  3981. <?php
  3982. namespace Composer\Command;
  3983. use Composer\Factory;
  3984. use Composer\Json\JsonFile;
  3985. use Composer\Package\BasePackage;
  3986. use Composer\Package\Package;
  3987. use Composer\Package\Version\VersionParser;
  3988. use Composer\Package\Version\VersionSelector;
  3989. use Composer\Repository\CompositeRepository;
  3990. use Composer\Repository\PlatformRepository;
  3991. use Composer\Repository\RepositoryFactory;
  3992. use Composer\Repository\RepositorySet;
  3993. use Composer\Util\ProcessExecutor;
  3994. use Symfony\Component\Console\Input\ArrayInput;
  3995. use Symfony\Component\Console\Input\InputInterface;
  3996. use Symfony\Component\Console\Input\InputOption;
  3997. use Symfony\Component\Console\Output\OutputInterface;
  3998. use Symfony\Component\Process\ExecutableFinder;
  3999. use Symfony\Component\Process\Process;
  4000. class InitCommand extends BaseCommand
  4001. {
  4002. protected $repos;
  4003. private $gitConfig;
  4004. private $repositorySets;
  4005. protected function configure()
  4006. {
  4007. $this
  4008. ->setName('init')
  4009. ->setDescription('Creates a basic composer.json file in current directory.')
  4010. ->setDefinition(array(
  4011. new InputOption('name', null, InputOption::VALUE_REQUIRED, 'Name of the package'),
  4012. new InputOption('description', null, InputOption::VALUE_REQUIRED, 'Description of package'),
  4013. new InputOption('author', null, InputOption::VALUE_REQUIRED, 'Author name of package'),
  4014. new InputOption('type', null, InputOption::VALUE_OPTIONAL, 'Type of package (e.g. library, project, metapackage, composer-plugin)'),
  4015. new InputOption('homepage', null, InputOption::VALUE_REQUIRED, 'Homepage of package'),
  4016. 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"'),
  4017. 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"'),
  4018. new InputOption('stability', 's', InputOption::VALUE_REQUIRED, 'Minimum stability (empty or one of: '.implode(', ', array_keys(BasePackage::$stabilities)).')'),
  4019. new InputOption('license', 'l', InputOption::VALUE_REQUIRED, 'License of package'),
  4020. new InputOption('repository', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Add custom repositories, either by URL or using JSON arrays'),
  4021. ))
  4022. ->setHelp(
  4023. <<<EOT
  4024. The <info>init</info> command creates a basic composer.json file
  4025. in the current directory.
  4026. <info>php composer.phar init</info>
  4027. Read more at https://getcomposer.org/doc/03-cli.md#init
  4028. EOT
  4029. )
  4030. ;
  4031. }
  4032. protected function execute(InputInterface $input, OutputInterface $output)
  4033. {
  4034. $io = $this->getIO();
  4035. $allowlist = array('name', 'description', 'author', 'type', 'homepage', 'require', 'require-dev', 'stability', 'license');
  4036. $options = array_filter(array_intersect_key($input->getOptions(), array_flip($allowlist)));
  4037. if (isset($options['author'])) {
  4038. $options['authors'] = $this->formatAuthors($options['author']);
  4039. unset($options['author']);
  4040. }
  4041. $repositories = $input->getOption('repository');
  4042. if ($repositories) {
  4043. $config = Factory::createConfig($io);
  4044. foreach ($repositories as $repo) {
  4045. $options['repositories'][] = RepositoryFactory::configFromString($io, $config, $repo, true);
  4046. }
  4047. }
  4048. if (isset($options['stability'])) {
  4049. $options['minimum-stability'] = $options['stability'];
  4050. unset($options['stability']);
  4051. }
  4052. $options['require'] = isset($options['require']) ? $this->formatRequirements($options['require']) : new \stdClass;
  4053. if (array() === $options['require']) {
  4054. $options['require'] = new \stdClass;
  4055. }
  4056. if (isset($options['require-dev'])) {
  4057. $options['require-dev'] = $this->formatRequirements($options['require-dev']);
  4058. if (array() === $options['require-dev']) {
  4059. $options['require-dev'] = new \stdClass;
  4060. }
  4061. }
  4062. $file = new JsonFile(Factory::getComposerFile());
  4063. $json = JsonFile::encode($options);
  4064. if ($input->isInteractive()) {
  4065. $io->writeError(array('', $json, ''));
  4066. if (!$io->askConfirmation('Do you confirm generation [<comment>yes</comment>]? ')) {
  4067. $io->writeError('<error>Command aborted</error>');
  4068. return 1;
  4069. }
  4070. } else {
  4071. if (json_encode($options) === '{"require":{}}') {
  4072. throw new \RuntimeException('You have to run this command in interactive mode, or specify at least some data using --name, --require, etc.');
  4073. }
  4074. $io->writeError('Writing composer.json');
  4075. }
  4076. $file->write($options);
  4077. if ($input->isInteractive() && is_dir('.git')) {
  4078. $ignoreFile = realpath('.gitignore');
  4079. if (false === $ignoreFile) {
  4080. $ignoreFile = realpath('.') . '/.gitignore';
  4081. }
  4082. if (!$this->hasVendorIgnore($ignoreFile)) {
  4083. $question = 'Would you like the <info>vendor</info> directory added to your <info>.gitignore</info> [<comment>yes</comment>]? ';
  4084. if ($io->askConfirmation($question)) {
  4085. $this->addVendorIgnore($ignoreFile);
  4086. }
  4087. }
  4088. }
  4089. $question = 'Would you like to install dependencies now [<comment>yes</comment>]? ';
  4090. if ($input->isInteractive() && $this->hasDependencies($options) && $io->askConfirmation($question)) {
  4091. $this->installDependencies($output);
  4092. }
  4093. return 0;
  4094. }
  4095. protected function interact(InputInterface $input, OutputInterface $output)
  4096. {
  4097. $git = $this->getGitConfig();
  4098. $io = $this->getIO();
  4099. $formatter = $this->getHelperSet()->get('formatter');
  4100. $repositories = $input->getOption('repository');
  4101. if ($repositories) {
  4102. $config = Factory::createConfig($io);
  4103. $repos = array(new PlatformRepository);
  4104. $createDefaultPackagistRepo = true;
  4105. foreach ($repositories as $repo) {
  4106. $repoConfig = RepositoryFactory::configFromString($io, $config, $repo, true);
  4107. if (
  4108. (isset($repoConfig['packagist']) && $repoConfig === array('packagist' => false))
  4109. || (isset($repoConfig['packagist.org']) && $repoConfig === array('packagist.org' => false))
  4110. ) {
  4111. $createDefaultPackagistRepo = false;
  4112. continue;
  4113. }
  4114. $repos[] = RepositoryFactory::createRepo($io, $config, $repoConfig);
  4115. }
  4116. if ($createDefaultPackagistRepo) {
  4117. $repos[] = RepositoryFactory::createRepo($io, $config, array(
  4118. 'type' => 'composer',
  4119. 'url' => 'https://repo.packagist.org',
  4120. ));
  4121. }
  4122. $this->repos = new CompositeRepository($repos);
  4123. unset($repos, $config, $repositories);
  4124. }
  4125. $io->writeError(array(
  4126. '',
  4127. $formatter->formatBlock('Welcome to the Composer config generator', 'bg=blue;fg=white', true),
  4128. '',
  4129. ));
  4130. $io->writeError(array(
  4131. '',
  4132. 'This command will guide you through creating your composer.json config.',
  4133. '',
  4134. ));
  4135. $cwd = realpath(".");
  4136. if (!$name = $input->getOption('name')) {
  4137. $name = basename($cwd);
  4138. $name = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  4139. $name = strtolower($name);
  4140. if (!empty($_SERVER['COMPOSER_DEFAULT_VENDOR'])) {
  4141. $name = $_SERVER['COMPOSER_DEFAULT_VENDOR'] . '/' . $name;
  4142. } elseif (isset($git['github.user'])) {
  4143. $name = $git['github.user'] . '/' . $name;
  4144. } elseif (!empty($_SERVER['USERNAME'])) {
  4145. $name = $_SERVER['USERNAME'] . '/' . $name;
  4146. } elseif (!empty($_SERVER['USER'])) {
  4147. $name = $_SERVER['USER'] . '/' . $name;
  4148. } elseif (get_current_user()) {
  4149. $name = get_current_user() . '/' . $name;
  4150. } else {
  4151. $name .= '/' . $name;
  4152. }
  4153. $name = strtolower($name);
  4154. } else {
  4155. if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $name)) {
  4156. throw new \InvalidArgumentException(
  4157. '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_.-]+'
  4158. );
  4159. }
  4160. }
  4161. $name = $io->askAndValidate(
  4162. 'Package name (<vendor>/<name>) [<comment>'.$name.'</comment>]: ',
  4163. function ($value) use ($name) {
  4164. if (null === $value) {
  4165. return $name;
  4166. }
  4167. if (!preg_match('{^[a-z0-9_.-]+/[a-z0-9_.-]+$}D', $value)) {
  4168. throw new \InvalidArgumentException(
  4169. '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_.-]+'
  4170. );
  4171. }
  4172. return $value;
  4173. },
  4174. null,
  4175. $name
  4176. );
  4177. $input->setOption('name', $name);
  4178. $description = $input->getOption('description') ?: false;
  4179. $description = $io->ask(
  4180. 'Description [<comment>'.$description.'</comment>]: ',
  4181. $description
  4182. );
  4183. $input->setOption('description', $description);
  4184. if (null === $author = $input->getOption('author')) {
  4185. if (!empty($_SERVER['COMPOSER_DEFAULT_AUTHOR'])) {
  4186. $author_name = $_SERVER['COMPOSER_DEFAULT_AUTHOR'];
  4187. } elseif (isset($git['user.name'])) {
  4188. $author_name = $git['user.name'];
  4189. }
  4190. if (!empty($_SERVER['COMPOSER_DEFAULT_EMAIL'])) {
  4191. $author_email = $_SERVER['COMPOSER_DEFAULT_EMAIL'];
  4192. } elseif (isset($git['user.email'])) {
  4193. $author_email = $git['user.email'];
  4194. }
  4195. if (isset($author_name, $author_email)) {
  4196. $author = sprintf('%s <%s>', $author_name, $author_email);
  4197. }
  4198. }
  4199. $self = $this;
  4200. $author = $io->askAndValidate(
  4201. 'Author [<comment>'.$author.'</comment>, n to skip]: ',
  4202. function ($value) use ($self, $author) {
  4203. if ($value === 'n' || $value === 'no') {
  4204. return;
  4205. }
  4206. $value = $value ?: $author;
  4207. $author = $self->parseAuthorString($value);
  4208. return sprintf('%s <%s>', $author['name'], $author['email']);
  4209. },
  4210. null,
  4211. $author
  4212. );
  4213. $input->setOption('author', $author);
  4214. $minimumStability = $input->getOption('stability') ?: null;
  4215. $minimumStability = $io->askAndValidate(
  4216. 'Minimum Stability [<comment>'.$minimumStability.'</comment>]: ',
  4217. function ($value) use ($minimumStability) {
  4218. if (null === $value) {
  4219. return $minimumStability;
  4220. }
  4221. if (!isset(BasePackage::$stabilities[$value])) {
  4222. throw new \InvalidArgumentException(
  4223. 'Invalid minimum stability "'.$value.'". Must be empty or one of: '.
  4224. implode(', ', array_keys(BasePackage::$stabilities))
  4225. );
  4226. }
  4227. return $value;
  4228. },
  4229. null,
  4230. $minimumStability
  4231. );
  4232. $input->setOption('stability', $minimumStability);
  4233. $type = $input->getOption('type') ?: false;
  4234. $type = $io->ask(
  4235. 'Package Type (e.g. library, project, metapackage, composer-plugin) [<comment>'.$type.'</comment>]: ',
  4236. $type
  4237. );
  4238. $input->setOption('type', $type);
  4239. if (null === $license = $input->getOption('license')) {
  4240. if (!empty($_SERVER['COMPOSER_DEFAULT_LICENSE'])) {
  4241. $license = $_SERVER['COMPOSER_DEFAULT_LICENSE'];
  4242. }
  4243. }
  4244. $license = $io->ask(
  4245. 'License [<comment>'.$license.'</comment>]: ',
  4246. $license
  4247. );
  4248. $input->setOption('license', $license);
  4249. $io->writeError(array('', 'Define your dependencies.', ''));
  4250. $repos = $this->getRepos();
  4251. $preferredStability = $minimumStability ?: 'stable';
  4252. $platformRepo = null;
  4253. if ($repos instanceof CompositeRepository) {
  4254. foreach ($repos->getRepositories() as $candidateRepo) {
  4255. if ($candidateRepo instanceof PlatformRepository) {
  4256. $platformRepo = $candidateRepo;
  4257. break;
  4258. }
  4259. }
  4260. }
  4261. $question = 'Would you like to define your dependencies (require) interactively [<comment>yes</comment>]? ';
  4262. $require = $input->getOption('require');
  4263. $requirements = array();
  4264. if ($require || $io->askConfirmation($question)) {
  4265. $requirements = $this->determineRequirements($input, $output, $require, $platformRepo, $preferredStability);
  4266. }
  4267. $input->setOption('require', $requirements);
  4268. $question = 'Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ';
  4269. $requireDev = $input->getOption('require-dev');
  4270. $devRequirements = array();
  4271. if ($requireDev || $io->askConfirmation($question)) {
  4272. $devRequirements = $this->determineRequirements($input, $output, $requireDev, $platformRepo, $preferredStability);
  4273. }
  4274. $input->setOption('require-dev', $devRequirements);
  4275. }
  4276. public function parseAuthorString($author)
  4277. {
  4278. if (preg_match('/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’"()]+) <(?P<email>.+?)>$/u', $author, $match)) {
  4279. if ($this->isValidEmail($match['email'])) {
  4280. return array(
  4281. 'name' => trim($match['name']),
  4282. 'email' => $match['email'],
  4283. );
  4284. }
  4285. }
  4286. throw new \InvalidArgumentException(
  4287. 'Invalid author string. Must be in the format: '.
  4288. 'John Smith <john@example.com>'
  4289. );
  4290. }
  4291. protected function findPackages($name)
  4292. {
  4293. return $this->getRepos()->search($name);
  4294. }
  4295. protected function getRepos()
  4296. {
  4297. if (!$this->repos) {
  4298. $this->repos = new CompositeRepository(array_merge(
  4299. array(new PlatformRepository),
  4300. RepositoryFactory::defaultRepos($this->getIO())
  4301. ));
  4302. }
  4303. return $this->repos;
  4304. }
  4305. final protected function determineRequirements(InputInterface $input, OutputInterface $output, $requires = array(), PlatformRepository $platformRepo = null, $preferredStability = 'stable', $checkProvidedVersions = true, $fixed = false)
  4306. {
  4307. if ($requires) {
  4308. $requires = $this->normalizeRequirements($requires);
  4309. $result = array();
  4310. $io = $this->getIO();
  4311. foreach ($requires as $requirement) {
  4312. if (!isset($requirement['version'])) {
  4313. list($name, $version) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, null, null, $fixed);
  4314. $requirement['version'] = $version;
  4315. $requirement['name'] = $name;
  4316. $io->writeError(sprintf(
  4317. 'Using version <info>%s</info> for <info>%s</info>',
  4318. $requirement['version'],
  4319. $requirement['name']
  4320. ));
  4321. } else {
  4322. list($name) = $this->findBestVersionAndNameForPackage($input, $requirement['name'], $platformRepo, $preferredStability, $checkProvidedVersions ? $requirement['version'] : null, 'dev', $fixed);
  4323. $requirement['name'] = $name;
  4324. }
  4325. $result[] = $requirement['name'] . ' ' . $requirement['version'];
  4326. }
  4327. return $result;
  4328. }
  4329. $versionParser = new VersionParser();
  4330. $composer = $this->getComposer(false);
  4331. $installedRepo = $composer ? $composer->getRepositoryManager()->getLocalRepository() : null;
  4332. $existingPackages = array();
  4333. if ($installedRepo) {
  4334. foreach ($installedRepo->getPackages() as $package) {
  4335. $existingPackages[] = $package->getName();
  4336. }
  4337. }
  4338. unset($composer, $installedRepo);
  4339. $io = $this->getIO();
  4340. while (null !== $package = $io->ask('Search for a package: ')) {
  4341. $matches = $this->findPackages($package);
  4342. if (count($matches)) {
  4343. foreach ($matches as $position => $foundPackage) {
  4344. if (in_array($foundPackage['name'], $existingPackages, true)) {
  4345. unset($matches[$position]);
  4346. }
  4347. }
  4348. $matches = array_values($matches);
  4349. $exactMatch = null;
  4350. $choices = array();
  4351. foreach ($matches as $position => $foundPackage) {
  4352. $abandoned = '';
  4353. if (isset($foundPackage['abandoned'])) {
  4354. if (is_string($foundPackage['abandoned'])) {
  4355. $replacement = sprintf('Use %s instead', $foundPackage['abandoned']);
  4356. } else {
  4357. $replacement = 'No replacement was suggested';
  4358. }
  4359. $abandoned = sprintf('<warning>Abandoned. %s.</warning>', $replacement);
  4360. }
  4361. $choices[] = sprintf(' <info>%5s</info> %s %s', "[$position]", $foundPackage['name'], $abandoned);
  4362. if ($foundPackage['name'] === $package) {
  4363. $exactMatch = true;
  4364. break;
  4365. }
  4366. }
  4367. if (!$exactMatch) {
  4368. $io->writeError(array(
  4369. '',
  4370. sprintf('Found <info>%s</info> packages matching <info>%s</info>', count($matches), $package),
  4371. '',
  4372. ));
  4373. $io->writeError($choices);
  4374. $io->writeError('');
  4375. $validator = function ($selection) use ($matches, $versionParser) {
  4376. if ('' === $selection) {
  4377. return false;
  4378. }
  4379. if (is_numeric($selection) && isset($matches[(int) $selection])) {
  4380. $package = $matches[(int) $selection];
  4381. return $package['name'];
  4382. }
  4383. if (preg_match('{^\s*(?P<name>[\S/]+)(?:\s+(?P<version>\S+))?\s*$}', $selection, $packageMatches)) {
  4384. if (isset($packageMatches['version'])) {
  4385. $versionParser->parseConstraints($packageMatches['version']);
  4386. return $packageMatches['name'].' '.$packageMatches['version'];
  4387. }
  4388. return $packageMatches['name'];
  4389. }
  4390. throw new \Exception('Not a valid selection');
  4391. };
  4392. $package = $io->askAndValidate(
  4393. 'Enter package # to add, or the complete package name if it is not listed: ',
  4394. $validator,
  4395. 3,
  4396. false
  4397. );
  4398. }
  4399. if (false !== $package && false === strpos($package, ' ')) {
  4400. $validator = function ($input) {
  4401. $input = trim($input);
  4402. return $input ?: false;
  4403. };
  4404. $constraint = $io->askAndValidate(
  4405. 'Enter the version constraint to require (or leave blank to use the latest version): ',
  4406. $validator,
  4407. 3,
  4408. false
  4409. );
  4410. if (false === $constraint) {
  4411. list(, $constraint) = $this->findBestVersionAndNameForPackage($input, $package, $platformRepo, $preferredStability);
  4412. $io->writeError(sprintf(
  4413. 'Using version <info>%s</info> for <info>%s</info>',
  4414. $constraint,
  4415. $package
  4416. ));
  4417. }
  4418. $package .= ' '.$constraint;
  4419. }
  4420. if (false !== $package) {
  4421. $requires[] = $package;
  4422. $existingPackages[] = substr($package, 0, strpos($package, ' '));
  4423. }
  4424. }
  4425. }
  4426. return $requires;
  4427. }
  4428. protected function formatAuthors($author)
  4429. {
  4430. return array($this->parseAuthorString($author));
  4431. }
  4432. protected function getGitConfig()
  4433. {
  4434. if (null !== $this->gitConfig) {
  4435. return $this->gitConfig;
  4436. }
  4437. $finder = new ExecutableFinder();
  4438. $gitBin = $finder->find('git');
  4439. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  4440. $cmd = new Process(array($gitBin, 'config', '-l'));
  4441. } else {
  4442. $cmd = new Process(sprintf('%s config -l', ProcessExecutor::escape($gitBin)));
  4443. }
  4444. $cmd->run();
  4445. if ($cmd->isSuccessful()) {
  4446. $this->gitConfig = array();
  4447. preg_match_all('{^([^=]+)=(.*)$}m', $cmd->getOutput(), $matches, PREG_SET_ORDER);
  4448. foreach ($matches as $match) {
  4449. $this->gitConfig[$match[1]] = $match[2];
  4450. }
  4451. return $this->gitConfig;
  4452. }
  4453. return $this->gitConfig = array();
  4454. }
  4455. protected function hasVendorIgnore($ignoreFile, $vendor = 'vendor')
  4456. {
  4457. if (!file_exists($ignoreFile)) {
  4458. return false;
  4459. }
  4460. $pattern = sprintf('{^/?%s(/\*?)?$}', preg_quote($vendor));
  4461. $lines = file($ignoreFile, FILE_IGNORE_NEW_LINES);
  4462. foreach ($lines as $line) {
  4463. if (preg_match($pattern, $line)) {
  4464. return true;
  4465. }
  4466. }
  4467. return false;
  4468. }
  4469. protected function addVendorIgnore($ignoreFile, $vendor = '/vendor/')
  4470. {
  4471. $contents = "";
  4472. if (file_exists($ignoreFile)) {
  4473. $contents = file_get_contents($ignoreFile);
  4474. if (strpos($contents, "\n") !== 0) {
  4475. $contents .= "\n";
  4476. }
  4477. }
  4478. file_put_contents($ignoreFile, $contents . $vendor. "\n");
  4479. }
  4480. protected function isValidEmail($email)
  4481. {
  4482. if (!function_exists('filter_var')) {
  4483. return true;
  4484. }
  4485. if (PHP_VERSION_ID < 50303) {
  4486. return true;
  4487. }
  4488. return false !== filter_var($email, FILTER_VALIDATE_EMAIL);
  4489. }
  4490. private function getRepositorySet(InputInterface $input, $minimumStability = null)
  4491. {
  4492. $key = $minimumStability ?: 'default';
  4493. if (!isset($this->repositorySets[$key])) {
  4494. $this->repositorySets[$key] = $repositorySet = new RepositorySet($minimumStability ?: $this->getMinimumStability($input));
  4495. $repositorySet->addRepository($this->getRepos());
  4496. }
  4497. return $this->repositorySets[$key];
  4498. }
  4499. private function getMinimumStability(InputInterface $input)
  4500. {
  4501. if ($input->hasOption('stability')) {
  4502. return VersionParser::normalizeStability($input->getOption('stability') ?: 'stable');
  4503. }
  4504. $file = Factory::getComposerFile();
  4505. if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  4506. if (!empty($composer['minimum-stability'])) {
  4507. return VersionParser::normalizeStability($composer['minimum-stability']);
  4508. }
  4509. }
  4510. return 'stable';
  4511. }
  4512. private function findBestVersionAndNameForPackage(InputInterface $input, $name, PlatformRepository $platformRepo = null, $preferredStability = 'stable', $requiredVersion = null, $minimumStability = null, $fixed = null)
  4513. {
  4514. $ignorePlatformReqs = false;
  4515. if ($input->hasOption('ignore-platform-reqs') && $input->hasOption('ignore-platform-req')) {
  4516. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  4517. }
  4518. $versionSelector = new VersionSelector($this->getRepositorySet($input, $minimumStability), $platformRepo);
  4519. $package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs);
  4520. if (!$package) {
  4521. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($name, $ignorePlatformReqs))) && PlatformRepository::isPlatformPackage($name)) {
  4522. return array($name, $requiredVersion ?: '*');
  4523. }
  4524. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, true)) {
  4525. throw new \InvalidArgumentException(sprintf(
  4526. 'Package %s%s has a PHP requirement incompatible with your PHP version, PHP extensions and Composer version',
  4527. $name,
  4528. $requiredVersion ? ' at version '.$requiredVersion : ''
  4529. ));
  4530. }
  4531. if ($package = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  4532. if ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, $ignorePlatformReqs, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  4533. throw new \InvalidArgumentException(
  4534. 'Package '.$name.' exists in '.$allReposPackage->getRepository()->getRepoName().' and '.$package->getRepository()->getRepoName().' which has a higher repository priority. The packages with higher priority do not match your minimum-stability and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.'
  4535. );
  4536. }
  4537. throw new \InvalidArgumentException(sprintf(
  4538. 'Could not find a version of package %s matching your minimum-stability (%s). Require it with an explicit version constraint allowing its desired stability.',
  4539. $name,
  4540. $this->getMinimumStability($input)
  4541. ));
  4542. }
  4543. if ($requiredVersion && $package = $versionSelector->findBestCandidate($name, null, $preferredStability, $ignorePlatformReqs)) {
  4544. if ($allReposPackage = $versionSelector->findBestCandidate($name, $requiredVersion, $preferredStability, false, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  4545. throw new \InvalidArgumentException(
  4546. 'Package '.$name.' exists in '.$allReposPackage->getRepository()->getRepoName().' and '.$package->getRepository()->getRepoName().' which has a higher repository priority. The packages with higher priority do not match your constraint and are therefore not installable. See https://getcomposer.org/repoprio for details and assistance.'
  4547. );
  4548. }
  4549. throw new \InvalidArgumentException(sprintf(
  4550. 'Could not find package %s in a version matching %s',
  4551. $name,
  4552. $requiredVersion
  4553. ));
  4554. }
  4555. if (true !== $ignorePlatformReqs && $versionSelector->findBestCandidate($name, null, $preferredStability, true)) {
  4556. throw new \InvalidArgumentException(sprintf(
  4557. 'Could not find package %s in any version matching your PHP version, PHP extensions and Composer version',
  4558. $name
  4559. ));
  4560. }
  4561. $similar = $this->findSimilar($name);
  4562. if ($similar) {
  4563. throw new \InvalidArgumentException(sprintf(
  4564. "Could not find package %s.\n\nDid you mean " . (count($similar) > 1 ? 'one of these' : 'this') . "?\n %s",
  4565. $name,
  4566. implode("\n ", $similar)
  4567. ));
  4568. }
  4569. throw new \InvalidArgumentException(sprintf(
  4570. '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).',
  4571. $name,
  4572. $this->getMinimumStability($input)
  4573. ));
  4574. }
  4575. return array(
  4576. $package->getPrettyName(),
  4577. $fixed ? $package->getPrettyVersion() : $versionSelector->findRecommendedRequireVersion($package),
  4578. );
  4579. }
  4580. private function findSimilar($package)
  4581. {
  4582. try {
  4583. $results = $this->repos->search($package);
  4584. } catch (\Exception $e) {
  4585. return array();
  4586. }
  4587. $similarPackages = array();
  4588. $installedRepo = $this->getComposer()->getRepositoryManager()->getLocalRepository();
  4589. foreach ($results as $result) {
  4590. if ($installedRepo->findPackage($result['name'], '*')) {
  4591. continue;
  4592. }
  4593. $similarPackages[$result['name']] = levenshtein($package, $result['name']);
  4594. }
  4595. asort($similarPackages);
  4596. return array_keys(array_slice($similarPackages, 0, 5));
  4597. }
  4598. private function installDependencies($output)
  4599. {
  4600. try {
  4601. $installCommand = $this->getApplication()->find('install');
  4602. $installCommand->run(new ArrayInput(array()), $output);
  4603. } catch (\Exception $e) {
  4604. $this->getIO()->writeError('Could not install dependencies. Run `composer install` to see more information.');
  4605. }
  4606. }
  4607. private function hasDependencies($options)
  4608. {
  4609. $requires = (array) $options['require'];
  4610. $devRequires = isset($options['require-dev']) ? (array) $options['require-dev'] : array();
  4611. return !empty($requires) || !empty($devRequires);
  4612. }
  4613. }
  4614. <?php
  4615. namespace Composer\Command;
  4616. use Composer\Installer;
  4617. use Composer\Plugin\CommandEvent;
  4618. use Composer\Plugin\PluginEvents;
  4619. use Composer\Util\HttpDownloader;
  4620. use Symfony\Component\Console\Input\InputInterface;
  4621. use Symfony\Component\Console\Input\InputOption;
  4622. use Symfony\Component\Console\Input\InputArgument;
  4623. use Symfony\Component\Console\Output\OutputInterface;
  4624. class InstallCommand extends BaseCommand
  4625. {
  4626. protected function configure()
  4627. {
  4628. $this
  4629. ->setName('install')
  4630. ->setAliases(array('i'))
  4631. ->setDescription('Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.')
  4632. ->setDefinition(array(
  4633. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  4634. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  4635. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4636. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  4637. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  4638. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  4639. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  4640. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4641. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4642. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Do not use, only defined here to catch misuse of the install command.'),
  4643. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  4644. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4645. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4646. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4647. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  4648. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4649. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4650. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Should not be provided, use composer require instead to add a given package to composer.json.'),
  4651. ))
  4652. ->setHelp(
  4653. <<<EOT
  4654. The <info>install</info> command reads the composer.lock file from
  4655. the current directory, processes it, and downloads and installs all the
  4656. libraries and dependencies outlined in that file. If the file does not
  4657. exist it will look for composer.json and do the same.
  4658. <info>php composer.phar install</info>
  4659. Read more at https://getcomposer.org/doc/03-cli.md#install-i
  4660. EOT
  4661. )
  4662. ;
  4663. }
  4664. protected function execute(InputInterface $input, OutputInterface $output)
  4665. {
  4666. $io = $this->getIO();
  4667. if ($input->getOption('dev')) {
  4668. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  4669. }
  4670. if ($input->getOption('no-suggest')) {
  4671. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  4672. }
  4673. if ($args = $input->getArgument('packages')) {
  4674. $io->writeError('<error>Invalid argument '.implode(' ', $args).'. Use "composer require '.implode(' ', $args).'" instead to add packages to your composer.json.</error>');
  4675. return 1;
  4676. }
  4677. if ($input->getOption('no-install')) {
  4678. $io->writeError('<error>Invalid option "--no-install". Use "composer update --no-install" instead if you are trying to update the composer.lock file.</error>');
  4679. return 1;
  4680. }
  4681. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  4682. if ((!$composer->getLocker() || !$composer->getLocker()->isLocked()) && !HttpDownloader::isCurlEnabled()) {
  4683. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  4684. }
  4685. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'install', $input, $output);
  4686. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4687. $install = Installer::create($io, $composer);
  4688. $config = $composer->getConfig();
  4689. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  4690. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  4691. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  4692. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  4693. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  4694. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  4695. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  4696. $install
  4697. ->setDryRun($input->getOption('dry-run'))
  4698. ->setVerbose($input->getOption('verbose'))
  4699. ->setPreferSource($preferSource)
  4700. ->setPreferDist($preferDist)
  4701. ->setDevMode(!$input->getOption('no-dev'))
  4702. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  4703. ->setRunScripts(!$input->getOption('no-scripts'))
  4704. ->setOptimizeAutoloader($optimize)
  4705. ->setClassMapAuthoritative($authoritative)
  4706. ->setApcuAutoloader($apcu, $apcuPrefix)
  4707. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  4708. ;
  4709. if ($input->getOption('no-plugins')) {
  4710. $install->disablePlugins();
  4711. }
  4712. return $install->run();
  4713. }
  4714. }
  4715. <?php
  4716. namespace Composer\Command;
  4717. use Composer\Json\JsonFile;
  4718. use Composer\Plugin\CommandEvent;
  4719. use Composer\Plugin\PluginEvents;
  4720. use Composer\Package\PackageInterface;
  4721. use Composer\Repository\RepositoryInterface;
  4722. use Symfony\Component\Console\Helper\Table;
  4723. use Symfony\Component\Console\Input\InputInterface;
  4724. use Symfony\Component\Console\Input\InputOption;
  4725. use Symfony\Component\Console\Output\OutputInterface;
  4726. use Symfony\Component\Console\Style\SymfonyStyle;
  4727. class LicensesCommand extends BaseCommand
  4728. {
  4729. protected function configure()
  4730. {
  4731. $this
  4732. ->setName('licenses')
  4733. ->setDescription('Shows information about licenses of dependencies.')
  4734. ->setDefinition(array(
  4735. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text, json or summary', 'text'),
  4736. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4737. ))
  4738. ->setHelp(
  4739. <<<EOT
  4740. The license command displays detailed information about the licenses of
  4741. the installed dependencies.
  4742. Read more at https://getcomposer.org/doc/03-cli.md#licenses
  4743. EOT
  4744. )
  4745. ;
  4746. }
  4747. protected function execute(InputInterface $input, OutputInterface $output)
  4748. {
  4749. $composer = $this->getComposer();
  4750. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'licenses', $input, $output);
  4751. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  4752. $root = $composer->getPackage();
  4753. $repo = $composer->getRepositoryManager()->getLocalRepository();
  4754. if ($input->getOption('no-dev')) {
  4755. $packages = $this->filterRequiredPackages($repo, $root);
  4756. } else {
  4757. $packages = $this->appendPackages($repo->getPackages(), array());
  4758. }
  4759. ksort($packages);
  4760. $io = $this->getIO();
  4761. switch ($format = $input->getOption('format')) {
  4762. case 'text':
  4763. $io->write('Name: <comment>'.$root->getPrettyName().'</comment>');
  4764. $io->write('Version: <comment>'.$root->getFullPrettyVersion().'</comment>');
  4765. $io->write('Licenses: <comment>'.(implode(', ', $root->getLicense()) ?: 'none').'</comment>');
  4766. $io->write('Dependencies:');
  4767. $io->write('');
  4768. $table = new Table($output);
  4769. $table->setStyle('compact');
  4770. $tableStyle = $table->getStyle();
  4771. if (method_exists($tableStyle, 'setVerticalBorderChars')) {
  4772. $tableStyle->setVerticalBorderChars('');
  4773. } else {
  4774. $tableStyle->setVerticalBorderChar('');
  4775. }
  4776. $tableStyle->setCellRowContentFormat('%s ');
  4777. $table->setHeaders(array('Name', 'Version', 'License'));
  4778. foreach ($packages as $package) {
  4779. $table->addRow(array(
  4780. $package->getPrettyName(),
  4781. $package->getFullPrettyVersion(),
  4782. implode(', ', $package->getLicense()) ?: 'none',
  4783. ));
  4784. }
  4785. $table->render();
  4786. break;
  4787. case 'json':
  4788. $dependencies = array();
  4789. foreach ($packages as $package) {
  4790. $dependencies[$package->getPrettyName()] = array(
  4791. 'version' => $package->getFullPrettyVersion(),
  4792. 'license' => $package->getLicense(),
  4793. );
  4794. }
  4795. $io->write(JsonFile::encode(array(
  4796. 'name' => $root->getPrettyName(),
  4797. 'version' => $root->getFullPrettyVersion(),
  4798. 'license' => $root->getLicense(),
  4799. 'dependencies' => $dependencies,
  4800. )));
  4801. break;
  4802. case 'summary':
  4803. $usedLicenses = array();
  4804. foreach ($packages as $package) {
  4805. $license = $package->getLicense();
  4806. $licenseName = $license[0];
  4807. if (!isset($usedLicenses[$licenseName])) {
  4808. $usedLicenses[$licenseName] = 0;
  4809. }
  4810. $usedLicenses[$licenseName]++;
  4811. }
  4812. arsort($usedLicenses, SORT_NUMERIC);
  4813. $rows = array();
  4814. foreach ($usedLicenses as $usedLicense => $numberOfDependencies) {
  4815. $rows[] = array($usedLicense, $numberOfDependencies);
  4816. }
  4817. $symfonyIo = new SymfonyStyle($input, $output);
  4818. $symfonyIo->table(
  4819. array('License', 'Number of dependencies'),
  4820. $rows
  4821. );
  4822. break;
  4823. default:
  4824. throw new \RuntimeException(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  4825. }
  4826. return 0;
  4827. }
  4828. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  4829. {
  4830. $requires = array_keys($package->getRequires());
  4831. $packageListNames = array_keys($bucket);
  4832. $packages = array_filter(
  4833. $repo->getPackages(),
  4834. function ($package) use ($requires, $packageListNames) {
  4835. return in_array($package->getName(), $requires) && !in_array($package->getName(), $packageListNames);
  4836. }
  4837. );
  4838. $bucket = $this->appendPackages($packages, $bucket);
  4839. foreach ($packages as $package) {
  4840. $bucket = $this->filterRequiredPackages($repo, $package, $bucket);
  4841. }
  4842. return $bucket;
  4843. }
  4844. public function appendPackages(array $packages, array $bucket)
  4845. {
  4846. foreach ($packages as $package) {
  4847. $bucket[$package->getName()] = $package;
  4848. }
  4849. return $bucket;
  4850. }
  4851. }
  4852. <?php
  4853. namespace Composer\Command;
  4854. use Symfony\Component\Console\Input\InputInterface;
  4855. use Symfony\Component\Console\Input\InputArgument;
  4856. use Symfony\Component\Console\Input\ArrayInput;
  4857. use Symfony\Component\Console\Input\InputOption;
  4858. use Symfony\Component\Console\Output\OutputInterface;
  4859. class OutdatedCommand extends ShowCommand
  4860. {
  4861. protected function configure()
  4862. {
  4863. $this
  4864. ->setName('outdated')
  4865. ->setDescription('Shows a list of installed packages that have updates available, including their latest version.')
  4866. ->setDefinition(array(
  4867. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  4868. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show only packages that are outdated (this is the default, but present here for compat with `show`'),
  4869. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show all installed packages with their latest versions'),
  4870. new InputOption('locked', null, InputOption::VALUE_NONE, 'Shows updates for packages from the lock file, regardless of what is currently in vendor dir'),
  4871. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  4872. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  4873. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  4874. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  4875. 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.'),
  4876. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  4877. ))
  4878. ->setHelp(
  4879. <<<EOT
  4880. The outdated command is just a proxy for `composer show -l`
  4881. The color coding (or signage if you have ANSI colors disabled) for dependency versions is as such:
  4882. - <info>green</info> (=): Dependency is in the latest version and is up to date.
  4883. - <comment>yellow</comment> (~): Dependency has a new version available that includes backwards
  4884. compatibility breaks according to semver, so upgrade when you can but it
  4885. may involve work.
  4886. - <highlight>red</highlight> (!): Dependency has a new version that is semver-compatible and you should upgrade it.
  4887. Read more at https://getcomposer.org/doc/03-cli.md#outdated
  4888. EOT
  4889. )
  4890. ;
  4891. }
  4892. protected function execute(InputInterface $input, OutputInterface $output)
  4893. {
  4894. $args = array(
  4895. 'command' => 'show',
  4896. '--latest' => true,
  4897. );
  4898. if (!$input->getOption('all')) {
  4899. $args['--outdated'] = true;
  4900. }
  4901. if ($input->getOption('direct')) {
  4902. $args['--direct'] = true;
  4903. }
  4904. if ($input->getArgument('package')) {
  4905. $args['package'] = $input->getArgument('package');
  4906. }
  4907. if ($input->getOption('strict')) {
  4908. $args['--strict'] = true;
  4909. }
  4910. if ($input->getOption('minor-only')) {
  4911. $args['--minor-only'] = true;
  4912. }
  4913. if ($input->getOption('locked')) {
  4914. $args['--locked'] = true;
  4915. }
  4916. if ($input->getOption('no-dev')) {
  4917. $args['--no-dev'] = true;
  4918. }
  4919. $args['--format'] = $input->getOption('format');
  4920. $args['--ignore'] = $input->getOption('ignore');
  4921. $input = new ArrayInput($args);
  4922. return $this->getApplication()->run($input, $output);
  4923. }
  4924. public function isProxyCommand()
  4925. {
  4926. return true;
  4927. }
  4928. }
  4929. <?php
  4930. namespace Composer\Command;
  4931. use Symfony\Component\Console\Input\InputInterface;
  4932. use Symfony\Component\Console\Output\OutputInterface;
  4933. class ProhibitsCommand extends BaseDependencyCommand
  4934. {
  4935. protected function configure()
  4936. {
  4937. parent::configure();
  4938. $this
  4939. ->setName('prohibits')
  4940. ->setAliases(array('why-not'))
  4941. ->setDescription('Shows which packages prevent the given package from being installed.')
  4942. ->setHelp(
  4943. <<<EOT
  4944. Displays detailed information about why a package cannot be installed.
  4945. <info>php composer.phar prohibits composer/composer</info>
  4946. Read more at https://getcomposer.org/doc/03-cli.md#prohibits-why-not-
  4947. EOT
  4948. )
  4949. ;
  4950. }
  4951. protected function execute(InputInterface $input, OutputInterface $output)
  4952. {
  4953. return parent::doExecute($input, $output, true);
  4954. }
  4955. }
  4956. <?php
  4957. namespace Composer\Command;
  4958. use Composer\Config\JsonConfigSource;
  4959. use Composer\DependencyResolver\Request;
  4960. use Composer\Installer;
  4961. use Composer\Plugin\CommandEvent;
  4962. use Composer\Plugin\PluginEvents;
  4963. use Composer\Json\JsonFile;
  4964. use Composer\Factory;
  4965. use Symfony\Component\Console\Input\InputInterface;
  4966. use Symfony\Component\Console\Input\InputOption;
  4967. use Symfony\Component\Console\Input\InputArgument;
  4968. use Symfony\Component\Console\Output\OutputInterface;
  4969. use Composer\Package\BasePackage;
  4970. class RemoveCommand extends BaseCommand
  4971. {
  4972. protected function configure()
  4973. {
  4974. $this
  4975. ->setName('remove')
  4976. ->setDescription('Removes a package from the require or require-dev.')
  4977. ->setDefinition(array(
  4978. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Packages that should be removed.'),
  4979. new InputOption('dev', null, InputOption::VALUE_NONE, 'Removes a package from the require-dev section.'),
  4980. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  4981. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  4982. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  4983. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  4984. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  4985. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  4986. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated with explicit dependencies. (Deprecrated, is now default behavior)'),
  4987. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  4988. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  4989. new InputOption('no-update-with-dependencies', null, InputOption::VALUE_NONE, 'Does not allow inherited dependencies to be updated with explicit dependencies.'),
  4990. new InputOption('unused', null, InputOption::VALUE_NONE, 'Remove all packages which are locked but not required by any other package.'),
  4991. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  4992. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  4993. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  4994. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  4995. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  4996. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  4997. ))
  4998. ->setHelp(
  4999. <<<EOT
  5000. The <info>remove</info> command removes a package from the current
  5001. list of installed packages
  5002. <info>php composer.phar remove</info>
  5003. Read more at https://getcomposer.org/doc/03-cli.md#remove
  5004. EOT
  5005. )
  5006. ;
  5007. }
  5008. protected function interact(InputInterface $input, OutputInterface $output)
  5009. {
  5010. if ($input->getOption('unused')) {
  5011. $composer = $this->getComposer();
  5012. $locker = $composer->getLocker();
  5013. if (!$locker->isLocked()) {
  5014. throw new \UnexpectedValueException('A valid composer.lock file is required to run this command with --unused');
  5015. }
  5016. $lockedPackages = $locker->getLockedRepository()->getPackages();
  5017. $required = array();
  5018. foreach (array_merge($composer->getPackage()->getRequires(), $composer->getPackage()->getDevRequires()) as $link) {
  5019. $required[$link->getTarget()] = true;
  5020. }
  5021. do {
  5022. $found = false;
  5023. foreach ($lockedPackages as $index => $package) {
  5024. foreach ($package->getNames() as $name) {
  5025. if (isset($required[$name])) {
  5026. foreach ($package->getRequires() as $link) {
  5027. $required[$link->getTarget()] = true;
  5028. }
  5029. $found = true;
  5030. unset($lockedPackages[$index]);
  5031. break;
  5032. }
  5033. }
  5034. }
  5035. } while ($found);
  5036. $unused = array();
  5037. foreach ($lockedPackages as $package) {
  5038. $unused[] = $package->getName();
  5039. }
  5040. $input->setArgument('packages', array_merge($input->getArgument('packages'), $unused));
  5041. if (!$input->getArgument('packages')) {
  5042. $this->getIO()->writeError('<info>No unused packages to remove</info>');
  5043. $this->setCode(function () {
  5044. return 0;
  5045. });
  5046. }
  5047. }
  5048. }
  5049. protected function execute(InputInterface $input, OutputInterface $output)
  5050. {
  5051. $packages = $input->getArgument('packages');
  5052. $packages = array_map('strtolower', $packages);
  5053. $file = Factory::getComposerFile();
  5054. $jsonFile = new JsonFile($file);
  5055. $composer = $jsonFile->read();
  5056. $composerBackup = file_get_contents($jsonFile->getPath());
  5057. $json = new JsonConfigSource($jsonFile);
  5058. $type = $input->getOption('dev') ? 'require-dev' : 'require';
  5059. $altType = !$input->getOption('dev') ? 'require-dev' : 'require';
  5060. $io = $this->getIO();
  5061. if ($input->getOption('update-with-dependencies')) {
  5062. $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>');
  5063. }
  5064. foreach (array('require', 'require-dev') as $linkType) {
  5065. if (isset($composer[$linkType])) {
  5066. foreach ($composer[$linkType] as $name => $version) {
  5067. $composer[$linkType][strtolower($name)] = $name;
  5068. }
  5069. }
  5070. }
  5071. $dryRun = $input->getOption('dry-run');
  5072. $toRemove = array();
  5073. foreach ($packages as $package) {
  5074. if (isset($composer[$type][$package])) {
  5075. if ($dryRun) {
  5076. $toRemove[$type][] = $composer[$type][$package];
  5077. } else {
  5078. $json->removeLink($type, $composer[$type][$package]);
  5079. }
  5080. } elseif (isset($composer[$altType][$package])) {
  5081. $io->writeError('<warning>' . $composer[$altType][$package] . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5082. if ($io->isInteractive()) {
  5083. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5084. if ($dryRun) {
  5085. $toRemove[$altType][] = $composer[$altType][$package];
  5086. } else {
  5087. $json->removeLink($altType, $composer[$altType][$package]);
  5088. }
  5089. }
  5090. }
  5091. } elseif (isset($composer[$type]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$type]))) {
  5092. foreach ($matches as $matchedPackage) {
  5093. if ($dryRun) {
  5094. $toRemove[$type][] = $matchedPackage;
  5095. } else {
  5096. $json->removeLink($type, $matchedPackage);
  5097. }
  5098. }
  5099. } elseif (isset($composer[$altType]) && $matches = preg_grep(BasePackage::packageNameToRegexp($package), array_keys($composer[$altType]))) {
  5100. foreach ($matches as $matchedPackage) {
  5101. $io->writeError('<warning>' . $matchedPackage . ' could not be found in ' . $type . ' but it is present in ' . $altType . '</warning>');
  5102. if ($io->isInteractive()) {
  5103. if ($io->askConfirmation('Do you want to remove it from ' . $altType . ' [<comment>yes</comment>]? ')) {
  5104. if ($dryRun) {
  5105. $toRemove[$altType][] = $matchedPackage;
  5106. } else {
  5107. $json->removeLink($altType, $matchedPackage);
  5108. }
  5109. }
  5110. }
  5111. }
  5112. } else {
  5113. $io->writeError('<warning>'.$package.' is not required in your composer.json and has not been removed</warning>');
  5114. }
  5115. }
  5116. $io->writeError('<info>'.$file.' has been updated</info>');
  5117. if ($input->getOption('no-update')) {
  5118. return 0;
  5119. }
  5120. $this->resetComposer();
  5121. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5122. if ($dryRun) {
  5123. $rootPackage = $composer->getPackage();
  5124. $links = array(
  5125. 'require' => $rootPackage->getRequires(),
  5126. 'require-dev' => $rootPackage->getDevRequires(),
  5127. );
  5128. foreach ($toRemove as $type => $names) {
  5129. foreach ($names as $name) {
  5130. unset($links[$type][$name]);
  5131. }
  5132. }
  5133. $rootPackage->setRequires($links['require']);
  5134. $rootPackage->setDevRequires($links['require-dev']);
  5135. }
  5136. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'remove', $input, $output);
  5137. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5138. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5139. $install = Installer::create($io, $composer);
  5140. $updateDevMode = !$input->getOption('update-no-dev');
  5141. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5142. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5143. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5144. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5145. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5146. $flags = '';
  5147. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5148. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5149. $flags .= ' --with-all-dependencies';
  5150. } elseif ($input->getOption('no-update-with-dependencies')) {
  5151. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5152. $flags .= ' --with-dependencies';
  5153. }
  5154. $io->writeError('<info>Running composer update '.implode(' ', $packages).$flags.'</info>');
  5155. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5156. $install
  5157. ->setVerbose($input->getOption('verbose'))
  5158. ->setDevMode($updateDevMode)
  5159. ->setOptimizeAutoloader($optimize)
  5160. ->setClassMapAuthoritative($authoritative)
  5161. ->setApcuAutoloader($apcu, $apcuPrefix)
  5162. ->setUpdate(true)
  5163. ->setInstall(!$input->getOption('no-install'))
  5164. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5165. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5166. ->setRunScripts(!$input->getOption('no-scripts'))
  5167. ->setDryRun($dryRun)
  5168. ;
  5169. if ($composer->getLocker()->isLocked()) {
  5170. $install->setUpdateAllowList($packages);
  5171. }
  5172. $status = $install->run();
  5173. if ($status !== 0) {
  5174. $io->writeError("\n".'<error>Removal failed, reverting '.$file.' to its original content.</error>');
  5175. file_put_contents($jsonFile->getPath(), $composerBackup);
  5176. }
  5177. if (!$dryRun) {
  5178. foreach ($packages as $package) {
  5179. if ($composer->getRepositoryManager()->getLocalRepository()->findPackages($package)) {
  5180. $io->writeError('<error>Removal failed, '.$package.' is still present, it may be required by another package. See `composer why '.$package.'`.</error>');
  5181. return 2;
  5182. }
  5183. }
  5184. }
  5185. return $status;
  5186. }
  5187. }
  5188. <?php
  5189. namespace Composer\Command;
  5190. use Composer\DependencyResolver\Request;
  5191. use Symfony\Component\Console\Input\InputInterface;
  5192. use Symfony\Component\Console\Input\InputArgument;
  5193. use Symfony\Component\Console\Input\InputOption;
  5194. use Symfony\Component\Console\Output\OutputInterface;
  5195. use Composer\Factory;
  5196. use Composer\Installer;
  5197. use Composer\Json\JsonFile;
  5198. use Composer\Json\JsonManipulator;
  5199. use Composer\Package\Version\VersionParser;
  5200. use Composer\Package\Loader\ArrayLoader;
  5201. use Composer\Package\BasePackage;
  5202. use Composer\Plugin\CommandEvent;
  5203. use Composer\Plugin\PluginEvents;
  5204. use Composer\Repository\CompositeRepository;
  5205. use Composer\Repository\PlatformRepository;
  5206. use Composer\IO\IOInterface;
  5207. use Composer\Util\Silencer;
  5208. class RequireCommand extends InitCommand
  5209. {
  5210. private $newlyCreated;
  5211. private $firstRequire;
  5212. private $json;
  5213. private $file;
  5214. private $composerBackup;
  5215. private $lock;
  5216. private $lockBackup;
  5217. protected function configure()
  5218. {
  5219. $this
  5220. ->setName('require')
  5221. ->setDescription('Adds required packages to your composer.json and installs them.')
  5222. ->setDefinition(array(
  5223. 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"'),
  5224. new InputOption('dev', null, InputOption::VALUE_NONE, 'Add requirement to require-dev.'),
  5225. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  5226. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  5227. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  5228. new InputOption('fixed', null, InputOption::VALUE_NONE, 'Write fixed version to the composer.json.'),
  5229. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  5230. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5231. new InputOption('no-update', null, InputOption::VALUE_NONE, 'Disables the automatic update of the dependencies (implies --no-install).'),
  5232. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  5233. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  5234. new InputOption('update-no-dev', null, InputOption::VALUE_NONE, 'Run the dependency update with the --no-dev option.'),
  5235. new InputOption('update-with-dependencies', 'w', InputOption::VALUE_NONE, 'Allows inherited dependencies to be updated, except those that are root requirements.'),
  5236. new InputOption('update-with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Allows all inherited dependencies to be updated, including those that are root requirements.'),
  5237. new InputOption('with-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-dependencies'),
  5238. new InputOption('with-all-dependencies', null, InputOption::VALUE_NONE, 'Alias for --update-with-all-dependencies'),
  5239. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  5240. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  5241. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  5242. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  5243. new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages when adding/updating a new dependency'),
  5244. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump'),
  5245. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  5246. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  5247. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  5248. ))
  5249. ->setHelp(
  5250. <<<EOT
  5251. The require command adds required packages to your composer.json and installs them.
  5252. If you do not specify a package, composer will prompt you to search for a package, and given results, provide a list of
  5253. matches to require.
  5254. If you do not specify a version constraint, composer will choose a suitable one based on the available package versions.
  5255. If you do not want to install the new dependencies immediately you can call it with --no-update
  5256. Read more at https://getcomposer.org/doc/03-cli.md#require
  5257. EOT
  5258. )
  5259. ;
  5260. }
  5261. protected function execute(InputInterface $input, OutputInterface $output)
  5262. {
  5263. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  5264. pcntl_async_signals(true);
  5265. pcntl_signal(SIGINT, array($this, 'revertComposerFile'));
  5266. pcntl_signal(SIGTERM, array($this, 'revertComposerFile'));
  5267. pcntl_signal(SIGHUP, array($this, 'revertComposerFile'));
  5268. }
  5269. $this->file = Factory::getComposerFile();
  5270. $io = $this->getIO();
  5271. if ($input->getOption('no-suggest')) {
  5272. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  5273. }
  5274. $this->newlyCreated = !file_exists($this->file);
  5275. if ($this->newlyCreated && !file_put_contents($this->file, "{\n}\n")) {
  5276. $io->writeError('<error>'.$this->file.' could not be created.</error>');
  5277. return 1;
  5278. }
  5279. if (!is_readable($this->file) && false === Silencer::call('file_get_contents', $this->file)) {
  5280. $io->writeError('<error>'.$this->file.' is not readable.</error>');
  5281. return 1;
  5282. }
  5283. if (filesize($this->file) === 0) {
  5284. file_put_contents($this->file, "{\n}\n");
  5285. }
  5286. $this->json = new JsonFile($this->file);
  5287. $this->lock = Factory::getLockFile($this->file);
  5288. $this->composerBackup = file_get_contents($this->json->getPath());
  5289. $this->lockBackup = file_exists($this->lock) ? file_get_contents($this->lock) : null;
  5290. if (!is_writable($this->file) && !Silencer::call('file_put_contents', $this->file, $this->composerBackup)) {
  5291. $io->writeError('<error>'.$this->file.' is not writable.</error>');
  5292. return 1;
  5293. }
  5294. if ($input->getOption('fixed') === true) {
  5295. $config = $this->json->read();
  5296. $packageType = empty($config['type']) ? 'library' : $config['type'];
  5297. if ($packageType !== 'project') {
  5298. $io->writeError('<error>"--fixed" option is allowed for "project" package types only to prevent possible misuses.</error>');
  5299. if (empty($config['type'])) {
  5300. $io->writeError('<error>If your package is not library, you should explicitly specify "type" parameter in composer.json.</error>');
  5301. }
  5302. return 1;
  5303. }
  5304. }
  5305. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5306. $repos = $composer->getRepositoryManager()->getRepositories();
  5307. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  5308. $this->repos = new CompositeRepository(array_merge(
  5309. array($platformRepo = new PlatformRepository(array(), $platformOverrides)),
  5310. $repos
  5311. ));
  5312. if ($composer->getPackage()->getPreferStable()) {
  5313. $preferredStability = 'stable';
  5314. } else {
  5315. $preferredStability = $composer->getPackage()->getMinimumStability();
  5316. }
  5317. try {
  5318. $requirements = $this->determineRequirements(
  5319. $input,
  5320. $output,
  5321. $input->getArgument('packages'),
  5322. $platformRepo,
  5323. $preferredStability,
  5324. !$input->getOption('no-update'),
  5325. $input->getOption('fixed')
  5326. );
  5327. } catch (\Exception $e) {
  5328. if ($this->newlyCreated) {
  5329. throw new \RuntimeException('No composer.json present in the current directory ('.$this->file.'), this may be the cause of the following exception.', 0, $e);
  5330. }
  5331. throw $e;
  5332. }
  5333. $requireKey = $input->getOption('dev') ? 'require-dev' : 'require';
  5334. $removeKey = $input->getOption('dev') ? 'require' : 'require-dev';
  5335. $requirements = $this->formatRequirements($requirements);
  5336. $versionParser = new VersionParser();
  5337. foreach ($requirements as $package => $constraint) {
  5338. if (strtolower($package) === $composer->getPackage()->getName()) {
  5339. $io->writeError(sprintf('<error>Root package \'%s\' cannot require itself in its composer.json</error>', $package));
  5340. return 1;
  5341. }
  5342. $versionParser->parseConstraints($constraint);
  5343. }
  5344. $sortPackages = $input->getOption('sort-packages') || $composer->getConfig()->get('sort-packages');
  5345. $this->firstRequire = $this->newlyCreated;
  5346. if (!$this->firstRequire) {
  5347. $composerDefinition = $this->json->read();
  5348. if (empty($composerDefinition['require']) && empty($composerDefinition['require-dev'])) {
  5349. $this->firstRequire = true;
  5350. }
  5351. }
  5352. if (!$input->getOption('dry-run') && !$this->updateFileCleanly($this->json, $requirements, $requireKey, $removeKey, $sortPackages)) {
  5353. $composerDefinition = $this->json->read();
  5354. foreach ($requirements as $package => $version) {
  5355. $composerDefinition[$requireKey][$package] = $version;
  5356. unset($composerDefinition[$removeKey][$package]);
  5357. if (isset($composerDefinition[$removeKey]) && count($composerDefinition[$removeKey]) === 0) {
  5358. unset($composerDefinition[$removeKey]);
  5359. }
  5360. }
  5361. $this->json->write($composerDefinition);
  5362. }
  5363. $io->writeError('<info>'.$this->file.' has been '.($this->newlyCreated ? 'created' : 'updated').'</info>');
  5364. if ($input->getOption('no-update')) {
  5365. return 0;
  5366. }
  5367. try {
  5368. return $this->doUpdate($input, $output, $io, $requirements, $requireKey, $removeKey);
  5369. } catch (\Exception $e) {
  5370. $this->revertComposerFile(false);
  5371. throw $e;
  5372. }
  5373. }
  5374. private function doUpdate(InputInterface $input, OutputInterface $output, IOInterface $io, array $requirements, $requireKey, $removeKey)
  5375. {
  5376. $this->resetComposer();
  5377. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  5378. if ($input->getOption('dry-run')) {
  5379. $rootPackage = $composer->getPackage();
  5380. $links = array(
  5381. 'require' => $rootPackage->getRequires(),
  5382. 'require-dev' => $rootPackage->getDevRequires(),
  5383. );
  5384. $loader = new ArrayLoader();
  5385. $newLinks = $loader->parseLinks($rootPackage->getName(), $rootPackage->getPrettyVersion(), BasePackage::$supportedLinkTypes[$requireKey]['description'], $requirements);
  5386. $links[$requireKey] = array_merge($links[$requireKey], $newLinks);
  5387. foreach ($requirements as $package => $constraint) {
  5388. unset($links[$removeKey][$package]);
  5389. }
  5390. $rootPackage->setRequires($links['require']);
  5391. $rootPackage->setDevRequires($links['require-dev']);
  5392. }
  5393. $updateDevMode = !$input->getOption('update-no-dev');
  5394. $optimize = $input->getOption('optimize-autoloader') || $composer->getConfig()->get('optimize-autoloader');
  5395. $authoritative = $input->getOption('classmap-authoritative') || $composer->getConfig()->get('classmap-authoritative');
  5396. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  5397. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $composer->getConfig()->get('apcu-autoloader');
  5398. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  5399. $flags = '';
  5400. if ($input->getOption('update-with-all-dependencies') || $input->getOption('with-all-dependencies')) {
  5401. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  5402. $flags .= ' --with-all-dependencies';
  5403. } elseif ($input->getOption('update-with-dependencies') || $input->getOption('with-dependencies')) {
  5404. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  5405. $flags .= ' --with-dependencies';
  5406. }
  5407. $io->writeError('<info>Running composer update '.implode(' ', array_keys($requirements)).$flags.'</info>');
  5408. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'require', $input, $output);
  5409. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5410. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  5411. $install = Installer::create($io, $composer);
  5412. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  5413. $install
  5414. ->setDryRun($input->getOption('dry-run'))
  5415. ->setVerbose($input->getOption('verbose'))
  5416. ->setPreferSource($input->getOption('prefer-source'))
  5417. ->setPreferDist($input->getOption('prefer-dist'))
  5418. ->setDevMode($updateDevMode)
  5419. ->setRunScripts(!$input->getOption('no-scripts'))
  5420. ->setOptimizeAutoloader($optimize)
  5421. ->setClassMapAuthoritative($authoritative)
  5422. ->setApcuAutoloader($apcu, $apcuPrefix)
  5423. ->setUpdate(true)
  5424. ->setInstall(!$input->getOption('no-install'))
  5425. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  5426. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  5427. ->setPreferStable($input->getOption('prefer-stable'))
  5428. ->setPreferLowest($input->getOption('prefer-lowest'))
  5429. ;
  5430. if (!$this->firstRequire && $composer->getLocker()->isLocked()) {
  5431. $install->setUpdateAllowList(array_keys($requirements));
  5432. }
  5433. $status = $install->run();
  5434. if ($status !== 0) {
  5435. $this->revertComposerFile(false);
  5436. }
  5437. return $status;
  5438. }
  5439. private function updateFileCleanly($json, array $new, $requireKey, $removeKey, $sortPackages)
  5440. {
  5441. $contents = file_get_contents($json->getPath());
  5442. $manipulator = new JsonManipulator($contents);
  5443. foreach ($new as $package => $constraint) {
  5444. if (!$manipulator->addLink($requireKey, $package, $constraint, $sortPackages)) {
  5445. return false;
  5446. }
  5447. if (!$manipulator->removeSubNode($removeKey, $package)) {
  5448. return false;
  5449. }
  5450. }
  5451. $manipulator->removeMainKeyIfEmpty($removeKey);
  5452. file_put_contents($json->getPath(), $manipulator->getContents());
  5453. return true;
  5454. }
  5455. protected function interact(InputInterface $input, OutputInterface $output)
  5456. {
  5457. return;
  5458. }
  5459. public function revertComposerFile($hardExit = true)
  5460. {
  5461. $io = $this->getIO();
  5462. if ($this->newlyCreated) {
  5463. $io->writeError("\n".'<error>Installation failed, deleting '.$this->file.'.</error>');
  5464. unlink($this->json->getPath());
  5465. if (file_exists($this->lock)) {
  5466. unlink($this->lock);
  5467. }
  5468. } else {
  5469. $msg = ' to its ';
  5470. if ($this->lockBackup) {
  5471. $msg = ' and '.$this->lock.' to their ';
  5472. }
  5473. $io->writeError("\n".'<error>Installation failed, reverting '.$this->file.$msg.'original content.</error>');
  5474. file_put_contents($this->json->getPath(), $this->composerBackup);
  5475. if ($this->lockBackup) {
  5476. file_put_contents($this->lock, $this->lockBackup);
  5477. }
  5478. }
  5479. if ($hardExit) {
  5480. exit(1);
  5481. }
  5482. }
  5483. }
  5484. <?php
  5485. namespace Composer\Command;
  5486. use Composer\Script\Event as ScriptEvent;
  5487. use Composer\Script\ScriptEvents;
  5488. use Composer\Util\ProcessExecutor;
  5489. use Symfony\Component\Console\Input\InputInterface;
  5490. use Symfony\Component\Console\Input\InputOption;
  5491. use Symfony\Component\Console\Input\InputArgument;
  5492. use Symfony\Component\Console\Output\OutputInterface;
  5493. class RunScriptCommand extends BaseCommand
  5494. {
  5495. protected $scriptEvents = array(
  5496. ScriptEvents::PRE_INSTALL_CMD,
  5497. ScriptEvents::POST_INSTALL_CMD,
  5498. ScriptEvents::PRE_UPDATE_CMD,
  5499. ScriptEvents::POST_UPDATE_CMD,
  5500. ScriptEvents::PRE_STATUS_CMD,
  5501. ScriptEvents::POST_STATUS_CMD,
  5502. ScriptEvents::POST_ROOT_PACKAGE_INSTALL,
  5503. ScriptEvents::POST_CREATE_PROJECT_CMD,
  5504. ScriptEvents::PRE_ARCHIVE_CMD,
  5505. ScriptEvents::POST_ARCHIVE_CMD,
  5506. ScriptEvents::PRE_AUTOLOAD_DUMP,
  5507. ScriptEvents::POST_AUTOLOAD_DUMP,
  5508. );
  5509. protected function configure()
  5510. {
  5511. $this
  5512. ->setName('run-script')
  5513. ->setAliases(array('run'))
  5514. ->setDescription('Runs the scripts defined in composer.json.')
  5515. ->setDefinition(array(
  5516. new InputArgument('script', InputArgument::OPTIONAL, 'Script name to run.'),
  5517. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5518. new InputOption('timeout', null, InputOption::VALUE_REQUIRED, 'Sets script timeout in seconds, or 0 for never.'),
  5519. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  5520. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  5521. new InputOption('list', 'l', InputOption::VALUE_NONE, 'List scripts.'),
  5522. ))
  5523. ->setHelp(
  5524. <<<EOT
  5525. The <info>run-script</info> command runs scripts defined in composer.json:
  5526. <info>php composer.phar run-script post-update-cmd</info>
  5527. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  5528. EOT
  5529. )
  5530. ;
  5531. }
  5532. protected function execute(InputInterface $input, OutputInterface $output)
  5533. {
  5534. if ($input->getOption('list')) {
  5535. return $this->listScripts($output);
  5536. }
  5537. if (!$input->getArgument('script')) {
  5538. throw new \RuntimeException('Missing required argument "script"');
  5539. }
  5540. $script = $input->getArgument('script');
  5541. if (!in_array($script, $this->scriptEvents)) {
  5542. if (defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  5543. throw new \InvalidArgumentException(sprintf('Script "%s" cannot be run with this command', $script));
  5544. }
  5545. }
  5546. $composer = $this->getComposer();
  5547. $devMode = $input->getOption('dev') || !$input->getOption('no-dev');
  5548. $event = new ScriptEvent($script, $composer, $this->getIO(), $devMode);
  5549. $hasListeners = $composer->getEventDispatcher()->hasEventListeners($event);
  5550. if (!$hasListeners) {
  5551. throw new \InvalidArgumentException(sprintf('Script "%s" is not defined in this package', $script));
  5552. }
  5553. $args = $input->getArgument('args');
  5554. if (null !== $timeout = $input->getOption('timeout')) {
  5555. if (!ctype_digit($timeout)) {
  5556. throw new \RuntimeException('Timeout value must be numeric and positive if defined, or 0 for forever');
  5557. }
  5558. ProcessExecutor::setTimeout((int) $timeout);
  5559. }
  5560. return $composer->getEventDispatcher()->dispatchScript($script, $devMode, $args);
  5561. }
  5562. protected function listScripts(OutputInterface $output)
  5563. {
  5564. $scripts = $this->getComposer()->getPackage()->getScripts();
  5565. if (!count($scripts)) {
  5566. return 0;
  5567. }
  5568. $io = $this->getIO();
  5569. $io->writeError('<info>scripts:</info>');
  5570. $table = array();
  5571. foreach ($scripts as $name => $script) {
  5572. $description = '';
  5573. try {
  5574. $cmd = $this->getApplication()->find($name);
  5575. if ($cmd instanceof ScriptAliasCommand) {
  5576. $description = $cmd->getDescription();
  5577. }
  5578. } catch (\Symfony\Component\Console\Exception\CommandNotFoundException $e) {
  5579. }
  5580. $table[] = array(' '.$name, $description);
  5581. }
  5582. $this->renderTable($table, $output);
  5583. return 0;
  5584. }
  5585. }
  5586. <?php
  5587. namespace Composer\Command;
  5588. use Symfony\Component\Console\Input\InputInterface;
  5589. use Symfony\Component\Console\Input\InputOption;
  5590. use Symfony\Component\Console\Input\InputArgument;
  5591. use Symfony\Component\Console\Output\OutputInterface;
  5592. class ScriptAliasCommand extends BaseCommand
  5593. {
  5594. private $script;
  5595. private $description;
  5596. public function __construct($script, $description)
  5597. {
  5598. $this->script = $script;
  5599. $this->description = empty($description) ? 'Runs the '.$script.' script as defined in composer.json.' : $description;
  5600. parent::__construct();
  5601. }
  5602. protected function configure()
  5603. {
  5604. $this
  5605. ->setName($this->script)
  5606. ->setDescription($this->description)
  5607. ->setDefinition(array(
  5608. new InputOption('dev', null, InputOption::VALUE_NONE, 'Sets the dev mode.'),
  5609. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables the dev mode.'),
  5610. new InputArgument('args', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, ''),
  5611. ))
  5612. ->setHelp(
  5613. <<<EOT
  5614. The <info>run-script</info> command runs scripts defined in composer.json:
  5615. <info>php composer.phar run-script post-update-cmd</info>
  5616. Read more at https://getcomposer.org/doc/03-cli.md#run-script
  5617. EOT
  5618. )
  5619. ;
  5620. }
  5621. protected function execute(InputInterface $input, OutputInterface $output)
  5622. {
  5623. $composer = $this->getComposer();
  5624. $args = $input->getArguments();
  5625. return $composer->getEventDispatcher()->dispatchScript($this->script, $input->getOption('dev') || !$input->getOption('no-dev'), $args['args']);
  5626. }
  5627. }
  5628. <?php
  5629. namespace Composer\Command;
  5630. use Composer\Factory;
  5631. use Symfony\Component\Console\Input\InputInterface;
  5632. use Symfony\Component\Console\Input\InputArgument;
  5633. use Symfony\Component\Console\Input\InputOption;
  5634. use Symfony\Component\Console\Output\OutputInterface;
  5635. use Composer\Repository\CompositeRepository;
  5636. use Composer\Repository\PlatformRepository;
  5637. use Composer\Repository\RepositoryInterface;
  5638. use Composer\Plugin\CommandEvent;
  5639. use Composer\Plugin\PluginEvents;
  5640. class SearchCommand extends BaseCommand
  5641. {
  5642. protected $matches;
  5643. protected $lowMatches = array();
  5644. protected $tokens;
  5645. protected $output;
  5646. protected $onlyName;
  5647. protected function configure()
  5648. {
  5649. $this
  5650. ->setName('search')
  5651. ->setDescription('Searches for packages.')
  5652. ->setDefinition(array(
  5653. new InputOption('only-name', 'N', InputOption::VALUE_NONE, 'Search only in name'),
  5654. new InputOption('type', 't', InputOption::VALUE_REQUIRED, 'Search for a specific package type'),
  5655. new InputArgument('tokens', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'tokens to search for'),
  5656. ))
  5657. ->setHelp(
  5658. <<<EOT
  5659. The search command searches for packages by its name
  5660. <info>php composer.phar search symfony composer</info>
  5661. Read more at https://getcomposer.org/doc/03-cli.md#search
  5662. EOT
  5663. )
  5664. ;
  5665. }
  5666. protected function execute(InputInterface $input, OutputInterface $output)
  5667. {
  5668. $platformRepo = new PlatformRepository;
  5669. $io = $this->getIO();
  5670. if (!($composer = $this->getComposer(false))) {
  5671. $composer = Factory::create($this->getIO(), array(), $input->hasParameterOption('--no-plugins'));
  5672. }
  5673. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  5674. $installedRepo = new CompositeRepository(array($localRepo, $platformRepo));
  5675. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  5676. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'search', $input, $output);
  5677. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  5678. $onlyName = $input->getOption('only-name');
  5679. $type = $input->getOption('type') ?: null;
  5680. $flags = $onlyName ? RepositoryInterface::SEARCH_NAME : RepositoryInterface::SEARCH_FULLTEXT;
  5681. $results = $repos->search(implode(' ', $input->getArgument('tokens')), $flags, $type);
  5682. foreach ($results as $result) {
  5683. $io->write($result['name'] . (isset($result['description']) ? ' '. $result['description'] : ''));
  5684. }
  5685. return 0;
  5686. }
  5687. }
  5688. <?php
  5689. namespace Composer\Command;
  5690. use Composer\Composer;
  5691. use Composer\Factory;
  5692. use Composer\Config;
  5693. use Composer\Util\Filesystem;
  5694. use Composer\Util\Platform;
  5695. use Composer\SelfUpdate\Keys;
  5696. use Composer\SelfUpdate\Versions;
  5697. use Composer\IO\IOInterface;
  5698. use Composer\Downloader\FilesystemException;
  5699. use Composer\Downloader\TransportException;
  5700. use Symfony\Component\Console\Input\InputInterface;
  5701. use Symfony\Component\Console\Input\InputOption;
  5702. use Symfony\Component\Console\Input\InputArgument;
  5703. use Symfony\Component\Console\Output\OutputInterface;
  5704. use Symfony\Component\Finder\Finder;
  5705. class SelfUpdateCommand extends BaseCommand
  5706. {
  5707. const HOMEPAGE = 'getcomposer.org';
  5708. const OLD_INSTALL_EXT = '-old.phar';
  5709. protected function configure()
  5710. {
  5711. $this
  5712. ->setName('self-update')
  5713. ->setAliases(array('selfupdate'))
  5714. ->setDescription('Updates composer.phar to the latest version.')
  5715. ->setDefinition(array(
  5716. new InputOption('rollback', 'r', InputOption::VALUE_NONE, 'Revert to an older installation of composer'),
  5717. 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'),
  5718. new InputArgument('version', InputArgument::OPTIONAL, 'The version to update to'),
  5719. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  5720. new InputOption('update-keys', null, InputOption::VALUE_NONE, 'Prompt user for a key update'),
  5721. new InputOption('stable', null, InputOption::VALUE_NONE, 'Force an update to the stable channel'),
  5722. new InputOption('preview', null, InputOption::VALUE_NONE, 'Force an update to the preview channel'),
  5723. new InputOption('snapshot', null, InputOption::VALUE_NONE, 'Force an update to the snapshot channel'),
  5724. new InputOption('1', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 1.x versions'),
  5725. new InputOption('2', null, InputOption::VALUE_NONE, 'Force an update to the stable channel, but only use 2.x versions'),
  5726. new InputOption('set-channel-only', null, InputOption::VALUE_NONE, 'Only store the channel as the default one and then exit'),
  5727. ))
  5728. ->setHelp(
  5729. <<<EOT
  5730. The <info>self-update</info> command checks getcomposer.org for newer
  5731. versions of composer and if found, installs the latest.
  5732. <info>php composer.phar self-update</info>
  5733. Read more at https://getcomposer.org/doc/03-cli.md#self-update-selfupdate-
  5734. EOT
  5735. )
  5736. ;
  5737. }
  5738. protected function execute(InputInterface $input, OutputInterface $output)
  5739. {
  5740. $config = Factory::createConfig();
  5741. if ($config->get('disable-tls') === true) {
  5742. $baseUrl = 'http://' . self::HOMEPAGE;
  5743. } else {
  5744. $baseUrl = 'https://' . self::HOMEPAGE;
  5745. }
  5746. $io = $this->getIO();
  5747. $httpDownloader = Factory::createHttpDownloader($io, $config);
  5748. $versionsUtil = new Versions($config, $httpDownloader);
  5749. $requestedChannel = null;
  5750. foreach (Versions::$channels as $channel) {
  5751. if ($input->getOption($channel)) {
  5752. $requestedChannel = $channel;
  5753. $versionsUtil->setChannel($channel);
  5754. break;
  5755. }
  5756. }
  5757. if ($input->getOption('set-channel-only')) {
  5758. return 0;
  5759. }
  5760. $cacheDir = $config->get('cache-dir');
  5761. $rollbackDir = $config->get('data-dir');
  5762. $home = $config->get('home');
  5763. $localFilename = realpath($_SERVER['argv'][0]) ?: $_SERVER['argv'][0];
  5764. if ($input->getOption('update-keys')) {
  5765. return $this->fetchKeys($io, $config);
  5766. }
  5767. if (!file_exists($localFilename)) {
  5768. throw new FilesystemException('Composer update failed: the "'.$localFilename.'" is not accessible');
  5769. }
  5770. $tmpDir = is_writable(dirname($localFilename)) ? dirname($localFilename) : $cacheDir;
  5771. if (!is_writable($tmpDir)) {
  5772. throw new FilesystemException('Composer update failed: the "'.$tmpDir.'" directory used to download the temp file could not be written');
  5773. }
  5774. if (function_exists('posix_getpwuid') && function_exists('posix_geteuid')) {
  5775. $composeUser = posix_getpwuid(posix_geteuid());
  5776. $homeOwner = posix_getpwuid(fileowner($home));
  5777. if (isset($composeUser['name'], $homeOwner['name']) && $composeUser['name'] !== $homeOwner['name']) {
  5778. $io->writeError('<warning>You are running Composer as "'.$composeUser['name'].'", while "'.$home.'" is owned by "'.$homeOwner['name'].'"</warning>');
  5779. }
  5780. }
  5781. if ($input->getOption('rollback')) {
  5782. return $this->rollback($output, $rollbackDir, $localFilename);
  5783. }
  5784. $latest = $versionsUtil->getLatest();
  5785. $latestStable = $versionsUtil->getLatest('stable');
  5786. try {
  5787. $latestPreview = $versionsUtil->getLatest('preview');
  5788. } catch (\UnexpectedValueException $e) {
  5789. $latestPreview = $latestStable;
  5790. }
  5791. $latestVersion = $latest['version'];
  5792. $updateVersion = $input->getArgument('version') ?: $latestVersion;
  5793. $currentMajorVersion = preg_replace('{^(\d+).*}', '$1', Composer::getVersion());
  5794. $updateMajorVersion = preg_replace('{^(\d+).*}', '$1', $updateVersion);
  5795. $previewMajorVersion = preg_replace('{^(\d+).*}', '$1', $latestPreview['version']);
  5796. if ($versionsUtil->getChannel() === 'stable' && !$input->getArgument('version')) {
  5797. if ($currentMajorVersion < $updateMajorVersion) {
  5798. $skippedVersion = $updateVersion;
  5799. $versionsUtil->setChannel($currentMajorVersion);
  5800. $latest = $versionsUtil->getLatest();
  5801. $latestStable = $versionsUtil->getLatest('stable');
  5802. $latestVersion = $latest['version'];
  5803. $updateVersion = $latestVersion;
  5804. $io->writeError('<warning>A new stable major version of Composer is available ('.$skippedVersion.'), run "composer self-update --'.$updateMajorVersion.'" to update to it. See also https://getcomposer.org/'.$updateMajorVersion.'</warning>');
  5805. } elseif ($currentMajorVersion < $previewMajorVersion) {
  5806. $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>');
  5807. }
  5808. }
  5809. if ($requestedChannel && is_numeric($requestedChannel) && strpos($latestStable['version'], $requestedChannel) !== 0) {
  5810. $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>');
  5811. }
  5812. if (preg_match('{^[0-9a-f]{40}$}', $updateVersion) && $updateVersion !== $latestVersion) {
  5813. $io->writeError('<error>You can not update to a specific SHA-1 as those phars are not available for download</error>');
  5814. return 1;
  5815. }
  5816. $channelString = $versionsUtil->getChannel();
  5817. if (is_numeric($channelString)) {
  5818. $channelString .= '.x';
  5819. }
  5820. if (Composer::VERSION === $updateVersion) {
  5821. $io->writeError(
  5822. sprintf(
  5823. '<info>You are already using the latest available Composer version %s (%s channel).</info>',
  5824. $updateVersion,
  5825. $channelString
  5826. )
  5827. );
  5828. if ($input->getOption('clean-backups')) {
  5829. $this->cleanBackups($rollbackDir, $this->getLastBackupVersion($rollbackDir));
  5830. }
  5831. return 0;
  5832. }
  5833. $tempFilename = $tmpDir . '/' . basename($localFilename, '.phar').'-temp.phar';
  5834. $backupFile = sprintf(
  5835. '%s/%s-%s%s',
  5836. $rollbackDir,
  5837. strtr(Composer::RELEASE_DATE, ' :', '_-'),
  5838. preg_replace('{^([0-9a-f]{7})[0-9a-f]{33}$}', '$1', Composer::VERSION),
  5839. self::OLD_INSTALL_EXT
  5840. );
  5841. $updatingToTag = !preg_match('{^[0-9a-f]{40}$}', $updateVersion);
  5842. $io->write(sprintf("Upgrading to version <info>%s</info> (%s channel).", $updateVersion, $channelString));
  5843. $remoteFilename = $baseUrl . ($updatingToTag ? "/download/{$updateVersion}/composer.phar" : '/composer.phar');
  5844. try {
  5845. $signature = $httpDownloader->get($remoteFilename.'.sig')->getBody();
  5846. } catch (TransportException $e) {
  5847. if ($e->getStatusCode() === 404) {
  5848. throw new \InvalidArgumentException('Version "'.$updateVersion.'" could not be found.', 0, $e);
  5849. }
  5850. throw $e;
  5851. }
  5852. $io->writeError(' ', false);
  5853. $httpDownloader->copy($remoteFilename, $tempFilename);
  5854. $io->writeError('');
  5855. if (!file_exists($tempFilename) || !$signature) {
  5856. $io->writeError('<error>The download of the new composer version failed for an unexpected reason</error>');
  5857. return 1;
  5858. }
  5859. if (!extension_loaded('openssl') && $config->get('disable-tls')) {
  5860. $io->writeError('<warning>Skipping phar signature verification as you have disabled OpenSSL via config.disable-tls</warning>');
  5861. } else {
  5862. if (!extension_loaded('openssl')) {
  5863. throw new \RuntimeException('The openssl extension is required for phar signatures to be verified but it is not available. '
  5864. . '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.');
  5865. }
  5866. $sigFile = 'file://'.$home.'/' . ($updatingToTag ? 'keys.tags.pub' : 'keys.dev.pub');
  5867. if (!file_exists($sigFile)) {
  5868. file_put_contents(
  5869. $home.'/keys.dev.pub',
  5870. <<<DEVPUBKEY
  5871. -----BEGIN PUBLIC KEY-----
  5872. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnBDHjZS6e0ZMoK3xTD7f
  5873. FNCzlXjX/Aie2dit8QXA03pSrOTbaMnxON3hUL47Lz3g1SC6YJEMVHr0zYq4elWi
  5874. i3ecFEgzLcj+pZM5X6qWu2Ozz4vWx3JYo1/a/HYdOuW9e3lwS8VtS0AVJA+U8X0A
  5875. hZnBmGpltHhO8hPKHgkJtkTUxCheTcbqn4wGHl8Z2SediDcPTLwqezWKUfrYzu1f
  5876. o/j3WFwFs6GtK4wdYtiXr+yspBZHO3y1udf8eFFGcb2V3EaLOrtfur6XQVizjOuk
  5877. 8lw5zzse1Qp/klHqbDRsjSzJ6iL6F4aynBc6Euqt/8ccNAIz0rLjLhOraeyj4eNn
  5878. 8iokwMKiXpcrQLTKH+RH1JCuOVxQ436bJwbSsp1VwiqftPQieN+tzqy+EiHJJmGf
  5879. TBAbWcncicCk9q2md+AmhNbvHO4PWbbz9TzC7HJb460jyWeuMEvw3gNIpEo2jYa9
  5880. pMV6cVqnSa+wOc0D7pC9a6bne0bvLcm3S+w6I5iDB3lZsb3A9UtRiSP7aGSo7D72
  5881. 8tC8+cIgZcI7k9vjvOqH+d7sdOU2yPCnRY6wFh62/g8bDnUpr56nZN1G89GwM4d4
  5882. r/TU7BQQIzsZgAiqOGXvVklIgAMiV0iucgf3rNBLjjeNEwNSTTG9F0CtQ+7JLwaE
  5883. wSEuAuRm+pRqi8BRnQ/GKUcCAwEAAQ==
  5884. -----END PUBLIC KEY-----
  5885. DEVPUBKEY
  5886. );
  5887. file_put_contents(
  5888. $home.'/keys.tags.pub',
  5889. <<<TAGSPUBKEY
  5890. -----BEGIN PUBLIC KEY-----
  5891. MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0Vi/2K6apCVj76nCnCl2
  5892. MQUPdK+A9eqkYBacXo2wQBYmyVlXm2/n/ZsX6pCLYPQTHyr5jXbkQzBw8SKqPdlh
  5893. vA7NpbMeNCz7wP/AobvUXM8xQuXKbMDTY2uZ4O7sM+PfGbptKPBGLe8Z8d2sUnTO
  5894. bXtX6Lrj13wkRto7st/w/Yp33RHe9SlqkiiS4MsH1jBkcIkEHsRaveZzedUaxY0M
  5895. mba0uPhGUInpPzEHwrYqBBEtWvP97t2vtfx8I5qv28kh0Y6t+jnjL1Urid2iuQZf
  5896. noCMFIOu4vksK5HxJxxrN0GOmGmwVQjOOtxkwikNiotZGPR4KsVj8NnBrLX7oGuM
  5897. nQvGciiu+KoC2r3HDBrpDeBVdOWxDzT5R4iI0KoLzFh2pKqwbY+obNPS2bj+2dgJ
  5898. rV3V5Jjry42QOCBN3c88wU1PKftOLj2ECpewY6vnE478IipiEu7EAdK8Zwj2LmTr
  5899. RKQUSa9k7ggBkYZWAeO/2Ag0ey3g2bg7eqk+sHEq5ynIXd5lhv6tC5PBdHlWipDK
  5900. tl2IxiEnejnOmAzGVivE1YGduYBjN+mjxDVy8KGBrjnz1JPgAvgdwJ2dYw4Rsc/e
  5901. TzCFWGk/HM6a4f0IzBWbJ5ot0PIi4amk07IotBXDWwqDiQTwyuGCym5EqWQ2BD95
  5902. RGv89BPD+2DLnJysngsvVaUCAwEAAQ==
  5903. -----END PUBLIC KEY-----
  5904. TAGSPUBKEY
  5905. );
  5906. }
  5907. $pubkeyid = openssl_pkey_get_public($sigFile);
  5908. $algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384';
  5909. if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()))) {
  5910. throw new \RuntimeException('SHA384 is not supported by your openssl extension, could not verify the phar file integrity');
  5911. }
  5912. $signature = json_decode($signature, true);
  5913. $signature = base64_decode($signature['sha384']);
  5914. $verified = 1 === openssl_verify(file_get_contents($tempFilename), $signature, $pubkeyid, $algo);
  5915. if (PHP_VERSION_ID < 80000) {
  5916. openssl_free_key($pubkeyid);
  5917. }
  5918. if (!$verified) {
  5919. 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');
  5920. }
  5921. }
  5922. if ($input->getOption('clean-backups')) {
  5923. $this->cleanBackups($rollbackDir);
  5924. }
  5925. if (!$this->setLocalPhar($localFilename, $tempFilename, $backupFile)) {
  5926. @unlink($tempFilename);
  5927. return 1;
  5928. }
  5929. if (file_exists($backupFile)) {
  5930. $io->writeError(sprintf(
  5931. 'Use <info>composer self-update --rollback</info> to return to version <comment>%s</comment>',
  5932. Composer::VERSION
  5933. ));
  5934. } else {
  5935. $io->writeError('<warning>A backup of the current version could not be written to '.$backupFile.', no rollback possible</warning>');
  5936. }
  5937. return 0;
  5938. }
  5939. protected function fetchKeys(IOInterface $io, Config $config)
  5940. {
  5941. if (!$io->isInteractive()) {
  5942. throw new \RuntimeException('Public keys can not be fetched in non-interactive mode, please run Composer interactively');
  5943. }
  5944. $io->write('Open <info>https://composer.github.io/pubkeys.html</info> to find the latest keys');
  5945. $validator = function ($value) {
  5946. if (!preg_match('{^-----BEGIN PUBLIC KEY-----$}', trim($value))) {
  5947. throw new \UnexpectedValueException('Invalid input');
  5948. }
  5949. return trim($value)."\n";
  5950. };
  5951. $devKey = '';
  5952. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $devKey, $match)) {
  5953. $devKey = $io->askAndValidate('Enter Dev / Snapshot Public Key (including lines with -----): ', $validator);
  5954. while ($line = $io->ask('')) {
  5955. $devKey .= trim($line)."\n";
  5956. if (trim($line) === '-----END PUBLIC KEY-----') {
  5957. break;
  5958. }
  5959. }
  5960. }
  5961. file_put_contents($keyPath = $config->get('home').'/keys.dev.pub', $match[0]);
  5962. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5963. $tagsKey = '';
  5964. while (!preg_match('{(-----BEGIN PUBLIC KEY-----.+?-----END PUBLIC KEY-----)}s', $tagsKey, $match)) {
  5965. $tagsKey = $io->askAndValidate('Enter Tags Public Key (including lines with -----): ', $validator);
  5966. while ($line = $io->ask('')) {
  5967. $tagsKey .= trim($line)."\n";
  5968. if (trim($line) === '-----END PUBLIC KEY-----') {
  5969. break;
  5970. }
  5971. }
  5972. }
  5973. file_put_contents($keyPath = $config->get('home').'/keys.tags.pub', $match[0]);
  5974. $io->write('Stored key with fingerprint: ' . Keys::fingerprint($keyPath));
  5975. $io->write('Public keys stored in '.$config->get('home'));
  5976. }
  5977. protected function rollback(OutputInterface $output, $rollbackDir, $localFilename)
  5978. {
  5979. $rollbackVersion = $this->getLastBackupVersion($rollbackDir);
  5980. if (!$rollbackVersion) {
  5981. throw new \UnexpectedValueException('Composer rollback failed: no installation to roll back to in "'.$rollbackDir.'"');
  5982. }
  5983. $oldFile = $rollbackDir . '/' . $rollbackVersion . self::OLD_INSTALL_EXT;
  5984. if (!is_file($oldFile)) {
  5985. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be found');
  5986. }
  5987. if (!is_readable($oldFile)) {
  5988. throw new FilesystemException('Composer rollback failed: "'.$oldFile.'" could not be read');
  5989. }
  5990. $io = $this->getIO();
  5991. $io->writeError(sprintf("Rolling back to version <info>%s</info>.", $rollbackVersion));
  5992. if (!$this->setLocalPhar($localFilename, $oldFile)) {
  5993. return 1;
  5994. }
  5995. return 0;
  5996. }
  5997. protected function setLocalPhar($localFilename, $newFilename, $backupTarget = null)
  5998. {
  5999. $io = $this->getIO();
  6000. @chmod($newFilename, fileperms($localFilename));
  6001. if (!$this->validatePhar($newFilename, $error)) {
  6002. $io->writeError('<error>The '.($backupTarget ? 'update' : 'backup').' file is corrupted ('.$error.')</error>');
  6003. if ($backupTarget) {
  6004. $io->writeError('<error>Please re-run the self-update command to try again.</error>');
  6005. }
  6006. return false;
  6007. }
  6008. if ($backupTarget) {
  6009. @copy($localFilename, $backupTarget);
  6010. }
  6011. try {
  6012. rename($newFilename, $localFilename);
  6013. return true;
  6014. } catch (\Exception $e) {
  6015. if (!is_writable(dirname($localFilename))
  6016. && $io->isInteractive()
  6017. && $this->isWindowsNonAdminUser()) {
  6018. return $this->tryAsWindowsAdmin($localFilename, $newFilename);
  6019. }
  6020. $action = 'Composer '.($backupTarget ? 'update' : 'rollback');
  6021. throw new FilesystemException($action.' failed: "'.$localFilename.'" could not be written.'.PHP_EOL.$e->getMessage());
  6022. }
  6023. }
  6024. protected function cleanBackups($rollbackDir, $except = null)
  6025. {
  6026. $finder = $this->getOldInstallationFinder($rollbackDir);
  6027. $io = $this->getIO();
  6028. $fs = new Filesystem;
  6029. foreach ($finder as $file) {
  6030. if ($except && $file->getBasename(self::OLD_INSTALL_EXT) === $except) {
  6031. continue;
  6032. }
  6033. $file = (string) $file;
  6034. $io->writeError('<info>Removing: '.$file.'</info>');
  6035. $fs->remove($file);
  6036. }
  6037. }
  6038. protected function getLastBackupVersion($rollbackDir)
  6039. {
  6040. $finder = $this->getOldInstallationFinder($rollbackDir);
  6041. $finder->sortByName();
  6042. $files = iterator_to_array($finder);
  6043. if (count($files)) {
  6044. return basename(end($files), self::OLD_INSTALL_EXT);
  6045. }
  6046. return false;
  6047. }
  6048. protected function getOldInstallationFinder($rollbackDir)
  6049. {
  6050. return Finder::create()
  6051. ->depth(0)
  6052. ->files()
  6053. ->name('*' . self::OLD_INSTALL_EXT)
  6054. ->in($rollbackDir);
  6055. }
  6056. protected function validatePhar($pharFile, &$error)
  6057. {
  6058. if (ini_get('phar.readonly')) {
  6059. return true;
  6060. }
  6061. try {
  6062. $phar = new \Phar($pharFile);
  6063. unset($phar);
  6064. $result = true;
  6065. } catch (\Exception $e) {
  6066. if (!$e instanceof \UnexpectedValueException && !$e instanceof \PharException) {
  6067. throw $e;
  6068. }
  6069. $error = $e->getMessage();
  6070. $result = false;
  6071. }
  6072. return $result;
  6073. }
  6074. protected function isWindowsNonAdminUser()
  6075. {
  6076. if (!Platform::isWindows()) {
  6077. return false;
  6078. }
  6079. exec('fltmc.exe filters', $output, $exitCode);
  6080. return $exitCode !== 0;
  6081. }
  6082. protected function tryAsWindowsAdmin($localFilename, $newFilename)
  6083. {
  6084. $io = $this->getIO();
  6085. $io->writeError('<error>Unable to write "'.$localFilename.'". Access is denied.</error>');
  6086. $helpMessage = 'Please run the self-update command as an Administrator.';
  6087. $question = 'Complete this operation with Administrator privileges [<comment>Y,n</comment>]? ';
  6088. if (!$io->askConfirmation($question, false)) {
  6089. $io->writeError('<warning>Operation cancelled. '.$helpMessage.'</warning>');
  6090. return false;
  6091. }
  6092. $tmpFile = tempnam(sys_get_temp_dir(), '');
  6093. $script = $tmpFile.'.vbs';
  6094. rename($tmpFile, $script);
  6095. $checksum = hash_file('sha256', $newFilename);
  6096. $source = str_replace('/', '\\', $newFilename);
  6097. $destination = str_replace('/', '\\', $localFilename);
  6098. $vbs = <<<EOT
  6099. Set UAC = CreateObject("Shell.Application")
  6100. UAC.ShellExecute "cmd.exe", "/c move /y ""$source"" ""$destination""", "", "runas", 0
  6101. Wscript.Sleep(300)
  6102. EOT;
  6103. file_put_contents($script, $vbs);
  6104. exec('"'.$script.'"');
  6105. @unlink($script);
  6106. if ($result = (hash_file('sha256', $localFilename) === $checksum)) {
  6107. $io->writeError('<info>Operation succeeded.</info>');
  6108. } else {
  6109. $io->writeError('<error>Operation failed (file not written). '.$helpMessage.'</error>');
  6110. }
  6111. return $result;
  6112. }
  6113. }
  6114. <?php
  6115. namespace Composer\Command;
  6116. use Composer\Composer;
  6117. use Composer\DependencyResolver\DefaultPolicy;
  6118. use Composer\Json\JsonFile;
  6119. use Composer\Package\BasePackage;
  6120. use Composer\Package\CompletePackageInterface;
  6121. use Composer\Package\Link;
  6122. use Composer\Package\AliasPackage;
  6123. use Composer\Package\PackageInterface;
  6124. use Composer\Package\Version\VersionParser;
  6125. use Composer\Package\Version\VersionSelector;
  6126. use Composer\Plugin\CommandEvent;
  6127. use Composer\Plugin\PluginEvents;
  6128. use Composer\Repository\InstalledArrayRepository;
  6129. use Composer\Repository\ComposerRepository;
  6130. use Composer\Repository\CompositeRepository;
  6131. use Composer\Repository\PlatformRepository;
  6132. use Composer\Repository\RepositoryFactory;
  6133. use Composer\Repository\InstalledRepository;
  6134. use Composer\Repository\RepositoryInterface;
  6135. use Composer\Repository\RepositorySet;
  6136. use Composer\Repository\RootPackageRepository;
  6137. use Composer\Semver\Constraint\ConstraintInterface;
  6138. use Composer\Semver\Semver;
  6139. use Composer\Spdx\SpdxLicenses;
  6140. use Composer\Util\Platform;
  6141. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  6142. use Symfony\Component\Console\Input\InputArgument;
  6143. use Symfony\Component\Console\Input\InputInterface;
  6144. use Symfony\Component\Console\Input\InputOption;
  6145. use Symfony\Component\Console\Output\OutputInterface;
  6146. use Symfony\Component\Console\Terminal;
  6147. class ShowCommand extends BaseCommand
  6148. {
  6149. protected $versionParser;
  6150. protected $colors;
  6151. private $repositorySet;
  6152. protected function configure()
  6153. {
  6154. $this
  6155. ->setName('show')
  6156. ->setAliases(array('info'))
  6157. ->setDescription('Shows information about packages.')
  6158. ->setDefinition(array(
  6159. new InputArgument('package', InputArgument::OPTIONAL, 'Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.'),
  6160. new InputArgument('version', InputArgument::OPTIONAL, 'Version or version constraint to inspect'),
  6161. new InputOption('all', null, InputOption::VALUE_NONE, 'List all packages'),
  6162. new InputOption('locked', null, InputOption::VALUE_NONE, 'List all locked packages'),
  6163. new InputOption('installed', 'i', InputOption::VALUE_NONE, 'List installed packages only (enabled by default, only present for BC).'),
  6164. new InputOption('platform', 'p', InputOption::VALUE_NONE, 'List platform packages only'),
  6165. new InputOption('available', 'a', InputOption::VALUE_NONE, 'List available packages only'),
  6166. new InputOption('self', 's', InputOption::VALUE_NONE, 'Show the root package information'),
  6167. new InputOption('name-only', 'N', InputOption::VALUE_NONE, 'List package names only'),
  6168. new InputOption('path', 'P', InputOption::VALUE_NONE, 'Show package paths'),
  6169. new InputOption('tree', 't', InputOption::VALUE_NONE, 'List the dependencies as a tree'),
  6170. new InputOption('latest', 'l', InputOption::VALUE_NONE, 'Show the latest version'),
  6171. new InputOption('outdated', 'o', InputOption::VALUE_NONE, 'Show the latest version but only for packages that are outdated'),
  6172. 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.'),
  6173. new InputOption('minor-only', 'm', InputOption::VALUE_NONE, 'Show only packages that have minor SemVer-compatible updates. Use with the --outdated option.'),
  6174. new InputOption('direct', 'D', InputOption::VALUE_NONE, 'Shows only packages that are directly required by the root package'),
  6175. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code when there are outdated packages'),
  6176. new InputOption('format', 'f', InputOption::VALUE_REQUIRED, 'Format of the output: text or json', 'text'),
  6177. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables search in require-dev packages.'),
  6178. ))
  6179. ->setHelp(
  6180. <<<EOT
  6181. The show command displays detailed information about a package, or
  6182. lists all packages available.
  6183. Read more at https://getcomposer.org/doc/03-cli.md#show
  6184. EOT
  6185. )
  6186. ;
  6187. }
  6188. protected function execute(InputInterface $input, OutputInterface $output)
  6189. {
  6190. $this->versionParser = new VersionParser;
  6191. if ($input->getOption('tree')) {
  6192. $this->initStyles($output);
  6193. }
  6194. $composer = $this->getComposer(false);
  6195. $io = $this->getIO();
  6196. if ($input->getOption('installed')) {
  6197. $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>');
  6198. }
  6199. if ($input->getOption('outdated')) {
  6200. $input->setOption('latest', true);
  6201. } elseif ($input->getOption('ignore')) {
  6202. $io->writeError('<warning>You are using the option "ignore" for action other than "outdated", it will be ignored.</warning>');
  6203. }
  6204. if ($input->getOption('direct') && ($input->getOption('all') || $input->getOption('available') || $input->getOption('platform'))) {
  6205. $io->writeError('The --direct (-D) option is not usable in combination with --all, --platform (-p) or --available (-a)');
  6206. return 1;
  6207. }
  6208. if ($input->getOption('tree') && ($input->getOption('all') || $input->getOption('available'))) {
  6209. $io->writeError('The --tree (-t) option is not usable in combination with --all or --available (-a)');
  6210. return 1;
  6211. }
  6212. if ($input->getOption('tree') && $input->getOption('latest')) {
  6213. $io->writeError('The --tree (-t) option is not usable in combination with --latest (-l)');
  6214. return 1;
  6215. }
  6216. if ($input->getOption('tree') && $input->getOption('path')) {
  6217. $io->writeError('The --tree (-t) option is not usable in combination with --path (-P)');
  6218. return 1;
  6219. }
  6220. $format = $input->getOption('format');
  6221. if (!in_array($format, array('text', 'json'))) {
  6222. $io->writeError(sprintf('Unsupported format "%s". See help for supported formats.', $format));
  6223. return 1;
  6224. }
  6225. $platformOverrides = array();
  6226. if ($composer) {
  6227. $platformOverrides = $composer->getConfig()->get('platform') ?: array();
  6228. }
  6229. $platformRepo = new PlatformRepository(array(), $platformOverrides);
  6230. $lockedRepo = null;
  6231. if ($input->getOption('self')) {
  6232. $package = $this->getComposer()->getPackage();
  6233. if ($input->getOption('name-only')) {
  6234. $io->write($package->getName());
  6235. return 0;
  6236. }
  6237. $repos = $installedRepo = new InstalledRepository(array(new RootPackageRepository($package)));
  6238. } elseif ($input->getOption('platform')) {
  6239. $repos = $installedRepo = new InstalledRepository(array($platformRepo));
  6240. } elseif ($input->getOption('available')) {
  6241. $installedRepo = new InstalledRepository(array($platformRepo));
  6242. if ($composer) {
  6243. $repos = new CompositeRepository($composer->getRepositoryManager()->getRepositories());
  6244. $installedRepo->addRepository($composer->getRepositoryManager()->getLocalRepository());
  6245. } else {
  6246. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6247. $repos = new CompositeRepository($defaultRepos);
  6248. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6249. }
  6250. } elseif ($input->getOption('all') && $composer) {
  6251. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  6252. $locker = $composer->getLocker();
  6253. if ($locker->isLocked()) {
  6254. $lockedRepo = $locker->getLockedRepository(true);
  6255. $installedRepo = new InstalledRepository(array($lockedRepo, $localRepo, $platformRepo));
  6256. } else {
  6257. $installedRepo = new InstalledRepository(array($localRepo, $platformRepo));
  6258. }
  6259. $repos = new CompositeRepository(array_merge(array($installedRepo), $composer->getRepositoryManager()->getRepositories()));
  6260. } elseif ($input->getOption('all')) {
  6261. $defaultRepos = RepositoryFactory::defaultRepos($io);
  6262. $io->writeError('No composer.json found in the current directory, showing available packages from ' . implode(', ', array_keys($defaultRepos)));
  6263. $installedRepo = new InstalledRepository(array($platformRepo));
  6264. $repos = new CompositeRepository(array_merge(array($installedRepo), $defaultRepos));
  6265. } elseif ($input->getOption('locked')) {
  6266. if (!$composer || !$composer->getLocker()->isLocked()) {
  6267. throw new \UnexpectedValueException('A valid composer.json and composer.lock files is required to run this command with --locked');
  6268. }
  6269. $locker = $composer->getLocker();
  6270. $lockedRepo = $locker->getLockedRepository(true);
  6271. $repos = $installedRepo = new InstalledRepository(array($lockedRepo));
  6272. } else {
  6273. if (!$composer) {
  6274. $composer = $this->getComposer();
  6275. }
  6276. $rootPkg = $composer->getPackage();
  6277. $repos = $installedRepo = new InstalledRepository(array($composer->getRepositoryManager()->getLocalRepository()));
  6278. if ($input->getOption('no-dev')) {
  6279. $packages = $this->filterRequiredPackages($installedRepo, $rootPkg);
  6280. $repos = $installedRepo = new InstalledRepository(array(new InstalledArrayRepository(array_map(function ($pkg) {
  6281. return clone $pkg;
  6282. }, $packages))));
  6283. }
  6284. if (!$installedRepo->getPackages() && ($rootPkg->getRequires() || $rootPkg->getDevRequires())) {
  6285. $io->writeError('<warning>No dependencies installed. Try running composer install or update.</warning>');
  6286. }
  6287. }
  6288. if ($composer) {
  6289. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'show', $input, $output);
  6290. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  6291. }
  6292. if ($input->getOption('latest') && null === $composer) {
  6293. $io->writeError('No composer.json found in the current directory, disabling "latest" option');
  6294. $input->setOption('latest', false);
  6295. }
  6296. $packageFilter = $input->getArgument('package');
  6297. if (($packageFilter && false === strpos($packageFilter, '*')) || !empty($package)) {
  6298. if (empty($package)) {
  6299. list($package, $versions) = $this->getPackage($installedRepo, $repos, $input->getArgument('package'), $input->getArgument('version'));
  6300. if (empty($package)) {
  6301. $options = $input->getOptions();
  6302. if (!isset($options['working-dir']) || !file_exists('composer.json')) {
  6303. if (PlatformRepository::isPlatformPackage($input->getArgument('package')) && !$input->getOption('platform')) {
  6304. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found, try using --platform (-p) to show platform packages.');
  6305. }
  6306. throw new \InvalidArgumentException('Package ' . $packageFilter . ' not found');
  6307. }
  6308. $io->writeError('Package ' . $packageFilter . ' not found in ' . $options['working-dir'] . '/composer.json');
  6309. return 1;
  6310. }
  6311. } else {
  6312. $versions = array($package->getPrettyVersion() => $package->getVersion());
  6313. }
  6314. $exitCode = 0;
  6315. if ($input->getOption('tree')) {
  6316. $arrayTree = $this->generatePackageTree($package, $installedRepo, $repos);
  6317. if ('json' === $format) {
  6318. $io->write(JsonFile::encode(array('installed' => array($arrayTree))));
  6319. } else {
  6320. $this->displayPackageTree(array($arrayTree));
  6321. }
  6322. } else {
  6323. $latestPackage = null;
  6324. if ($input->getOption('latest')) {
  6325. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $input->getOption('minor-only'));
  6326. }
  6327. if ($input->getOption('outdated') && $input->getOption('strict') && $latestPackage && $latestPackage->getFullPrettyVersion() !== $package->getFullPrettyVersion() && !$latestPackage->isAbandoned()) {
  6328. $exitCode = 1;
  6329. }
  6330. if ($input->getOption('path')) {
  6331. $io->write($package->getName(), false);
  6332. $io->write(' ' . strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n"));
  6333. return $exitCode;
  6334. }
  6335. if ('json' === $format) {
  6336. $this->printPackageInfoAsJson($package, $versions, $installedRepo, $latestPackage ?: null);
  6337. } else {
  6338. $this->printPackageInfo($package, $versions, $installedRepo, $latestPackage ?: null);
  6339. }
  6340. }
  6341. return $exitCode;
  6342. }
  6343. if ($input->getOption('tree')) {
  6344. $rootRequires = $this->getRootRequires();
  6345. $packages = $installedRepo->getPackages();
  6346. usort($packages, 'strcmp');
  6347. $arrayTree = array();
  6348. foreach ($packages as $package) {
  6349. if (in_array($package->getName(), $rootRequires, true)) {
  6350. $arrayTree[] = $this->generatePackageTree($package, $installedRepo, $repos);
  6351. }
  6352. }
  6353. if ('json' === $format) {
  6354. $io->write(JsonFile::encode(array('installed' => $arrayTree)));
  6355. } else {
  6356. $this->displayPackageTree($arrayTree);
  6357. }
  6358. return 0;
  6359. }
  6360. if ($repos instanceof CompositeRepository) {
  6361. $repos = $repos->getRepositories();
  6362. } elseif (!is_array($repos)) {
  6363. $repos = array($repos);
  6364. }
  6365. $packages = array();
  6366. $packageFilterRegex = null;
  6367. if (null !== $packageFilter) {
  6368. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  6369. }
  6370. $packageListFilter = array();
  6371. if ($input->getOption('direct')) {
  6372. $packageListFilter = $this->getRootRequires();
  6373. }
  6374. if (class_exists('Symfony\Component\Console\Terminal')) {
  6375. $terminal = new Terminal();
  6376. $width = $terminal->getWidth();
  6377. } else {
  6378. list($width) = $this->getApplication()->getTerminalDimensions();
  6379. }
  6380. if (null === $width) {
  6381. $width = PHP_INT_MAX;
  6382. }
  6383. if (Platform::isWindows()) {
  6384. $width--;
  6385. } else {
  6386. $width = max(80, $width);
  6387. }
  6388. if ($input->getOption('path') && null === $composer) {
  6389. $io->writeError('No composer.json found in the current directory, disabling "path" option');
  6390. $input->setOption('path', false);
  6391. }
  6392. foreach ($repos as $repo) {
  6393. if ($repo === $platformRepo) {
  6394. $type = 'platform';
  6395. } elseif ($lockedRepo !== null && $repo === $lockedRepo) {
  6396. $type = 'locked';
  6397. } elseif ($repo === $installedRepo || in_array($repo, $installedRepo->getRepositories(), true)) {
  6398. $type = 'installed';
  6399. } else {
  6400. $type = 'available';
  6401. }
  6402. if ($repo instanceof ComposerRepository) {
  6403. foreach ($repo->getPackageNames($packageFilter) as $name) {
  6404. $packages[$type][$name] = $name;
  6405. }
  6406. } else {
  6407. foreach ($repo->getPackages() as $package) {
  6408. if (!isset($packages[$type][$package->getName()])
  6409. || !is_object($packages[$type][$package->getName()])
  6410. || version_compare($packages[$type][$package->getName()]->getVersion(), $package->getVersion(), '<')
  6411. ) {
  6412. while ($package instanceof AliasPackage) {
  6413. $package = $package->getAliasOf();
  6414. }
  6415. if (!$packageFilterRegex || preg_match($packageFilterRegex, $package->getName())) {
  6416. if (!$packageListFilter || in_array($package->getName(), $packageListFilter, true)) {
  6417. $packages[$type][$package->getName()] = $package;
  6418. }
  6419. }
  6420. }
  6421. }
  6422. }
  6423. }
  6424. $showAllTypes = $input->getOption('all');
  6425. $showLatest = $input->getOption('latest');
  6426. $showMinorOnly = $input->getOption('minor-only');
  6427. $ignoredPackages = array_map('strtolower', $input->getOption('ignore'));
  6428. $indent = $showAllTypes ? ' ' : '';
  6429. $latestPackages = array();
  6430. $exitCode = 0;
  6431. $viewData = array();
  6432. $viewMetaData = array();
  6433. foreach (array('platform' => true, 'locked' => true, 'available' => false, 'installed' => true) as $type => $showVersion) {
  6434. if (isset($packages[$type])) {
  6435. ksort($packages[$type]);
  6436. $nameLength = $versionLength = $latestLength = 0;
  6437. if ($showLatest && $showVersion) {
  6438. foreach ($packages[$type] as $package) {
  6439. if (is_object($package)) {
  6440. $latestPackage = $this->findLatestPackage($package, $composer, $platformRepo, $showMinorOnly);
  6441. if ($latestPackage === false) {
  6442. continue;
  6443. }
  6444. $latestPackages[$package->getPrettyName()] = $latestPackage;
  6445. }
  6446. }
  6447. }
  6448. $writePath = !$input->getOption('name-only') && $input->getOption('path');
  6449. $writeVersion = !$input->getOption('name-only') && !$input->getOption('path') && $showVersion;
  6450. $writeLatest = $writeVersion && $showLatest;
  6451. $writeDescription = !$input->getOption('name-only') && !$input->getOption('path');
  6452. $hasOutdatedPackages = false;
  6453. $viewData[$type] = array();
  6454. foreach ($packages[$type] as $package) {
  6455. $packageViewData = array();
  6456. if (is_object($package)) {
  6457. $latestPackage = null;
  6458. if ($showLatest && isset($latestPackages[$package->getPrettyName()])) {
  6459. $latestPackage = $latestPackages[$package->getPrettyName()];
  6460. }
  6461. $packageIsUpToDate = $latestPackage && $latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion() && !$latestPackage->isAbandoned();
  6462. $packageIsIgnored = \in_array($package->getPrettyName(), $ignoredPackages, true);
  6463. if ($input->getOption('outdated') && ($packageIsUpToDate || $packageIsIgnored)) {
  6464. continue;
  6465. }
  6466. if ($input->getOption('outdated') || $input->getOption('strict')) {
  6467. $hasOutdatedPackages = true;
  6468. }
  6469. $packageViewData['name'] = $package->getPrettyName();
  6470. $nameLength = max($nameLength, strlen($package->getPrettyName()));
  6471. if ($writeVersion) {
  6472. $packageViewData['version'] = $package->getFullPrettyVersion();
  6473. $versionLength = max($versionLength, strlen($package->getFullPrettyVersion()));
  6474. }
  6475. if ($writeLatest && $latestPackage) {
  6476. $packageViewData['latest'] = $latestPackage->getFullPrettyVersion();
  6477. $packageViewData['latest-status'] = $this->getUpdateStatus($latestPackage, $package);
  6478. $latestLength = max($latestLength, strlen($latestPackage->getFullPrettyVersion()));
  6479. }
  6480. if ($writeDescription) {
  6481. $packageViewData['description'] = $package->getDescription();
  6482. }
  6483. if ($writePath) {
  6484. $packageViewData['path'] = strtok(realpath($composer->getInstallationManager()->getInstallPath($package)), "\r\n");
  6485. }
  6486. if ($latestPackage && $latestPackage->isAbandoned()) {
  6487. $replacement = is_string($latestPackage->getReplacementPackage())
  6488. ? 'Use ' . $latestPackage->getReplacementPackage() . ' instead'
  6489. : 'No replacement was suggested';
  6490. $packageWarning = sprintf(
  6491. 'Package %s is abandoned, you should avoid using it. %s.',
  6492. $package->getPrettyName(),
  6493. $replacement
  6494. );
  6495. $packageViewData['warning'] = $packageWarning;
  6496. }
  6497. } else {
  6498. $packageViewData['name'] = $package;
  6499. $nameLength = max($nameLength, strlen($package));
  6500. }
  6501. $viewData[$type][] = $packageViewData;
  6502. }
  6503. $viewMetaData[$type] = array(
  6504. 'nameLength' => $nameLength,
  6505. 'versionLength' => $versionLength,
  6506. 'latestLength' => $latestLength,
  6507. );
  6508. if ($input->getOption('strict') && $hasOutdatedPackages) {
  6509. $exitCode = 1;
  6510. break;
  6511. }
  6512. }
  6513. }
  6514. if ('json' === $format) {
  6515. $io->write(JsonFile::encode($viewData));
  6516. } else {
  6517. foreach ($viewData as $type => $packages) {
  6518. $nameLength = $viewMetaData[$type]['nameLength'];
  6519. $versionLength = $viewMetaData[$type]['versionLength'];
  6520. $latestLength = $viewMetaData[$type]['latestLength'];
  6521. $writeVersion = $nameLength + $versionLength + 3 <= $width;
  6522. $writeLatest = $nameLength + $versionLength + $latestLength + 3 <= $width;
  6523. $writeDescription = $nameLength + $versionLength + $latestLength + 24 <= $width;
  6524. if ($writeLatest && !$io->isDecorated()) {
  6525. $latestLength += 2;
  6526. }
  6527. if ($showAllTypes) {
  6528. if ('available' === $type) {
  6529. $io->write('<comment>' . $type . '</comment>:');
  6530. } else {
  6531. $io->write('<info>' . $type . '</info>:');
  6532. }
  6533. }
  6534. foreach ($packages as $package) {
  6535. $io->write($indent . str_pad($package['name'], $nameLength, ' '), false);
  6536. if (isset($package['version']) && $writeVersion) {
  6537. $io->write(' ' . str_pad($package['version'], $versionLength, ' '), false);
  6538. }
  6539. if (isset($package['latest']) && $writeLatest) {
  6540. $latestVersion = $package['latest'];
  6541. $updateStatus = $package['latest-status'];
  6542. $style = $this->updateStatusToVersionStyle($updateStatus);
  6543. if (!$io->isDecorated()) {
  6544. $latestVersion = str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('=', '!', '~'), $updateStatus) . ' ' . $latestVersion;
  6545. }
  6546. $io->write(' <' . $style . '>' . str_pad($latestVersion, $latestLength, ' ') . '</' . $style . '>', false);
  6547. }
  6548. if (isset($package['description']) && $writeDescription) {
  6549. $description = strtok($package['description'], "\r\n");
  6550. $remaining = $width - $nameLength - $versionLength - 4;
  6551. if ($writeLatest) {
  6552. $remaining -= $latestLength;
  6553. }
  6554. if (strlen($description) > $remaining) {
  6555. $description = substr($description, 0, $remaining - 3) . '...';
  6556. }
  6557. $io->write(' ' . $description, false);
  6558. }
  6559. if (isset($package['path'])) {
  6560. $io->write(' ' . $package['path'], false);
  6561. }
  6562. $io->write('');
  6563. if (isset($package['warning'])) {
  6564. $io->write('<warning>' . $package['warning'] . '</warning>');
  6565. }
  6566. }
  6567. if ($showAllTypes) {
  6568. $io->write('');
  6569. }
  6570. }
  6571. }
  6572. return $exitCode;
  6573. }
  6574. protected function getRootRequires()
  6575. {
  6576. $rootPackage = $this->getComposer()->getPackage();
  6577. return array_map(
  6578. 'strtolower',
  6579. array_keys(array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()))
  6580. );
  6581. }
  6582. protected function getVersionStyle(PackageInterface $latestPackage, PackageInterface $package)
  6583. {
  6584. return $this->updateStatusToVersionStyle($this->getUpdateStatus($latestPackage, $package));
  6585. }
  6586. protected function getPackage(InstalledRepository $installedRepo, RepositoryInterface $repos, $name, $version = null)
  6587. {
  6588. $name = strtolower($name);
  6589. $constraint = is_string($version) ? $this->versionParser->parseConstraints($version) : $version;
  6590. $policy = new DefaultPolicy();
  6591. $repositorySet = new RepositorySet('dev');
  6592. $repositorySet->allowInstalledRepositories();
  6593. $repositorySet->addRepository($repos);
  6594. $matchedPackage = null;
  6595. $versions = array();
  6596. if (PlatformRepository::isPlatformPackage($name)) {
  6597. $pool = $repositorySet->createPoolWithAllPackages();
  6598. } else {
  6599. $pool = $repositorySet->createPoolForPackage($name);
  6600. }
  6601. $matches = $pool->whatProvides($name, $constraint);
  6602. foreach ($matches as $index => $package) {
  6603. if (null === $version && $installedRepo->hasPackage($package)) {
  6604. $matchedPackage = $package;
  6605. }
  6606. $versions[$package->getPrettyVersion()] = $package->getVersion();
  6607. $matches[$index] = $package->getId();
  6608. }
  6609. if (!$matchedPackage && $matches && $preferred = $policy->selectPreferredPackages($pool, $matches)) {
  6610. $matchedPackage = $pool->literalToPackage($preferred[0]);
  6611. }
  6612. return array($matchedPackage, $versions);
  6613. }
  6614. protected function printPackageInfo(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6615. {
  6616. $io = $this->getIO();
  6617. $this->printMeta($package, $versions, $installedRepo, $latestPackage ?: null);
  6618. $this->printLinks($package, Link::TYPE_REQUIRE);
  6619. $this->printLinks($package, Link::TYPE_DEV_REQUIRE, 'requires (dev)');
  6620. if ($package->getSuggests()) {
  6621. $io->write("\n<info>suggests</info>");
  6622. foreach ($package->getSuggests() as $suggested => $reason) {
  6623. $io->write($suggested . ' <comment>' . $reason . '</comment>');
  6624. }
  6625. }
  6626. $this->printLinks($package, Link::TYPE_PROVIDE);
  6627. $this->printLinks($package, Link::TYPE_CONFLICT);
  6628. $this->printLinks($package, Link::TYPE_REPLACE);
  6629. }
  6630. protected function printMeta(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6631. {
  6632. $io = $this->getIO();
  6633. $io->write('<info>name</info> : ' . $package->getPrettyName());
  6634. $io->write('<info>descrip.</info> : ' . $package->getDescription());
  6635. $io->write('<info>keywords</info> : ' . implode(', ', $package->getKeywords() ?: array()));
  6636. $this->printVersions($package, $versions, $installedRepo);
  6637. if ($latestPackage) {
  6638. $style = $this->getVersionStyle($latestPackage, $package);
  6639. $io->write('<info>latest</info> : <'.$style.'>' . $latestPackage->getPrettyVersion() . '</'.$style.'>');
  6640. } else {
  6641. $latestPackage = $package;
  6642. }
  6643. $io->write('<info>type</info> : ' . $package->getType());
  6644. $this->printLicenses($package);
  6645. $io->write('<info>homepage</info> : ' . $package->getHomepage());
  6646. $io->write('<info>source</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getSourceType(), $package->getSourceUrl(), $package->getSourceReference()));
  6647. $io->write('<info>dist</info> : ' . sprintf('[%s] <comment>%s</comment> %s', $package->getDistType(), $package->getDistUrl(), $package->getDistReference()));
  6648. if ($installedRepo->hasPackage($package)) {
  6649. $io->write('<info>path</info> : ' . sprintf('%s', realpath($this->getComposer()->getInstallationManager()->getInstallPath($package))));
  6650. }
  6651. $io->write('<info>names</info> : ' . implode(', ', $package->getNames()));
  6652. if ($latestPackage->isAbandoned()) {
  6653. $replacement = ($latestPackage->getReplacementPackage() !== null)
  6654. ? ' The author suggests using the ' . $latestPackage->getReplacementPackage(). ' package instead.'
  6655. : null;
  6656. $io->writeError(
  6657. sprintf('<warning>Attention: This package is abandoned and no longer maintained.%s</warning>', $replacement)
  6658. );
  6659. }
  6660. if ($package->getSupport()) {
  6661. $io->write("\n<info>support</info>");
  6662. foreach ($package->getSupport() as $type => $value) {
  6663. $io->write('<comment>' . $type . '</comment> : '.$value);
  6664. }
  6665. }
  6666. if ($package->getAutoload()) {
  6667. $io->write("\n<info>autoload</info>");
  6668. foreach ($package->getAutoload() as $type => $autoloads) {
  6669. $io->write('<comment>' . $type . '</comment>');
  6670. if ($type === 'psr-0' || $type === 'psr-4') {
  6671. foreach ($autoloads as $name => $path) {
  6672. $io->write(($name ?: '*') . ' => ' . (is_array($path) ? implode(', ', $path) : ($path ?: '.')));
  6673. }
  6674. } elseif ($type === 'classmap') {
  6675. $io->write(implode(', ', $autoloads));
  6676. }
  6677. }
  6678. if ($package->getIncludePaths()) {
  6679. $io->write('<comment>include-path</comment>');
  6680. $io->write(implode(', ', $package->getIncludePaths()));
  6681. }
  6682. }
  6683. }
  6684. protected function printVersions(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo)
  6685. {
  6686. $versions = array_keys($versions);
  6687. $versions = Semver::rsort($versions);
  6688. if ($installedPackages = $installedRepo->findPackages($package->getName())) {
  6689. foreach ($installedPackages as $installedPackage) {
  6690. $installedVersion = $installedPackage->getPrettyVersion();
  6691. $key = array_search($installedVersion, $versions);
  6692. if (false !== $key) {
  6693. $versions[$key] = '<info>* ' . $installedVersion . '</info>';
  6694. }
  6695. }
  6696. }
  6697. $versions = implode(', ', $versions);
  6698. $this->getIO()->write('<info>versions</info> : ' . $versions);
  6699. }
  6700. protected function printLinks(CompletePackageInterface $package, $linkType, $title = null)
  6701. {
  6702. $title = $title ?: $linkType;
  6703. $io = $this->getIO();
  6704. if ($links = $package->{'get'.ucfirst($linkType)}()) {
  6705. $io->write("\n<info>" . $title . "</info>");
  6706. foreach ($links as $link) {
  6707. $io->write($link->getTarget() . ' <comment>' . $link->getPrettyConstraint() . '</comment>');
  6708. }
  6709. }
  6710. }
  6711. protected function printLicenses(CompletePackageInterface $package)
  6712. {
  6713. $spdxLicenses = new SpdxLicenses();
  6714. $licenses = $package->getLicense();
  6715. $io = $this->getIO();
  6716. foreach ($licenses as $licenseId) {
  6717. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  6718. if (!$license) {
  6719. $out = $licenseId;
  6720. } else {
  6721. if ($license[1] === true) {
  6722. $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
  6723. } else {
  6724. $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
  6725. }
  6726. }
  6727. $io->write('<info>license</info> : ' . $out);
  6728. }
  6729. }
  6730. protected function printPackageInfoAsJson(CompletePackageInterface $package, array $versions, InstalledRepository $installedRepo, PackageInterface $latestPackage = null)
  6731. {
  6732. $json = array(
  6733. 'name' => $package->getPrettyName(),
  6734. 'description' => $package->getDescription(),
  6735. 'keywords' => $package->getKeywords() ?: array(),
  6736. 'type' => $package->getType(),
  6737. 'homepage' => $package->getHomepage(),
  6738. 'names' => $package->getNames(),
  6739. );
  6740. $json = $this->appendVersions($json, $versions);
  6741. $json = $this->appendLicenses($json, $package);
  6742. if ($latestPackage) {
  6743. $json['latest'] = $latestPackage->getPrettyVersion();
  6744. } else {
  6745. $latestPackage = $package;
  6746. }
  6747. if ($package->getSourceType()) {
  6748. $json['source'] = array(
  6749. 'type' => $package->getSourceType(),
  6750. 'url' => $package->getSourceUrl(),
  6751. 'reference' => $package->getSourceReference(),
  6752. );
  6753. }
  6754. if ($package->getDistType()) {
  6755. $json['dist'] = array(
  6756. 'type' => $package->getDistType(),
  6757. 'url' => $package->getDistUrl(),
  6758. 'reference' => $package->getDistReference(),
  6759. );
  6760. }
  6761. if ($installedRepo->hasPackage($package)) {
  6762. $json['path'] = realpath($this->getComposer()->getInstallationManager()->getInstallPath($package));
  6763. if ($json['path'] === false) {
  6764. unset($json['path']);
  6765. }
  6766. }
  6767. if ($latestPackage->isAbandoned()) {
  6768. $json['replacement'] = $latestPackage->getReplacementPackage();
  6769. }
  6770. if ($package->getSuggests()) {
  6771. $json['suggests'] = $package->getSuggests();
  6772. }
  6773. if ($package->getSupport()) {
  6774. $json['support'] = $package->getSupport();
  6775. }
  6776. $json = $this->appendAutoload($json, $package);
  6777. if ($package->getIncludePaths()) {
  6778. $json['include_path'] = $package->getIncludePaths();
  6779. }
  6780. $json = $this->appendLinks($json, $package);
  6781. $this->getIO()->write(JsonFile::encode($json));
  6782. }
  6783. private function appendVersions($json, array $versions)
  6784. {
  6785. uasort($versions, 'version_compare');
  6786. $versions = array_keys(array_reverse($versions));
  6787. $json['versions'] = $versions;
  6788. return $json;
  6789. }
  6790. private function appendLicenses($json, CompletePackageInterface $package)
  6791. {
  6792. if ($licenses = $package->getLicense()) {
  6793. $spdxLicenses = new SpdxLicenses();
  6794. $json['licenses'] = array_map(function ($licenseId) use ($spdxLicenses) {
  6795. $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
  6796. if (!$license) {
  6797. return $licenseId;
  6798. }
  6799. return array(
  6800. 'name' => $license[0],
  6801. 'osi' => $licenseId,
  6802. 'url' => $license[2],
  6803. );
  6804. }, $licenses);
  6805. }
  6806. return $json;
  6807. }
  6808. private function appendAutoload($json, CompletePackageInterface $package)
  6809. {
  6810. if ($package->getAutoload()) {
  6811. $autoload = array();
  6812. foreach ($package->getAutoload() as $type => $autoloads) {
  6813. if ($type === 'psr-0' || $type === 'psr-4') {
  6814. $psr = array();
  6815. foreach ($autoloads as $name => $path) {
  6816. if (!$path) {
  6817. $path = '.';
  6818. }
  6819. $psr[$name ?: '*'] = $path;
  6820. }
  6821. $autoload[$type] = $psr;
  6822. } elseif ($type === 'classmap') {
  6823. $autoload['classmap'] = $autoloads;
  6824. }
  6825. }
  6826. $json['autoload'] = $autoload;
  6827. }
  6828. return $json;
  6829. }
  6830. private function appendLinks($json, CompletePackageInterface $package)
  6831. {
  6832. foreach (Link::$TYPES as $linkType) {
  6833. $json = $this->appendLink($json, $package, $linkType);
  6834. }
  6835. return $json;
  6836. }
  6837. private function appendLink($json, CompletePackageInterface $package, $linkType)
  6838. {
  6839. $links = $package->{'get' . ucfirst($linkType)}();
  6840. if ($links) {
  6841. $json[$linkType] = array();
  6842. foreach ($links as $link) {
  6843. $json[$linkType][$link->getTarget()] = $link->getPrettyConstraint();
  6844. }
  6845. }
  6846. return $json;
  6847. }
  6848. protected function initStyles(OutputInterface $output)
  6849. {
  6850. $this->colors = array(
  6851. 'green',
  6852. 'yellow',
  6853. 'cyan',
  6854. 'magenta',
  6855. 'blue',
  6856. );
  6857. foreach ($this->colors as $color) {
  6858. $style = new OutputFormatterStyle($color);
  6859. $output->getFormatter()->setStyle($color, $style);
  6860. }
  6861. }
  6862. protected function displayPackageTree(array $arrayTree)
  6863. {
  6864. $io = $this->getIO();
  6865. foreach ($arrayTree as $package) {
  6866. $io->write(sprintf('<info>%s</info>', $package['name']), false);
  6867. $io->write(' ' . $package['version'], false);
  6868. $io->write(' ' . strtok($package['description'], "\r\n"));
  6869. if (isset($package['requires'])) {
  6870. $requires = $package['requires'];
  6871. $treeBar = '├';
  6872. $j = 0;
  6873. $total = count($requires);
  6874. foreach ($requires as $require) {
  6875. $requireName = $require['name'];
  6876. $j++;
  6877. if ($j === $total) {
  6878. $treeBar = 'â””';
  6879. }
  6880. $level = 1;
  6881. $color = $this->colors[$level];
  6882. $info = sprintf(
  6883. '%s──<%s>%s</%s> %s',
  6884. $treeBar,
  6885. $color,
  6886. $requireName,
  6887. $color,
  6888. $require['version']
  6889. );
  6890. $this->writeTreeLine($info);
  6891. $treeBar = str_replace('â””', ' ', $treeBar);
  6892. $packagesInTree = array($package['name'], $requireName);
  6893. $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
  6894. }
  6895. }
  6896. }
  6897. }
  6898. protected function generatePackageTree(
  6899. PackageInterface $package,
  6900. InstalledRepository $installedRepo,
  6901. RepositoryInterface $remoteRepos
  6902. ) {
  6903. $requires = $package->getRequires();
  6904. ksort($requires);
  6905. $children = array();
  6906. foreach ($requires as $requireName => $require) {
  6907. $packagesInTree = array($package->getName(), $requireName);
  6908. $treeChildDesc = array(
  6909. 'name' => $requireName,
  6910. 'version' => $require->getPrettyConstraint(),
  6911. );
  6912. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $packagesInTree);
  6913. if ($deepChildren) {
  6914. $treeChildDesc['requires'] = $deepChildren;
  6915. }
  6916. $children[] = $treeChildDesc;
  6917. }
  6918. $tree = array(
  6919. 'name' => $package->getPrettyName(),
  6920. 'version' => $package->getPrettyVersion(),
  6921. 'description' => $package->getDescription(),
  6922. );
  6923. if ($children) {
  6924. $tree['requires'] = $children;
  6925. }
  6926. return $tree;
  6927. }
  6928. protected function displayTree(
  6929. $package,
  6930. array $packagesInTree,
  6931. $previousTreeBar = '├',
  6932. $level = 1
  6933. ) {
  6934. $previousTreeBar = str_replace('├', '│', $previousTreeBar);
  6935. if (is_array($package) && isset($package['requires'])) {
  6936. $requires = $package['requires'];
  6937. $treeBar = $previousTreeBar . ' ├';
  6938. $i = 0;
  6939. $total = count($requires);
  6940. foreach ($requires as $require) {
  6941. $currentTree = $packagesInTree;
  6942. $i++;
  6943. if ($i === $total) {
  6944. $treeBar = $previousTreeBar . ' â””';
  6945. }
  6946. $colorIdent = $level % count($this->colors);
  6947. $color = $this->colors[$colorIdent];
  6948. $circularWarn = in_array(
  6949. $require['name'],
  6950. $currentTree,
  6951. true
  6952. ) ? '(circular dependency aborted here)' : '';
  6953. $info = rtrim(sprintf(
  6954. '%s──<%s>%s</%s> %s %s',
  6955. $treeBar,
  6956. $color,
  6957. $require['name'],
  6958. $color,
  6959. $require['version'],
  6960. $circularWarn
  6961. ));
  6962. $this->writeTreeLine($info);
  6963. $treeBar = str_replace('â””', ' ', $treeBar);
  6964. $currentTree[] = $require['name'];
  6965. $this->displayTree($require, $currentTree, $treeBar, $level + 1);
  6966. }
  6967. }
  6968. }
  6969. protected function addTree(
  6970. $name,
  6971. $package,
  6972. InstalledRepository $installedRepo,
  6973. RepositoryInterface $remoteRepos,
  6974. array $packagesInTree
  6975. ) {
  6976. $children = array();
  6977. list($package) = $this->getPackage(
  6978. $installedRepo,
  6979. $remoteRepos,
  6980. $name,
  6981. $package->getPrettyConstraint() === 'self.version' ? $package->getConstraint() : $package->getPrettyConstraint()
  6982. );
  6983. if (is_object($package)) {
  6984. $requires = $package->getRequires();
  6985. ksort($requires);
  6986. foreach ($requires as $requireName => $require) {
  6987. $currentTree = $packagesInTree;
  6988. $treeChildDesc = array(
  6989. 'name' => $requireName,
  6990. 'version' => $require->getPrettyConstraint(),
  6991. );
  6992. if (!in_array($requireName, $currentTree, true)) {
  6993. $currentTree[] = $requireName;
  6994. $deepChildren = $this->addTree($requireName, $require, $installedRepo, $remoteRepos, $currentTree);
  6995. if ($deepChildren) {
  6996. $treeChildDesc['requires'] = $deepChildren;
  6997. }
  6998. }
  6999. $children[] = $treeChildDesc;
  7000. }
  7001. }
  7002. return $children;
  7003. }
  7004. private function updateStatusToVersionStyle($updateStatus)
  7005. {
  7006. return str_replace(array('up-to-date', 'semver-safe-update', 'update-possible'), array('info', 'highlight', 'comment'), $updateStatus);
  7007. }
  7008. private function getUpdateStatus(PackageInterface $latestPackage, PackageInterface $package)
  7009. {
  7010. if ($latestPackage->getFullPrettyVersion() === $package->getFullPrettyVersion()) {
  7011. return 'up-to-date';
  7012. }
  7013. $constraint = $package->getVersion();
  7014. if (0 !== strpos($constraint, 'dev-')) {
  7015. $constraint = '^'.$constraint;
  7016. }
  7017. if ($latestPackage->getVersion() && Semver::satisfies($latestPackage->getVersion(), $constraint)) {
  7018. return 'semver-safe-update';
  7019. }
  7020. return 'update-possible';
  7021. }
  7022. private function writeTreeLine($line)
  7023. {
  7024. $io = $this->getIO();
  7025. if (!$io->isDecorated()) {
  7026. $line = str_replace(array('└', '├', '──', '│'), array('`-', '|-', '-', '|'), $line);
  7027. }
  7028. $io->write($line);
  7029. }
  7030. private function findLatestPackage(PackageInterface $package, Composer $composer, PlatformRepository $platformRepo, $minorOnly = false)
  7031. {
  7032. $name = $package->getName();
  7033. $versionSelector = new VersionSelector($this->getRepositorySet($composer), $platformRepo);
  7034. $stability = $composer->getPackage()->getMinimumStability();
  7035. $flags = $composer->getPackage()->getStabilityFlags();
  7036. if (isset($flags[$name])) {
  7037. $stability = array_search($flags[$name], BasePackage::$stabilities, true);
  7038. }
  7039. $bestStability = $stability;
  7040. if ($composer->getPackage()->getPreferStable()) {
  7041. $bestStability = $package->getStability();
  7042. }
  7043. $targetVersion = null;
  7044. if (0 === strpos($package->getVersion(), 'dev-')) {
  7045. $targetVersion = $package->getVersion();
  7046. }
  7047. if ($targetVersion === null && $minorOnly) {
  7048. $targetVersion = '^' . $package->getVersion();
  7049. }
  7050. $candidate = $versionSelector->findBestCandidate($name, $targetVersion, $bestStability);
  7051. while ($candidate instanceof AliasPackage) {
  7052. $candidate = $candidate->getAliasOf();
  7053. }
  7054. return $candidate;
  7055. }
  7056. private function getRepositorySet(Composer $composer)
  7057. {
  7058. if (!$this->repositorySet) {
  7059. $this->repositorySet = new RepositorySet($composer->getPackage()->getMinimumStability(), $composer->getPackage()->getStabilityFlags());
  7060. $this->repositorySet->addRepository(new CompositeRepository($composer->getRepositoryManager()->getRepositories()));
  7061. }
  7062. return $this->repositorySet;
  7063. }
  7064. private function filterRequiredPackages(RepositoryInterface $repo, PackageInterface $package, $bucket = array())
  7065. {
  7066. $requires = $package->getRequires();
  7067. foreach ($repo->getPackages() as $candidate) {
  7068. foreach ($candidate->getNames() as $name) {
  7069. if (isset($requires[$name])) {
  7070. if (!in_array($candidate, $bucket, true)) {
  7071. $bucket[] = $candidate;
  7072. $bucket = $this->filterRequiredPackages($repo, $candidate, $bucket);
  7073. }
  7074. break;
  7075. }
  7076. }
  7077. }
  7078. return $bucket;
  7079. }
  7080. }
  7081. <?php
  7082. namespace Composer\Command;
  7083. use Symfony\Component\Console\Input\InputInterface;
  7084. use Symfony\Component\Console\Input\InputOption;
  7085. use Symfony\Component\Console\Output\OutputInterface;
  7086. use Composer\Downloader\ChangeReportInterface;
  7087. use Composer\Downloader\DvcsDownloaderInterface;
  7088. use Composer\Downloader\VcsCapableDownloaderInterface;
  7089. use Composer\Package\Dumper\ArrayDumper;
  7090. use Composer\Package\Version\VersionGuesser;
  7091. use Composer\Package\Version\VersionParser;
  7092. use Composer\Plugin\CommandEvent;
  7093. use Composer\Plugin\PluginEvents;
  7094. use Composer\Script\ScriptEvents;
  7095. use Composer\Util\ProcessExecutor;
  7096. class StatusCommand extends BaseCommand
  7097. {
  7098. const EXIT_CODE_ERRORS = 1;
  7099. const EXIT_CODE_UNPUSHED_CHANGES = 2;
  7100. const EXIT_CODE_VERSION_CHANGES = 4;
  7101. protected function configure()
  7102. {
  7103. $this
  7104. ->setName('status')
  7105. ->setDescription('Shows a list of locally modified packages.')
  7106. ->setDefinition(array(
  7107. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Show modified files for each directory that contains changes.'),
  7108. ))
  7109. ->setHelp(
  7110. <<<EOT
  7111. The status command displays a list of dependencies that have
  7112. been modified locally.
  7113. Read more at https://getcomposer.org/doc/03-cli.md#status
  7114. EOT
  7115. )
  7116. ;
  7117. }
  7118. protected function execute(InputInterface $input, OutputInterface $output)
  7119. {
  7120. $composer = $this->getComposer();
  7121. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'status', $input, $output);
  7122. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7123. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::PRE_STATUS_CMD, true);
  7124. $exitCode = $this->doExecute($input);
  7125. $composer->getEventDispatcher()->dispatchScript(ScriptEvents::POST_STATUS_CMD, true);
  7126. return $exitCode;
  7127. }
  7128. private function doExecute(InputInterface $input)
  7129. {
  7130. $composer = $this->getComposer();
  7131. $installedRepo = $composer->getRepositoryManager()->getLocalRepository();
  7132. $dm = $composer->getDownloadManager();
  7133. $im = $composer->getInstallationManager();
  7134. $errors = array();
  7135. $io = $this->getIO();
  7136. $unpushedChanges = array();
  7137. $vcsVersionChanges = array();
  7138. $parser = new VersionParser;
  7139. $guesser = new VersionGuesser($composer->getConfig(), new ProcessExecutor($io), $parser);
  7140. $dumper = new ArrayDumper;
  7141. foreach ($installedRepo->getCanonicalPackages() as $package) {
  7142. $downloader = $dm->getDownloaderForPackage($package);
  7143. $targetDir = $im->getInstallPath($package);
  7144. if ($downloader instanceof ChangeReportInterface) {
  7145. if (is_link($targetDir)) {
  7146. $errors[$targetDir] = $targetDir . ' is a symbolic link.';
  7147. }
  7148. if ($changes = $downloader->getLocalChanges($package, $targetDir)) {
  7149. $errors[$targetDir] = $changes;
  7150. }
  7151. }
  7152. if ($downloader instanceof VcsCapableDownloaderInterface) {
  7153. if ($downloader->getVcsReference($package, $targetDir)) {
  7154. switch ($package->getInstallationSource()) {
  7155. case 'source':
  7156. $previousRef = $package->getSourceReference();
  7157. break;
  7158. case 'dist':
  7159. $previousRef = $package->getDistReference();
  7160. break;
  7161. default:
  7162. $previousRef = null;
  7163. }
  7164. $currentVersion = $guesser->guessVersion($dumper->dump($package), $targetDir);
  7165. if ($previousRef && $currentVersion && $currentVersion['commit'] !== $previousRef) {
  7166. $vcsVersionChanges[$targetDir] = array(
  7167. 'previous' => array(
  7168. 'version' => $package->getPrettyVersion(),
  7169. 'ref' => $previousRef,
  7170. ),
  7171. 'current' => array(
  7172. 'version' => $currentVersion['pretty_version'],
  7173. 'ref' => $currentVersion['commit'],
  7174. ),
  7175. );
  7176. }
  7177. }
  7178. }
  7179. if ($downloader instanceof DvcsDownloaderInterface) {
  7180. if ($unpushed = $downloader->getUnpushedChanges($package, $targetDir)) {
  7181. $unpushedChanges[$targetDir] = $unpushed;
  7182. }
  7183. }
  7184. }
  7185. if (!$errors && !$unpushedChanges && !$vcsVersionChanges) {
  7186. $io->writeError('<info>No local changes</info>');
  7187. return 0;
  7188. }
  7189. if ($errors) {
  7190. $io->writeError('<error>You have changes in the following dependencies:</error>');
  7191. foreach ($errors as $path => $changes) {
  7192. if ($input->getOption('verbose')) {
  7193. $indentedChanges = implode("\n", array_map(function ($line) {
  7194. return ' ' . ltrim($line);
  7195. }, explode("\n", $changes)));
  7196. $io->write('<info>'.$path.'</info>:');
  7197. $io->write($indentedChanges);
  7198. } else {
  7199. $io->write($path);
  7200. }
  7201. }
  7202. }
  7203. if ($unpushedChanges) {
  7204. $io->writeError('<warning>You have unpushed changes on the current branch in the following dependencies:</warning>');
  7205. foreach ($unpushedChanges as $path => $changes) {
  7206. if ($input->getOption('verbose')) {
  7207. $indentedChanges = implode("\n", array_map(function ($line) {
  7208. return ' ' . ltrim($line);
  7209. }, explode("\n", $changes)));
  7210. $io->write('<info>'.$path.'</info>:');
  7211. $io->write($indentedChanges);
  7212. } else {
  7213. $io->write($path);
  7214. }
  7215. }
  7216. }
  7217. if ($vcsVersionChanges) {
  7218. $io->writeError('<warning>You have version variations in the following dependencies:</warning>');
  7219. foreach ($vcsVersionChanges as $path => $changes) {
  7220. if ($input->getOption('verbose')) {
  7221. $currentVersion = $changes['current']['version'] ?: $changes['current']['ref'];
  7222. $previousVersion = $changes['previous']['version'] ?: $changes['previous']['ref'];
  7223. if ($io->isVeryVerbose()) {
  7224. $currentVersion .= sprintf(' (%s)', $changes['current']['ref']);
  7225. $previousVersion .= sprintf(' (%s)', $changes['previous']['ref']);
  7226. }
  7227. $io->write('<info>'.$path.'</info>:');
  7228. $io->write(sprintf(' From <comment>%s</comment> to <comment>%s</comment>', $previousVersion, $currentVersion));
  7229. } else {
  7230. $io->write($path);
  7231. }
  7232. }
  7233. }
  7234. if (($errors || $unpushedChanges || $vcsVersionChanges) && !$input->getOption('verbose')) {
  7235. $io->writeError('Use --verbose (-v) to see a list of files');
  7236. }
  7237. return ($errors ? self::EXIT_CODE_ERRORS : 0) + ($unpushedChanges ? self::EXIT_CODE_UNPUSHED_CHANGES : 0) + ($vcsVersionChanges ? self::EXIT_CODE_VERSION_CHANGES : 0);
  7238. }
  7239. }
  7240. <?php
  7241. namespace Composer\Command;
  7242. use Composer\Repository\PlatformRepository;
  7243. use Composer\Repository\RootPackageRepository;
  7244. use Composer\Repository\InstalledRepository;
  7245. use Composer\Installer\SuggestedPackagesReporter;
  7246. use Symfony\Component\Console\Input\InputArgument;
  7247. use Symfony\Component\Console\Input\InputInterface;
  7248. use Symfony\Component\Console\Input\InputOption;
  7249. use Symfony\Component\Console\Output\OutputInterface;
  7250. class SuggestsCommand extends BaseCommand
  7251. {
  7252. protected function configure()
  7253. {
  7254. $this
  7255. ->setName('suggests')
  7256. ->setDescription('Shows package suggestions.')
  7257. ->setDefinition(array(
  7258. new InputOption('by-package', null, InputOption::VALUE_NONE, 'Groups output by suggesting package (default)'),
  7259. new InputOption('by-suggestion', null, InputOption::VALUE_NONE, 'Groups output by suggested package'),
  7260. new InputOption('all', 'a', InputOption::VALUE_NONE, 'Show suggestions from all dependencies, including transitive ones'),
  7261. new InputOption('list', null, InputOption::VALUE_NONE, 'Show only list of suggested package names'),
  7262. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Exclude suggestions from require-dev packages'),
  7263. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that you want to list suggestions from.'),
  7264. ))
  7265. ->setHelp(
  7266. <<<EOT
  7267. The <info>%command.name%</info> command shows a sorted list of suggested packages.
  7268. Read more at https://getcomposer.org/doc/03-cli.md#suggests
  7269. EOT
  7270. )
  7271. ;
  7272. }
  7273. protected function execute(InputInterface $input, OutputInterface $output)
  7274. {
  7275. $composer = $this->getComposer();
  7276. $installedRepos = array(
  7277. new RootPackageRepository(clone $composer->getPackage()),
  7278. );
  7279. $locker = $composer->getLocker();
  7280. if ($locker->isLocked()) {
  7281. $installedRepos[] = new PlatformRepository(array(), $locker->getPlatformOverrides());
  7282. $installedRepos[] = $locker->getLockedRepository(!$input->getOption('no-dev'));
  7283. } else {
  7284. $installedRepos[] = new PlatformRepository(array(), $composer->getConfig()->get('platform') ?: array());
  7285. $installedRepos[] = $composer->getRepositoryManager()->getLocalRepository();
  7286. }
  7287. $installedRepo = new InstalledRepository($installedRepos);
  7288. $reporter = new SuggestedPackagesReporter($this->getIO());
  7289. $filter = $input->getArgument('packages');
  7290. $packages = $installedRepo->getPackages();
  7291. $packages[] = $composer->getPackage();
  7292. foreach ($packages as $package) {
  7293. if (!empty($filter) && !in_array($package->getName(), $filter)) {
  7294. continue;
  7295. }
  7296. $reporter->addSuggestionsFromPackage($package);
  7297. }
  7298. $mode = SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7299. if ($input->getOption('by-suggestion')) {
  7300. $mode = SuggestedPackagesReporter::MODE_BY_SUGGESTION;
  7301. }
  7302. if ($input->getOption('by-package')) {
  7303. $mode |= SuggestedPackagesReporter::MODE_BY_PACKAGE;
  7304. }
  7305. if ($input->getOption('list')) {
  7306. $mode = SuggestedPackagesReporter::MODE_LIST;
  7307. }
  7308. $reporter->output($mode, $installedRepo, empty($filter) && !$input->getOption('all') ? $composer->getPackage() : null);
  7309. return 0;
  7310. }
  7311. }
  7312. <?php
  7313. namespace Composer\Command;
  7314. use Composer\Composer;
  7315. use Composer\DependencyResolver\Request;
  7316. use Composer\Installer;
  7317. use Composer\IO\IOInterface;
  7318. use Composer\Plugin\CommandEvent;
  7319. use Composer\Plugin\PluginEvents;
  7320. use Composer\Package\Version\VersionParser;
  7321. use Composer\Util\HttpDownloader;
  7322. use Composer\Semver\Constraint\MultiConstraint;
  7323. use Composer\Package\Link;
  7324. use Symfony\Component\Console\Helper\Table;
  7325. use Symfony\Component\Console\Input\InputInterface;
  7326. use Symfony\Component\Console\Input\InputOption;
  7327. use Symfony\Component\Console\Input\InputArgument;
  7328. use Symfony\Component\Console\Output\OutputInterface;
  7329. use Symfony\Component\Console\Question\Question;
  7330. class UpdateCommand extends BaseCommand
  7331. {
  7332. protected function configure()
  7333. {
  7334. $this
  7335. ->setName('update')
  7336. ->setAliases(array('u', 'upgrade'))
  7337. ->setDescription('Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.')
  7338. ->setDefinition(array(
  7339. new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Packages that should be updated, if not provided all packages are.'),
  7340. 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'),
  7341. new InputOption('prefer-source', null, InputOption::VALUE_NONE, 'Forces installation from package sources when possible, including VCS information.'),
  7342. new InputOption('prefer-dist', null, InputOption::VALUE_NONE, 'Forces installation from package dist even for dev versions.'),
  7343. new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
  7344. new InputOption('dev', null, InputOption::VALUE_NONE, 'DEPRECATED: Enables installation of require-dev packages (enabled by default, only present for BC).'),
  7345. new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
  7346. new InputOption('lock', null, InputOption::VALUE_NONE, 'Overwrites the lock file hash to suppress warning about the lock file being out of date without updating package versions. Package metadata like mirrors and URLs are updated if they changed.'),
  7347. new InputOption('no-install', null, InputOption::VALUE_NONE, 'Skip the install step after updating the composer.lock file.'),
  7348. new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
  7349. new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
  7350. new InputOption('no-suggest', null, InputOption::VALUE_NONE, 'DEPRECATED: This flag does not exist anymore.'),
  7351. new InputOption('no-progress', null, InputOption::VALUE_NONE, 'Do not output download progress.'),
  7352. new InputOption('with-dependencies', 'w', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, except those which are root requirements.'),
  7353. new InputOption('with-all-dependencies', 'W', InputOption::VALUE_NONE, 'Update also dependencies of packages in the argument list, including those which are root requirements.'),
  7354. new InputOption('verbose', 'v|vv|vvv', InputOption::VALUE_NONE, 'Shows more details including new commits pulled in when updating packages.'),
  7355. new InputOption('optimize-autoloader', 'o', InputOption::VALUE_NONE, 'Optimize autoloader during autoloader dump.'),
  7356. new InputOption('classmap-authoritative', 'a', InputOption::VALUE_NONE, 'Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.'),
  7357. new InputOption('apcu-autoloader', null, InputOption::VALUE_NONE, 'Use APCu to cache found/not-found classes.'),
  7358. new InputOption('apcu-autoloader-prefix', null, InputOption::VALUE_REQUIRED, 'Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader'),
  7359. new InputOption('ignore-platform-req', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Ignore a specific platform requirement (php & ext- packages).'),
  7360. new InputOption('ignore-platform-reqs', null, InputOption::VALUE_NONE, 'Ignore all platform requirements (php & ext- packages).'),
  7361. new InputOption('prefer-stable', null, InputOption::VALUE_NONE, 'Prefer stable versions of dependencies.'),
  7362. new InputOption('prefer-lowest', null, InputOption::VALUE_NONE, 'Prefer lowest versions of dependencies.'),
  7363. new InputOption('interactive', 'i', InputOption::VALUE_NONE, 'Interactive interface with autocompletion to select the packages to update.'),
  7364. new InputOption('root-reqs', null, InputOption::VALUE_NONE, 'Restricts the update to your first degree dependencies.'),
  7365. ))
  7366. ->setHelp(
  7367. <<<EOT
  7368. The <info>update</info> command reads the composer.json file from the
  7369. current directory, processes it, and updates, removes or installs all the
  7370. dependencies.
  7371. <info>php composer.phar update</info>
  7372. To limit the update operation to a few packages, you can list the package(s)
  7373. you want to update as such:
  7374. <info>php composer.phar update vendor/package1 foo/mypackage [...]</info>
  7375. You may also use an asterisk (*) pattern to limit the update operation to package(s)
  7376. from a specific vendor:
  7377. <info>php composer.phar update vendor/package1 foo/* [...]</info>
  7378. To run an update with more restrictive constraints you can use:
  7379. <info>php composer.phar update --with vendor/package:1.0.*</info>
  7380. To run a partial update with more restrictive constraints you can use the shorthand:
  7381. <info>php composer.phar update vendor/package:1.0.*</info>
  7382. To select packages names interactively with auto-completion use <info>-i</info>.
  7383. Read more at https://getcomposer.org/doc/03-cli.md#update-u
  7384. EOT
  7385. )
  7386. ;
  7387. }
  7388. protected function execute(InputInterface $input, OutputInterface $output)
  7389. {
  7390. $io = $this->getIO();
  7391. if ($input->getOption('dev')) {
  7392. $io->writeError('<warning>You are using the deprecated option "--dev". It has no effect and will break in Composer 3.</warning>');
  7393. }
  7394. if ($input->getOption('no-suggest')) {
  7395. $io->writeError('<warning>You are using the deprecated option "--no-suggest". It has no effect and will break in Composer 3.</warning>');
  7396. }
  7397. $composer = $this->getComposer(true, $input->getOption('no-plugins'));
  7398. if (!HttpDownloader::isCurlEnabled()) {
  7399. $io->writeError('<warning>Composer is operating significantly slower than normal because you do not have the PHP curl extension enabled.</warning>');
  7400. }
  7401. $packages = $input->getArgument('packages');
  7402. $reqs = $this->formatRequirements($input->getOption('with'));
  7403. if ($packages) {
  7404. $allowlistPackagesWithRequirements = array_filter($packages, function ($pkg) {
  7405. return preg_match('{\S+[ =:]\S+}', $pkg) > 0;
  7406. });
  7407. foreach ($this->formatRequirements($allowlistPackagesWithRequirements) as $package => $constraint) {
  7408. $reqs[$package] = $constraint;
  7409. }
  7410. foreach ($allowlistPackagesWithRequirements as $package) {
  7411. $packageName = preg_replace('{^([^ =:]+)[ =:].*$}', '$1', $package);
  7412. $index = array_search($package, $packages);
  7413. $packages[$index] = $packageName;
  7414. }
  7415. }
  7416. $rootRequires = $composer->getPackage()->getRequires();
  7417. $rootDevRequires = $composer->getPackage()->getDevRequires();
  7418. foreach ($reqs as $package => $constraint) {
  7419. if (isset($rootRequires[$package])) {
  7420. $rootRequires[$package] = $this->appendConstraintToLink($rootRequires[$package], $constraint);
  7421. } elseif (isset($rootDevRequires[$package])) {
  7422. $rootDevRequires[$package] = $this->appendConstraintToLink($rootDevRequires[$package], $constraint);
  7423. } else {
  7424. throw new \UnexpectedValueException('Only root package requirements can receive temporary constraints and '.$package.' is not one');
  7425. }
  7426. }
  7427. $composer->getPackage()->setRequires($rootRequires);
  7428. $composer->getPackage()->setDevRequires($rootDevRequires);
  7429. if ($input->getOption('interactive')) {
  7430. $packages = $this->getPackagesInteractively($io, $input, $output, $composer, $packages);
  7431. }
  7432. if ($input->getOption('root-reqs')) {
  7433. $requires = array_keys($rootRequires);
  7434. if (!$input->getOption('no-dev')) {
  7435. $requires = array_merge($requires, array_keys($rootDevRequires));
  7436. }
  7437. if (!empty($packages)) {
  7438. $packages = array_intersect($packages, $requires);
  7439. } else {
  7440. $packages = $requires;
  7441. }
  7442. }
  7443. $filteredPackages = array_filter($packages, function ($package) {
  7444. return !in_array($package, array('lock', 'nothing', 'mirrors'), true);
  7445. });
  7446. $updateMirrors = $input->getOption('lock') || count($filteredPackages) != count($packages);
  7447. $packages = $filteredPackages;
  7448. if ($updateMirrors && !empty($packages)) {
  7449. $io->writeError('<error>You cannot simultaneously update only a selection of packages and regenerate the lock file metadata.</error>');
  7450. return -1;
  7451. }
  7452. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'update', $input, $output);
  7453. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7454. $composer->getInstallationManager()->setOutputProgress(!$input->getOption('no-progress'));
  7455. $install = Installer::create($io, $composer);
  7456. $config = $composer->getConfig();
  7457. list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
  7458. $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');
  7459. $authoritative = $input->getOption('classmap-authoritative') || $config->get('classmap-authoritative');
  7460. $apcuPrefix = $input->getOption('apcu-autoloader-prefix');
  7461. $apcu = $apcuPrefix !== null || $input->getOption('apcu-autoloader') || $config->get('apcu-autoloader');
  7462. $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  7463. if ($input->getOption('with-all-dependencies')) {
  7464. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  7465. } elseif ($input->getOption('with-dependencies')) {
  7466. $updateAllowTransitiveDependencies = Request::UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE;
  7467. }
  7468. $ignorePlatformReqs = $input->getOption('ignore-platform-reqs') ?: ($input->getOption('ignore-platform-req') ?: false);
  7469. $install
  7470. ->setDryRun($input->getOption('dry-run'))
  7471. ->setVerbose($input->getOption('verbose'))
  7472. ->setPreferSource($preferSource)
  7473. ->setPreferDist($preferDist)
  7474. ->setDevMode(!$input->getOption('no-dev'))
  7475. ->setDumpAutoloader(!$input->getOption('no-autoloader'))
  7476. ->setRunScripts(!$input->getOption('no-scripts'))
  7477. ->setOptimizeAutoloader($optimize)
  7478. ->setClassMapAuthoritative($authoritative)
  7479. ->setApcuAutoloader($apcu, $apcuPrefix)
  7480. ->setUpdate(true)
  7481. ->setInstall(!$input->getOption('no-install'))
  7482. ->setUpdateMirrors($updateMirrors)
  7483. ->setUpdateAllowList($packages)
  7484. ->setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  7485. ->setIgnorePlatformRequirements($ignorePlatformReqs)
  7486. ->setPreferStable($input->getOption('prefer-stable'))
  7487. ->setPreferLowest($input->getOption('prefer-lowest'))
  7488. ;
  7489. if ($input->getOption('no-plugins')) {
  7490. $install->disablePlugins();
  7491. }
  7492. return $install->run();
  7493. }
  7494. private function getPackagesInteractively(IOInterface $io, InputInterface $input, OutputInterface $output, Composer $composer, array $packages)
  7495. {
  7496. if (!$input->isInteractive()) {
  7497. throw new \InvalidArgumentException('--interactive cannot be used in non-interactive terminals.');
  7498. }
  7499. $requires = array_merge(
  7500. $composer->getPackage()->getRequires(),
  7501. $composer->getPackage()->getDevRequires()
  7502. );
  7503. $autocompleterValues = array();
  7504. foreach ($requires as $require) {
  7505. $target = $require->getTarget();
  7506. $autocompleterValues[strtolower($target)] = $target;
  7507. }
  7508. $installedPackages = $composer->getRepositoryManager()->getLocalRepository()->getPackages();
  7509. foreach ($installedPackages as $package) {
  7510. $autocompleterValues[$package->getName()] = $package->getPrettyName();
  7511. }
  7512. $helper = $this->getHelper('question');
  7513. $question = new Question('<comment>Enter package name: </comment>', null);
  7514. $io->writeError('<info>Press enter without value to end submission</info>');
  7515. do {
  7516. $autocompleterValues = array_diff($autocompleterValues, $packages);
  7517. $question->setAutocompleterValues($autocompleterValues);
  7518. $addedPackage = $helper->ask($input, $output, $question);
  7519. if (!is_string($addedPackage) || empty($addedPackage)) {
  7520. break;
  7521. }
  7522. $addedPackage = strtolower($addedPackage);
  7523. if (!in_array($addedPackage, $packages)) {
  7524. $packages[] = $addedPackage;
  7525. }
  7526. } while (true);
  7527. $packages = array_filter($packages);
  7528. if (!$packages) {
  7529. throw new \InvalidArgumentException('You must enter minimum one package.');
  7530. }
  7531. $table = new Table($output);
  7532. $table->setHeaders(array('Selected packages'));
  7533. foreach ($packages as $package) {
  7534. $table->addRow(array($package));
  7535. }
  7536. $table->render();
  7537. if ($io->askConfirmation(sprintf(
  7538. 'Would you like to continue and update the above package%s [<comment>yes</comment>]? ',
  7539. 1 === count($packages) ? '' : 's'
  7540. ))) {
  7541. return $packages;
  7542. }
  7543. throw new \RuntimeException('Installation aborted.');
  7544. }
  7545. private function appendConstraintToLink(Link $link, $constraint)
  7546. {
  7547. $parser = new VersionParser;
  7548. $oldPrettyString = $link->getConstraint()->getPrettyString();
  7549. $newConstraint = MultiConstraint::create(array($link->getConstraint(), $parser->parseConstraints($constraint)));
  7550. $newConstraint->setPrettyString($oldPrettyString.', '.$constraint);
  7551. return new Link(
  7552. $link->getSource(),
  7553. $link->getTarget(),
  7554. $newConstraint,
  7555. $link->getDescription(),
  7556. $link->getPrettyConstraint() . ', ' . $constraint
  7557. );
  7558. }
  7559. }
  7560. <?php
  7561. namespace Composer\Command;
  7562. use Composer\Factory;
  7563. use Composer\Package\Loader\ValidatingArrayLoader;
  7564. use Composer\Plugin\CommandEvent;
  7565. use Composer\Plugin\PluginEvents;
  7566. use Composer\Util\ConfigValidator;
  7567. use Symfony\Component\Console\Input\InputArgument;
  7568. use Symfony\Component\Console\Input\InputInterface;
  7569. use Symfony\Component\Console\Input\InputOption;
  7570. use Symfony\Component\Console\Output\OutputInterface;
  7571. class ValidateCommand extends BaseCommand
  7572. {
  7573. protected function configure()
  7574. {
  7575. $this
  7576. ->setName('validate')
  7577. ->setDescription('Validates a composer.json and composer.lock.')
  7578. ->setDefinition(array(
  7579. new InputOption('no-check-all', null, InputOption::VALUE_NONE, 'Do not validate requires for overly strict/loose constraints'),
  7580. new InputOption('no-check-lock', null, InputOption::VALUE_NONE, 'Do not check if lock file is up to date'),
  7581. new InputOption('no-check-publish', null, InputOption::VALUE_NONE, 'Do not check for publish errors'),
  7582. new InputOption('no-check-version', null, InputOption::VALUE_NONE, 'Do not report a warning if the version field is present'),
  7583. new InputOption('with-dependencies', 'A', InputOption::VALUE_NONE, 'Also validate the composer.json of all installed dependencies'),
  7584. new InputOption('strict', null, InputOption::VALUE_NONE, 'Return a non-zero exit code for warnings as well as errors'),
  7585. new InputArgument('file', InputArgument::OPTIONAL, 'path to composer.json file'),
  7586. ))
  7587. ->setHelp(
  7588. <<<EOT
  7589. The validate command validates a given composer.json and composer.lock
  7590. Exit codes in case of errors are:
  7591. 1 validation warning(s), only when --strict is given
  7592. 2 validation error(s)
  7593. 3 file unreadable or missing
  7594. Read more at https://getcomposer.org/doc/03-cli.md#validate
  7595. EOT
  7596. );
  7597. }
  7598. protected function execute(InputInterface $input, OutputInterface $output)
  7599. {
  7600. $file = $input->getArgument('file') ?: Factory::getComposerFile();
  7601. $io = $this->getIO();
  7602. if (!file_exists($file)) {
  7603. $io->writeError('<error>' . $file . ' not found.</error>');
  7604. return 3;
  7605. }
  7606. if (!is_readable($file)) {
  7607. $io->writeError('<error>' . $file . ' is not readable.</error>');
  7608. return 3;
  7609. }
  7610. $validator = new ConfigValidator($io);
  7611. $checkAll = $input->getOption('no-check-all') ? 0 : ValidatingArrayLoader::CHECK_ALL;
  7612. $checkPublish = !$input->getOption('no-check-publish');
  7613. $checkLock = !$input->getOption('no-check-lock');
  7614. $checkVersion = $input->getOption('no-check-version') ? 0 : ConfigValidator::CHECK_VERSION;
  7615. $isStrict = $input->getOption('strict');
  7616. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  7617. $lockErrors = array();
  7618. $composer = Factory::create($io, $file, $input->hasParameterOption('--no-plugins'));
  7619. $locker = $composer->getLocker();
  7620. if ($locker->isLocked() && !$locker->isFresh()) {
  7621. $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>`.';
  7622. }
  7623. $this->outputResult($io, $file, $errors, $warnings, $checkPublish, $publishErrors, $checkLock, $lockErrors, true);
  7624. $exitCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  7625. if ($input->getOption('with-dependencies')) {
  7626. $localRepo = $composer->getRepositoryManager()->getLocalRepository();
  7627. foreach ($localRepo->getPackages() as $package) {
  7628. $path = $composer->getInstallationManager()->getInstallPath($package);
  7629. $file = $path . '/composer.json';
  7630. if (is_dir($path) && file_exists($file)) {
  7631. list($errors, $publishErrors, $warnings) = $validator->validate($file, $checkAll, $checkVersion);
  7632. $this->outputResult($io, $package->getPrettyName(), $errors, $warnings, $checkPublish, $publishErrors);
  7633. $depCode = $errors ? 2 : ($isStrict && $warnings ? 1 : 0);
  7634. $exitCode = max($depCode, $exitCode);
  7635. }
  7636. }
  7637. }
  7638. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'validate', $input, $output);
  7639. $eventCode = $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  7640. return max($eventCode, $exitCode);
  7641. }
  7642. private function outputResult($io, $name, &$errors, &$warnings, $checkPublish = false, $publishErrors = array(), $checkLock = false, $lockErrors = array(), $printSchemaUrl = false)
  7643. {
  7644. $doPrintSchemaUrl = false;
  7645. if ($errors) {
  7646. $io->writeError('<error>' . $name . ' is invalid, the following errors/warnings were found:</error>');
  7647. } elseif ($publishErrors) {
  7648. $io->writeError('<info>' . $name . ' is valid for simple usage with composer but has</info>');
  7649. $io->writeError('<info>strict errors that make it unable to be published as a package:</info>');
  7650. $doPrintSchemaUrl = $printSchemaUrl;
  7651. } elseif ($warnings) {
  7652. $io->writeError('<info>' . $name . ' is valid, but with a few warnings</info>');
  7653. $doPrintSchemaUrl = $printSchemaUrl;
  7654. } else {
  7655. $io->write('<info>' . $name . ' is valid</info>');
  7656. }
  7657. if ($doPrintSchemaUrl) {
  7658. $io->writeError('<warning>See https://getcomposer.org/doc/04-schema.md for details on the schema</warning>');
  7659. }
  7660. $extraWarnings = array();
  7661. if ($checkPublish) {
  7662. $errors = array_merge($errors, $publishErrors);
  7663. } else {
  7664. $extraWarnings = array_merge($extraWarnings, $publishErrors);
  7665. }
  7666. if ($checkLock) {
  7667. $errors = array_merge($errors, $lockErrors);
  7668. } else {
  7669. $extraWarnings = array_merge($extraWarnings, $lockErrors);
  7670. }
  7671. $messages = array(
  7672. 'error' => $errors,
  7673. 'warning' => array_merge($warnings, $extraWarnings),
  7674. );
  7675. foreach ($messages as $style => $msgs) {
  7676. foreach ($msgs as $msg) {
  7677. $io->writeError('<' . $style . '>' . $msg . '</' . $style . '>');
  7678. }
  7679. }
  7680. }
  7681. }
  7682. <?php
  7683. namespace Composer;
  7684. use Composer\Package\RootPackageInterface;
  7685. use Composer\Package\Locker;
  7686. use Composer\Util\Loop;
  7687. use Composer\Repository\RepositoryManager;
  7688. use Composer\Installer\InstallationManager;
  7689. use Composer\Plugin\PluginManager;
  7690. use Composer\Downloader\DownloadManager;
  7691. use Composer\EventDispatcher\EventDispatcher;
  7692. use Composer\Autoload\AutoloadGenerator;
  7693. use Composer\Package\Archiver\ArchiveManager;
  7694. class Composer
  7695. {
  7696. const VERSION = '2.0.9';
  7697. const BRANCH_ALIAS_VERSION = '';
  7698. const RELEASE_DATE = '2021-01-27 16:09:27';
  7699. const SOURCE_VERSION = '';
  7700. const RUNTIME_API_VERSION = '2.0.0';
  7701. public static function getVersion()
  7702. {
  7703. if (self::VERSION === '@package_version'.'@') {
  7704. return self::SOURCE_VERSION;
  7705. }
  7706. if (self::BRANCH_ALIAS_VERSION !== '' && preg_match('{^[a-f0-9]{40}$}', self::VERSION)) {
  7707. return self::BRANCH_ALIAS_VERSION.'+'.self::VERSION;
  7708. }
  7709. return self::VERSION;
  7710. }
  7711. private $package;
  7712. private $locker;
  7713. private $loop;
  7714. private $repositoryManager;
  7715. private $downloadManager;
  7716. private $installationManager;
  7717. private $pluginManager;
  7718. private $config;
  7719. private $eventDispatcher;
  7720. private $autoloadGenerator;
  7721. private $archiveManager;
  7722. public function setPackage(RootPackageInterface $package)
  7723. {
  7724. $this->package = $package;
  7725. }
  7726. public function getPackage()
  7727. {
  7728. return $this->package;
  7729. }
  7730. public function setConfig(Config $config)
  7731. {
  7732. $this->config = $config;
  7733. }
  7734. public function getConfig()
  7735. {
  7736. return $this->config;
  7737. }
  7738. public function setLocker(Locker $locker)
  7739. {
  7740. $this->locker = $locker;
  7741. }
  7742. public function getLocker()
  7743. {
  7744. return $this->locker;
  7745. }
  7746. public function setLoop(Loop $loop)
  7747. {
  7748. $this->loop = $loop;
  7749. }
  7750. public function getLoop()
  7751. {
  7752. return $this->loop;
  7753. }
  7754. public function setRepositoryManager(RepositoryManager $manager)
  7755. {
  7756. $this->repositoryManager = $manager;
  7757. }
  7758. public function getRepositoryManager()
  7759. {
  7760. return $this->repositoryManager;
  7761. }
  7762. public function setDownloadManager(DownloadManager $manager)
  7763. {
  7764. $this->downloadManager = $manager;
  7765. }
  7766. public function getDownloadManager()
  7767. {
  7768. return $this->downloadManager;
  7769. }
  7770. public function setArchiveManager(ArchiveManager $manager)
  7771. {
  7772. $this->archiveManager = $manager;
  7773. }
  7774. public function getArchiveManager()
  7775. {
  7776. return $this->archiveManager;
  7777. }
  7778. public function setInstallationManager(InstallationManager $manager)
  7779. {
  7780. $this->installationManager = $manager;
  7781. }
  7782. public function getInstallationManager()
  7783. {
  7784. return $this->installationManager;
  7785. }
  7786. public function setPluginManager(PluginManager $manager)
  7787. {
  7788. $this->pluginManager = $manager;
  7789. }
  7790. public function getPluginManager()
  7791. {
  7792. return $this->pluginManager;
  7793. }
  7794. public function setEventDispatcher(EventDispatcher $eventDispatcher)
  7795. {
  7796. $this->eventDispatcher = $eventDispatcher;
  7797. }
  7798. public function getEventDispatcher()
  7799. {
  7800. return $this->eventDispatcher;
  7801. }
  7802. public function setAutoloadGenerator(AutoloadGenerator $autoloadGenerator)
  7803. {
  7804. $this->autoloadGenerator = $autoloadGenerator;
  7805. }
  7806. public function getAutoloadGenerator()
  7807. {
  7808. return $this->autoloadGenerator;
  7809. }
  7810. }
  7811. <?php
  7812. namespace Composer;
  7813. use Composer\Config\ConfigSourceInterface;
  7814. use Composer\Downloader\TransportException;
  7815. use Composer\IO\IOInterface;
  7816. use Composer\Util\Platform;
  7817. use Composer\Util\ProcessExecutor;
  7818. class Config
  7819. {
  7820. const RELATIVE_PATHS = 1;
  7821. public static $defaultConfig = array(
  7822. 'process-timeout' => 300,
  7823. 'use-include-path' => false,
  7824. 'preferred-install' => 'auto',
  7825. 'notify-on-install' => true,
  7826. 'github-protocols' => array('https', 'ssh', 'git'),
  7827. 'vendor-dir' => 'vendor',
  7828. 'bin-dir' => '{$vendor-dir}/bin',
  7829. 'cache-dir' => '{$home}/cache',
  7830. 'data-dir' => '{$home}',
  7831. 'cache-files-dir' => '{$cache-dir}/files',
  7832. 'cache-repo-dir' => '{$cache-dir}/repo',
  7833. 'cache-vcs-dir' => '{$cache-dir}/vcs',
  7834. 'cache-ttl' => 15552000,
  7835. 'cache-files-ttl' => null,
  7836. 'cache-files-maxsize' => '300MiB',
  7837. 'cache-read-only' => false,
  7838. 'bin-compat' => 'auto',
  7839. 'discard-changes' => false,
  7840. 'autoloader-suffix' => null,
  7841. 'sort-packages' => false,
  7842. 'optimize-autoloader' => false,
  7843. 'classmap-authoritative' => false,
  7844. 'apcu-autoloader' => false,
  7845. 'prepend-autoloader' => true,
  7846. 'github-domains' => array('github.com'),
  7847. 'bitbucket-expose-hostname' => true,
  7848. 'disable-tls' => false,
  7849. 'secure-http' => true,
  7850. 'cafile' => null,
  7851. 'capath' => null,
  7852. 'github-expose-hostname' => true,
  7853. 'gitlab-domains' => array('gitlab.com'),
  7854. 'store-auths' => 'prompt',
  7855. 'platform' => array(),
  7856. 'archive-format' => 'tar',
  7857. 'archive-dir' => '.',
  7858. 'htaccess-protect' => true,
  7859. 'use-github-api' => true,
  7860. 'lock' => true,
  7861. 'platform-check' => 'php-only',
  7862. );
  7863. public static $defaultRepositories = array(
  7864. 'packagist.org' => array(
  7865. 'type' => 'composer',
  7866. 'url' => 'https?://repo.packagist.org',
  7867. 'allow_ssl_downgrade' => true,
  7868. ),
  7869. );
  7870. private $config;
  7871. private $baseDir;
  7872. private $repositories;
  7873. private $configSource;
  7874. private $authConfigSource;
  7875. private $useEnvironment;
  7876. private $warnedHosts = array();
  7877. public function __construct($useEnvironment = true, $baseDir = null)
  7878. {
  7879. $this->config = static::$defaultConfig;
  7880. $this->repositories = static::$defaultRepositories;
  7881. $this->useEnvironment = (bool) $useEnvironment;
  7882. $this->baseDir = $baseDir;
  7883. }
  7884. public function setConfigSource(ConfigSourceInterface $source)
  7885. {
  7886. $this->configSource = $source;
  7887. }
  7888. public function getConfigSource()
  7889. {
  7890. return $this->configSource;
  7891. }
  7892. public function setAuthConfigSource(ConfigSourceInterface $source)
  7893. {
  7894. $this->authConfigSource = $source;
  7895. }
  7896. public function getAuthConfigSource()
  7897. {
  7898. return $this->authConfigSource;
  7899. }
  7900. public function merge($config)
  7901. {
  7902. if (!empty($config['config']) && is_array($config['config'])) {
  7903. foreach ($config['config'] as $key => $val) {
  7904. if (in_array($key, array('bitbucket-oauth', 'github-oauth', 'gitlab-oauth', 'gitlab-token', 'http-basic', 'bearer')) && isset($this->config[$key])) {
  7905. $this->config[$key] = array_merge($this->config[$key], $val);
  7906. } elseif (in_array($key, array('gitlab-domains', 'github-domains')) && isset($this->config[$key])) {
  7907. $this->config[$key] = array_unique(array_merge($this->config[$key], $val));
  7908. } elseif ('preferred-install' === $key && isset($this->config[$key])) {
  7909. if (is_array($val) || is_array($this->config[$key])) {
  7910. if (is_string($val)) {
  7911. $val = array('*' => $val);
  7912. }
  7913. if (is_string($this->config[$key])) {
  7914. $this->config[$key] = array('*' => $this->config[$key]);
  7915. }
  7916. $this->config[$key] = array_merge($this->config[$key], $val);
  7917. if (isset($this->config[$key]['*'])) {
  7918. $wildcard = $this->config[$key]['*'];
  7919. unset($this->config[$key]['*']);
  7920. $this->config[$key]['*'] = $wildcard;
  7921. }
  7922. } else {
  7923. $this->config[$key] = $val;
  7924. }
  7925. } else {
  7926. $this->config[$key] = $val;
  7927. }
  7928. }
  7929. }
  7930. if (!empty($config['repositories']) && is_array($config['repositories'])) {
  7931. $this->repositories = array_reverse($this->repositories, true);
  7932. $newRepos = array_reverse($config['repositories'], true);
  7933. foreach ($newRepos as $name => $repository) {
  7934. if (false === $repository) {
  7935. $this->disableRepoByName($name);
  7936. continue;
  7937. }
  7938. if (is_array($repository) && 1 === count($repository) && false === current($repository)) {
  7939. $this->disableRepoByName(key($repository));
  7940. continue;
  7941. }
  7942. if (is_int($name)) {
  7943. $this->repositories[] = $repository;
  7944. } else {
  7945. if ($name === 'packagist') {
  7946. $this->repositories[$name . '.org'] = $repository;
  7947. } else {
  7948. $this->repositories[$name] = $repository;
  7949. }
  7950. }
  7951. }
  7952. $this->repositories = array_reverse($this->repositories, true);
  7953. }
  7954. }
  7955. public function getRepositories()
  7956. {
  7957. return $this->repositories;
  7958. }
  7959. public function get($key, $flags = 0)
  7960. {
  7961. switch ($key) {
  7962. case 'vendor-dir':
  7963. case 'bin-dir':
  7964. case 'process-timeout':
  7965. case 'data-dir':
  7966. case 'cache-dir':
  7967. case 'cache-files-dir':
  7968. case 'cache-repo-dir':
  7969. case 'cache-vcs-dir':
  7970. case 'cafile':
  7971. case 'capath':
  7972. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  7973. $val = $this->getComposerEnv($env);
  7974. $val = rtrim((string) $this->process(false !== $val ? $val : $this->config[$key], $flags), '/\\');
  7975. $val = Platform::expandPath($val);
  7976. if (substr($key, -4) !== '-dir') {
  7977. return $val;
  7978. }
  7979. return (($flags & self::RELATIVE_PATHS) == self::RELATIVE_PATHS) ? $val : $this->realpath($val);
  7980. case 'cache-read-only':
  7981. case 'htaccess-protect':
  7982. $env = 'COMPOSER_' . strtoupper(strtr($key, '-', '_'));
  7983. $val = $this->getComposerEnv($env);
  7984. if (false === $val) {
  7985. $val = $this->config[$key];
  7986. }
  7987. return $val !== 'false' && (bool) $val;
  7988. case 'disable-tls':
  7989. case 'secure-http':
  7990. case 'use-github-api':
  7991. case 'lock':
  7992. if ($key === 'secure-http' && $this->get('disable-tls') === true) {
  7993. return false;
  7994. }
  7995. return $this->config[$key] !== 'false' && (bool) $this->config[$key];
  7996. case 'cache-ttl':
  7997. return (int) $this->config[$key];
  7998. case 'cache-files-maxsize':
  7999. if (!preg_match('/^\s*([0-9.]+)\s*(?:([kmg])(?:i?b)?)?\s*$/i', $this->config[$key], $matches)) {
  8000. throw new \RuntimeException(
  8001. "Could not parse the value of '$key': {$this->config[$key]}"
  8002. );
  8003. }
  8004. $size = $matches[1];
  8005. if (isset($matches[2])) {
  8006. switch (strtolower($matches[2])) {
  8007. case 'g':
  8008. $size *= 1024;
  8009. case 'm':
  8010. $size *= 1024;
  8011. case 'k':
  8012. $size *= 1024;
  8013. break;
  8014. }
  8015. }
  8016. return $size;
  8017. case 'cache-files-ttl':
  8018. if (isset($this->config[$key])) {
  8019. return (int) $this->config[$key];
  8020. }
  8021. return (int) $this->config['cache-ttl'];
  8022. case 'home':
  8023. $val = preg_replace('#^(\$HOME|~)(/|$)#', rtrim(getenv('HOME') ?: getenv('USERPROFILE'), '/\\') . '/', $this->config[$key]);
  8024. return rtrim($this->process($val, $flags), '/\\');
  8025. case 'bin-compat':
  8026. $value = $this->getComposerEnv('COMPOSER_BIN_COMPAT') ?: $this->config[$key];
  8027. if (!in_array($value, array('auto', 'full'))) {
  8028. throw new \RuntimeException(
  8029. "Invalid value for 'bin-compat': {$value}. Expected auto, full"
  8030. );
  8031. }
  8032. return $value;
  8033. case 'discard-changes':
  8034. if ($env = $this->getComposerEnv('COMPOSER_DISCARD_CHANGES')) {
  8035. if (!in_array($env, array('stash', 'true', 'false', '1', '0'), true)) {
  8036. throw new \RuntimeException(
  8037. "Invalid value for COMPOSER_DISCARD_CHANGES: {$env}. Expected 1, 0, true, false or stash"
  8038. );
  8039. }
  8040. if ('stash' === $env) {
  8041. return 'stash';
  8042. }
  8043. return $env !== 'false' && (bool) $env;
  8044. }
  8045. if (!in_array($this->config[$key], array(true, false, 'stash'), true)) {
  8046. throw new \RuntimeException(
  8047. "Invalid value for 'discard-changes': {$this->config[$key]}. Expected true, false or stash"
  8048. );
  8049. }
  8050. return $this->config[$key];
  8051. case 'github-protocols':
  8052. $protos = $this->config['github-protocols'];
  8053. if ($this->config['secure-http'] && false !== ($index = array_search('git', $protos))) {
  8054. unset($protos[$index]);
  8055. }
  8056. if (reset($protos) === 'http') {
  8057. throw new \RuntimeException('The http protocol for github is not available anymore, update your config\'s github-protocols to use "https", "git" or "ssh"');
  8058. }
  8059. return $protos;
  8060. default:
  8061. if (!isset($this->config[$key])) {
  8062. return null;
  8063. }
  8064. return $this->process($this->config[$key], $flags);
  8065. }
  8066. }
  8067. public function all($flags = 0)
  8068. {
  8069. $all = array(
  8070. 'repositories' => $this->getRepositories(),
  8071. );
  8072. foreach (array_keys($this->config) as $key) {
  8073. $all['config'][$key] = $this->get($key, $flags);
  8074. }
  8075. return $all;
  8076. }
  8077. public function raw()
  8078. {
  8079. return array(
  8080. 'repositories' => $this->getRepositories(),
  8081. 'config' => $this->config,
  8082. );
  8083. }
  8084. public function has($key)
  8085. {
  8086. return array_key_exists($key, $this->config);
  8087. }
  8088. private function process($value, $flags)
  8089. {
  8090. $config = $this;
  8091. if (!is_string($value)) {
  8092. return $value;
  8093. }
  8094. return preg_replace_callback('#\{\$(.+)\}#', function ($match) use ($config, $flags) {
  8095. return $config->get($match[1], $flags);
  8096. }, $value);
  8097. }
  8098. private function realpath($path)
  8099. {
  8100. if (preg_match('{^(?:/|[a-z]:|[a-z0-9.]+://)}i', $path)) {
  8101. return $path;
  8102. }
  8103. return $this->baseDir . '/' . $path;
  8104. }
  8105. private function getComposerEnv($var)
  8106. {
  8107. if ($this->useEnvironment) {
  8108. return getenv($var);
  8109. }
  8110. return false;
  8111. }
  8112. private function disableRepoByName($name)
  8113. {
  8114. if (isset($this->repositories[$name])) {
  8115. unset($this->repositories[$name]);
  8116. } elseif ($name === 'packagist') {
  8117. unset($this->repositories['packagist.org']);
  8118. }
  8119. }
  8120. public function prohibitUrlByConfig($url, IOInterface $io = null)
  8121. {
  8122. if (false === filter_var($url, FILTER_VALIDATE_URL)) {
  8123. return;
  8124. }
  8125. $scheme = parse_url($url, PHP_URL_SCHEME);
  8126. if (in_array($scheme, array('http', 'git', 'ftp', 'svn'))) {
  8127. if ($this->get('secure-http')) {
  8128. throw new TransportException("Your configuration does not allow connections to $url. See https://getcomposer.org/doc/06-config.md#secure-http for details.");
  8129. }
  8130. if ($io) {
  8131. $host = parse_url($url, PHP_URL_HOST);
  8132. if (!isset($this->warnedHosts[$host])) {
  8133. $io->writeError("<warning>Warning: Accessing $host over $scheme which is an insecure protocol.</warning>");
  8134. }
  8135. $this->warnedHosts[$host] = true;
  8136. }
  8137. }
  8138. }
  8139. public static function disableProcessTimeout()
  8140. {
  8141. ProcessExecutor::setTimeout(0);
  8142. }
  8143. }
  8144. <?php
  8145. namespace Composer\Config;
  8146. interface ConfigSourceInterface
  8147. {
  8148. public function addRepository($name, $config, $append = true);
  8149. public function removeRepository($name);
  8150. public function addConfigSetting($name, $value);
  8151. public function removeConfigSetting($name);
  8152. public function addProperty($name, $value);
  8153. public function removeProperty($name);
  8154. public function addLink($type, $name, $value);
  8155. public function removeLink($type, $name);
  8156. public function getName();
  8157. }
  8158. <?php
  8159. namespace Composer\Config;
  8160. use Composer\Json\JsonFile;
  8161. use Composer\Json\JsonManipulator;
  8162. use Composer\Json\JsonValidationException;
  8163. use Composer\Util\Silencer;
  8164. class JsonConfigSource implements ConfigSourceInterface
  8165. {
  8166. private $file;
  8167. private $authConfig;
  8168. public function __construct(JsonFile $file, $authConfig = false)
  8169. {
  8170. $this->file = $file;
  8171. $this->authConfig = $authConfig;
  8172. }
  8173. public function getName()
  8174. {
  8175. return $this->file->getPath();
  8176. }
  8177. public function addRepository($name, $config, $append = true)
  8178. {
  8179. $this->manipulateJson('addRepository', $name, $config, $append, function (&$config, $repo, $repoConfig) use ($append) {
  8180. if (isset($config['repositories'])) {
  8181. foreach ($config['repositories'] as $index => $val) {
  8182. if ($index === $repo) {
  8183. continue;
  8184. }
  8185. if (is_numeric($index) && ($val === array('packagist' => false) || $val === array('packagist.org' => false))) {
  8186. unset($config['repositories'][$index]);
  8187. $config['repositories']['packagist.org'] = false;
  8188. break;
  8189. }
  8190. }
  8191. }
  8192. if ($append) {
  8193. $config['repositories'][$repo] = $repoConfig;
  8194. } else {
  8195. $config['repositories'] = array($repo => $repoConfig) + $config['repositories'];
  8196. }
  8197. });
  8198. }
  8199. public function removeRepository($name)
  8200. {
  8201. $this->manipulateJson('removeRepository', $name, function (&$config, $repo) {
  8202. unset($config['repositories'][$repo]);
  8203. });
  8204. }
  8205. public function addConfigSetting($name, $value)
  8206. {
  8207. $authConfig = $this->authConfig;
  8208. $this->manipulateJson('addConfigSetting', $name, $value, function (&$config, $key, $val) use ($authConfig) {
  8209. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8210. list($key, $host) = explode('.', $key, 2);
  8211. if ($authConfig) {
  8212. $config[$key][$host] = $val;
  8213. } else {
  8214. $config['config'][$key][$host] = $val;
  8215. }
  8216. } else {
  8217. $config['config'][$key] = $val;
  8218. }
  8219. });
  8220. }
  8221. public function removeConfigSetting($name)
  8222. {
  8223. $authConfig = $this->authConfig;
  8224. $this->manipulateJson('removeConfigSetting', $name, function (&$config, $key) use ($authConfig) {
  8225. if (preg_match('{^(bitbucket-oauth|github-oauth|gitlab-oauth|gitlab-token|bearer|http-basic|platform)\.}', $key)) {
  8226. list($key, $host) = explode('.', $key, 2);
  8227. if ($authConfig) {
  8228. unset($config[$key][$host]);
  8229. } else {
  8230. unset($config['config'][$key][$host]);
  8231. }
  8232. } else {
  8233. unset($config['config'][$key]);
  8234. }
  8235. });
  8236. }
  8237. public function addProperty($name, $value)
  8238. {
  8239. $this->manipulateJson('addProperty', $name, $value, function (&$config, $key, $val) {
  8240. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  8241. $bits = explode('.', $key);
  8242. $last = array_pop($bits);
  8243. $arr = &$config[reset($bits)];
  8244. foreach ($bits as $bit) {
  8245. if (!isset($arr[$bit])) {
  8246. $arr[$bit] = array();
  8247. }
  8248. $arr = &$arr[$bit];
  8249. }
  8250. $arr[$last] = $val;
  8251. } else {
  8252. $config[$key] = $val;
  8253. }
  8254. });
  8255. }
  8256. public function removeProperty($name)
  8257. {
  8258. $this->manipulateJson('removeProperty', $name, function (&$config, $key) {
  8259. if (strpos($key, 'extra.') === 0 || strpos($key, 'scripts.') === 0) {
  8260. $bits = explode('.', $key);
  8261. $last = array_pop($bits);
  8262. $arr = &$config[reset($bits)];
  8263. foreach ($bits as $bit) {
  8264. if (!isset($arr[$bit])) {
  8265. return;
  8266. }
  8267. $arr = &$arr[$bit];
  8268. }
  8269. unset($arr[$last]);
  8270. } else {
  8271. unset($config[$key]);
  8272. }
  8273. });
  8274. }
  8275. public function addLink($type, $name, $value)
  8276. {
  8277. $this->manipulateJson('addLink', $type, $name, $value, function (&$config, $type, $name, $value) {
  8278. $config[$type][$name] = $value;
  8279. });
  8280. }
  8281. public function removeLink($type, $name)
  8282. {
  8283. $this->manipulateJson('removeSubNode', $type, $name, function (&$config, $type, $name) {
  8284. unset($config[$type][$name]);
  8285. });
  8286. $this->manipulateJson('removeMainKeyIfEmpty', $type, function (&$config, $type) {
  8287. if (0 === count($config[$type])) {
  8288. unset($config[$type]);
  8289. }
  8290. });
  8291. }
  8292. protected function manipulateJson($method, $args, $fallback)
  8293. {
  8294. $args = func_get_args();
  8295. array_shift($args);
  8296. $fallback = array_pop($args);
  8297. if ($this->file->exists()) {
  8298. if (!is_writable($this->file->getPath())) {
  8299. throw new \RuntimeException(sprintf('The file "%s" is not writable.', $this->file->getPath()));
  8300. }
  8301. if (!is_readable($this->file->getPath())) {
  8302. throw new \RuntimeException(sprintf('The file "%s" is not readable.', $this->file->getPath()));
  8303. }
  8304. $contents = file_get_contents($this->file->getPath());
  8305. } elseif ($this->authConfig) {
  8306. $contents = "{\n}\n";
  8307. } else {
  8308. $contents = "{\n \"config\": {\n }\n}\n";
  8309. }
  8310. $manipulator = new JsonManipulator($contents);
  8311. $newFile = !$this->file->exists();
  8312. if ($this->authConfig && $method === 'addConfigSetting') {
  8313. $method = 'addSubNode';
  8314. list($mainNode, $name) = explode('.', $args[0], 2);
  8315. $args = array($mainNode, $name, $args[1]);
  8316. } elseif ($this->authConfig && $method === 'removeConfigSetting') {
  8317. $method = 'removeSubNode';
  8318. list($mainNode, $name) = explode('.', $args[0], 2);
  8319. $args = array($mainNode, $name);
  8320. }
  8321. if (call_user_func_array(array($manipulator, $method), $args)) {
  8322. file_put_contents($this->file->getPath(), $manipulator->getContents());
  8323. } else {
  8324. $config = $this->file->read();
  8325. $this->arrayUnshiftRef($args, $config);
  8326. call_user_func_array($fallback, $args);
  8327. foreach (array('require', 'require-dev', 'conflict', 'provide', 'replace', 'suggest', 'config', 'autoload', 'autoload-dev', 'scripts', 'scripts-descriptions', 'support') as $prop) {
  8328. if (isset($config[$prop]) && $config[$prop] === array()) {
  8329. $config[$prop] = new \stdClass;
  8330. }
  8331. }
  8332. foreach (array('psr-0', 'psr-4') as $prop) {
  8333. if (isset($config['autoload'][$prop]) && $config['autoload'][$prop] === array()) {
  8334. $config['autoload'][$prop] = new \stdClass;
  8335. }
  8336. if (isset($config['autoload-dev'][$prop]) && $config['autoload-dev'][$prop] === array()) {
  8337. $config['autoload-dev'][$prop] = new \stdClass;
  8338. }
  8339. }
  8340. foreach (array('platform', 'http-basic', 'bearer', 'gitlab-token', 'gitlab-oauth', 'github-oauth', 'preferred-install') as $prop) {
  8341. if (isset($config['config'][$prop]) && $config['config'][$prop] === array()) {
  8342. $config['config'][$prop] = new \stdClass;
  8343. }
  8344. }
  8345. $this->file->write($config);
  8346. }
  8347. try {
  8348. $this->file->validateSchema(JsonFile::LAX_SCHEMA);
  8349. } catch (JsonValidationException $e) {
  8350. file_put_contents($this->file->getPath(), $contents);
  8351. throw new \RuntimeException('Failed to update composer.json with a valid format, reverting to the original content. Please report an issue to us with details (command you run and a copy of your composer.json).', 0, $e);
  8352. }
  8353. if ($newFile) {
  8354. Silencer::call('chmod', $this->file->getPath(), 0600);
  8355. }
  8356. }
  8357. private function arrayUnshiftRef(&$array, &$value)
  8358. {
  8359. $return = array_unshift($array, '');
  8360. $array[0] = &$value;
  8361. return $return;
  8362. }
  8363. }
  8364. <?php
  8365. namespace Composer\Console;
  8366. use Composer\IO\NullIO;
  8367. use Composer\Util\Platform;
  8368. use Composer\Util\Silencer;
  8369. use Symfony\Component\Console\Application as BaseApplication;
  8370. use Symfony\Component\Console\Exception\CommandNotFoundException;
  8371. use Symfony\Component\Console\Helper\HelperSet;
  8372. use Symfony\Component\Console\Helper\QuestionHelper;
  8373. use Symfony\Component\Console\Input\InputInterface;
  8374. use Symfony\Component\Console\Input\InputOption;
  8375. use Symfony\Component\Console\Output\OutputInterface;
  8376. use Seld\JsonLint\ParsingException;
  8377. use Composer\Command;
  8378. use Composer\Composer;
  8379. use Composer\Factory;
  8380. use Composer\IO\IOInterface;
  8381. use Composer\IO\ConsoleIO;
  8382. use Composer\Json\JsonValidationException;
  8383. use Composer\Util\ErrorHandler;
  8384. use Composer\Util\HttpDownloader;
  8385. use Composer\EventDispatcher\ScriptExecutionException;
  8386. use Composer\Exception\NoSslException;
  8387. class Application extends BaseApplication
  8388. {
  8389. protected $composer;
  8390. protected $io;
  8391. private static $logo = ' ______
  8392. / ____/___ ____ ___ ____ ____ ________ _____
  8393. / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
  8394. / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
  8395. \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
  8396. /_/
  8397. ';
  8398. private $hasPluginCommands = false;
  8399. private $disablePluginsByDefault = false;
  8400. private $initialWorkingDirectory;
  8401. public function __construct()
  8402. {
  8403. static $shutdownRegistered = false;
  8404. if (function_exists('ini_set') && extension_loaded('xdebug')) {
  8405. ini_set('xdebug.show_exception_trace', false);
  8406. ini_set('xdebug.scream', false);
  8407. }
  8408. if (function_exists('date_default_timezone_set') && function_exists('date_default_timezone_get')) {
  8409. date_default_timezone_set(Silencer::call('date_default_timezone_get'));
  8410. }
  8411. if (!$shutdownRegistered) {
  8412. if (function_exists('pcntl_async_signals') && function_exists('pcntl_signal')) {
  8413. pcntl_async_signals(true);
  8414. pcntl_signal(SIGINT, function ($sig) {
  8415. exit(130);
  8416. });
  8417. }
  8418. $shutdownRegistered = true;
  8419. register_shutdown_function(function () {
  8420. $lastError = error_get_last();
  8421. if ($lastError && $lastError['message'] &&
  8422. (strpos($lastError['message'], 'Allowed memory') !== false ||
  8423. strpos($lastError['message'], 'exceeded memory') !== false )) {
  8424. echo "\n". 'Check https://getcomposer.org/doc/articles/troubleshooting.md#memory-limit-errors for more info on how to handle out of memory errors.';
  8425. }
  8426. });
  8427. }
  8428. $this->io = new NullIO();
  8429. $this->initialWorkingDirectory = getcwd();
  8430. parent::__construct('Composer', Composer::getVersion());
  8431. }
  8432. public function run(InputInterface $input = null, OutputInterface $output = null)
  8433. {
  8434. if (null === $output) {
  8435. $output = Factory::createOutput();
  8436. }
  8437. return parent::run($input, $output);
  8438. }
  8439. public function doRun(InputInterface $input, OutputInterface $output)
  8440. {
  8441. $this->disablePluginsByDefault = $input->hasParameterOption('--no-plugins');
  8442. if (getenv('COMPOSER_NO_INTERACTION') || !Platform::isTty(defined('STDIN') ? STDIN : fopen('php://stdin', 'r'))) {
  8443. $input->setInteractive(false);
  8444. }
  8445. $io = $this->io = new ConsoleIO($input, $output, new HelperSet(array(
  8446. new QuestionHelper(),
  8447. )));
  8448. ErrorHandler::register($io);
  8449. if ($input->hasParameterOption('--no-cache')) {
  8450. $io->writeError('Disabling cache usage', true, IOInterface::DEBUG);
  8451. $_SERVER['COMPOSER_CACHE_DIR'] = Platform::isWindows() ? 'nul' : '/dev/null';
  8452. putenv('COMPOSER_CACHE_DIR='.$_SERVER['COMPOSER_CACHE_DIR']);
  8453. }
  8454. if ($newWorkDir = $this->getNewWorkingDir($input)) {
  8455. $oldWorkingDir = getcwd();
  8456. chdir($newWorkDir);
  8457. $this->initialWorkingDirectory = $newWorkDir;
  8458. $io->writeError('Changed CWD to ' . getcwd(), true, IOInterface::DEBUG);
  8459. }
  8460. $commandName = '';
  8461. if ($name = $this->getCommandName($input)) {
  8462. try {
  8463. $commandName = $this->find($name)->getName();
  8464. } catch (CommandNotFoundException $e) {
  8465. $commandName = false;
  8466. } catch (\InvalidArgumentException $e) {
  8467. }
  8468. }
  8469. if ($io->isInteractive() && !$newWorkDir && !in_array($commandName, array('', 'list', 'init', 'about', 'help', 'diagnose', 'self-update', 'global', 'create-project', 'outdated'), true) && !file_exists(Factory::getComposerFile())) {
  8470. $dir = dirname(getcwd());
  8471. $home = realpath(getenv('HOME') ?: getenv('USERPROFILE') ?: '/');
  8472. while (dirname($dir) !== $dir && $dir !== $home) {
  8473. if (file_exists($dir.'/'.Factory::getComposerFile())) {
  8474. if ($io->askConfirmation('<info>No composer.json in current directory, do you want to use the one at '.$dir.'?</info> [<comment>Y,n</comment>]? ')) {
  8475. $oldWorkingDir = getcwd();
  8476. chdir($dir);
  8477. }
  8478. break;
  8479. }
  8480. $dir = dirname($dir);
  8481. }
  8482. }
  8483. if (!$this->disablePluginsByDefault && !$this->hasPluginCommands && 'global' !== $commandName) {
  8484. try {
  8485. foreach ($this->getPluginCommands() as $command) {
  8486. if ($this->has($command->getName())) {
  8487. $io->writeError('<warning>Plugin command '.$command->getName().' ('.get_class($command).') would override a Composer command and has been skipped</warning>');
  8488. } else {
  8489. $this->add($command);
  8490. }
  8491. }
  8492. } catch (NoSslException $e) {
  8493. } catch (ParsingException $e) {
  8494. $details = $e->getDetails();
  8495. $file = realpath(Factory::getComposerFile());
  8496. $line = null;
  8497. if ($details && isset($details['line'])) {
  8498. $line = $details['line'];
  8499. }
  8500. $ghe = new GithubActionError($this->io);
  8501. $ghe->emit($e->getMessage(), $file, $line);
  8502. throw $e;
  8503. }
  8504. $this->hasPluginCommands = true;
  8505. }
  8506. $isProxyCommand = false;
  8507. if ($name = $this->getCommandName($input)) {
  8508. try {
  8509. $command = $this->find($name);
  8510. $commandName = $command->getName();
  8511. $isProxyCommand = ($command instanceof Command\BaseCommand && $command->isProxyCommand());
  8512. } catch (\InvalidArgumentException $e) {
  8513. }
  8514. }
  8515. if (!$isProxyCommand) {
  8516. $io->writeError(sprintf(
  8517. 'Running %s (%s) with %s on %s',
  8518. Composer::getVersion(),
  8519. Composer::RELEASE_DATE,
  8520. defined('HHVM_VERSION') ? 'HHVM '.HHVM_VERSION : 'PHP '.PHP_VERSION,
  8521. function_exists('php_uname') ? php_uname('s') . ' / ' . php_uname('r') : 'Unknown OS'
  8522. ), true, IOInterface::DEBUG);
  8523. if (PHP_VERSION_ID < 50302) {
  8524. $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>');
  8525. }
  8526. if (extension_loaded('xdebug') && !getenv('COMPOSER_DISABLE_XDEBUG_WARN')) {
  8527. $io->writeError('<warning>Composer is operating slower than normal because you have Xdebug enabled. See https://getcomposer.org/xdebug</warning>');
  8528. }
  8529. if (defined('COMPOSER_DEV_WARNING_TIME') && $commandName !== 'self-update' && $commandName !== 'selfupdate' && time() > COMPOSER_DEV_WARNING_TIME) {
  8530. $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']));
  8531. }
  8532. if (
  8533. !Platform::isWindows()
  8534. && function_exists('exec')
  8535. && !getenv('COMPOSER_ALLOW_SUPERUSER')
  8536. && (ini_get('open_basedir') || !file_exists('/.dockerenv'))
  8537. ) {
  8538. if (function_exists('posix_getuid') && posix_getuid() === 0) {
  8539. if ($commandName !== 'self-update' && $commandName !== 'selfupdate') {
  8540. $io->writeError('<warning>Do not run Composer as root/super user! See https://getcomposer.org/root for details</warning>');
  8541. if ($io->isInteractive()) {
  8542. if (!$io->askConfirmation('<info>Continue as root/super user</info> [<comment>yes</comment>]? ')) {
  8543. return 1;
  8544. }
  8545. }
  8546. }
  8547. if ($uid = (int) getenv('SUDO_UID')) {
  8548. Silencer::call('exec', "sudo -u \\#{$uid} sudo -K > /dev/null 2>&1");
  8549. }
  8550. }
  8551. Silencer::call('exec', 'sudo -K > /dev/null 2>&1');
  8552. }
  8553. Silencer::call(function () use ($io) {
  8554. $tempfile = sys_get_temp_dir() . '/temp-' . md5(microtime());
  8555. if (!(file_put_contents($tempfile, __FILE__) && (file_get_contents($tempfile) == __FILE__) && unlink($tempfile) && !file_exists($tempfile))) {
  8556. $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()));
  8557. }
  8558. });
  8559. $file = Factory::getComposerFile();
  8560. if (is_file($file) && is_readable($file) && is_array($composer = json_decode(file_get_contents($file), true))) {
  8561. if (isset($composer['scripts']) && is_array($composer['scripts'])) {
  8562. foreach ($composer['scripts'] as $script => $dummy) {
  8563. if (!defined('Composer\Script\ScriptEvents::'.str_replace('-', '_', strtoupper($script)))) {
  8564. if ($this->has($script)) {
  8565. $io->writeError('<warning>A script named '.$script.' would override a Composer command and has been skipped</warning>');
  8566. } else {
  8567. $description = null;
  8568. if (isset($composer['scripts-descriptions'][$script])) {
  8569. $description = $composer['scripts-descriptions'][$script];
  8570. }
  8571. $this->add(new Command\ScriptAliasCommand($script, $description));
  8572. }
  8573. }
  8574. }
  8575. }
  8576. }
  8577. }
  8578. try {
  8579. if ($input->hasParameterOption('--profile')) {
  8580. $startTime = microtime(true);
  8581. $this->io->enableDebugging($startTime);
  8582. }
  8583. $result = parent::doRun($input, $output);
  8584. if (isset($oldWorkingDir)) {
  8585. Silencer::call('chdir', $oldWorkingDir);
  8586. }
  8587. if (isset($startTime)) {
  8588. $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');
  8589. }
  8590. restore_error_handler();
  8591. return $result;
  8592. } catch (ScriptExecutionException $e) {
  8593. return (int) $e->getCode();
  8594. } catch (\Exception $e) {
  8595. $ghe = new GithubActionError($this->io);
  8596. $ghe->emit($e->getMessage());
  8597. $this->hintCommonErrors($e);
  8598. restore_error_handler();
  8599. throw $e;
  8600. }
  8601. }
  8602. private function getNewWorkingDir(InputInterface $input)
  8603. {
  8604. $workingDir = $input->getParameterOption(array('--working-dir', '-d'));
  8605. if (false !== $workingDir && !is_dir($workingDir)) {
  8606. throw new \RuntimeException('Invalid working directory specified, '.$workingDir.' does not exist.');
  8607. }
  8608. return $workingDir;
  8609. }
  8610. private function hintCommonErrors($exception)
  8611. {
  8612. $io = $this->getIO();
  8613. Silencer::suppress();
  8614. try {
  8615. $composer = $this->getComposer(false, true);
  8616. if ($composer) {
  8617. $config = $composer->getConfig();
  8618. $minSpaceFree = 1024 * 1024;
  8619. if ((($df = disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  8620. || (($df = disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  8621. || (($df = disk_free_space($dir = sys_get_temp_dir())) !== false && $df < $minSpaceFree)
  8622. ) {
  8623. $io->writeError('<error>The disk hosting '.$dir.' is full, this may be the cause of the following exception</error>', true, IOInterface::QUIET);
  8624. }
  8625. }
  8626. } catch (\Exception $e) {
  8627. }
  8628. Silencer::restore();
  8629. if (Platform::isWindows() && false !== strpos($exception->getMessage(), 'The system cannot find the path specified')) {
  8630. $io->writeError('<error>The following exception may be caused by a stale entry in your cmd.exe AutoRun</error>', true, IOInterface::QUIET);
  8631. $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);
  8632. }
  8633. if (false !== strpos($exception->getMessage(), 'fork failed - Cannot allocate memory')) {
  8634. $io->writeError('<error>The following exception is caused by a lack of memory or swap, or not having swap configured</error>', true, IOInterface::QUIET);
  8635. $io->writeError('<error>Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details</error>', true, IOInterface::QUIET);
  8636. }
  8637. if ($hints = HttpDownloader::getExceptionHints($exception)) {
  8638. foreach ($hints as $hint) {
  8639. $io->writeError($hint, true, IOInterface::QUIET);
  8640. }
  8641. }
  8642. }
  8643. public function getComposer($required = true, $disablePlugins = null)
  8644. {
  8645. if (null === $disablePlugins) {
  8646. $disablePlugins = $this->disablePluginsByDefault;
  8647. }
  8648. if (null === $this->composer) {
  8649. try {
  8650. $this->composer = Factory::create($this->io, null, $disablePlugins);
  8651. } catch (\InvalidArgumentException $e) {
  8652. if ($required) {
  8653. $this->io->writeError($e->getMessage());
  8654. exit(1);
  8655. }
  8656. } catch (JsonValidationException $e) {
  8657. $errors = ' - ' . implode(PHP_EOL . ' - ', $e->getErrors());
  8658. $message = $e->getMessage() . ':' . PHP_EOL . $errors;
  8659. throw new JsonValidationException($message);
  8660. }
  8661. }
  8662. return $this->composer;
  8663. }
  8664. public function resetComposer()
  8665. {
  8666. $this->composer = null;
  8667. if ($this->getIO() && method_exists($this->getIO(), 'resetAuthentications')) {
  8668. $this->getIO()->resetAuthentications();
  8669. }
  8670. }
  8671. public function getIO()
  8672. {
  8673. return $this->io;
  8674. }
  8675. public function getHelp()
  8676. {
  8677. return self::$logo . parent::getHelp();
  8678. }
  8679. protected function getDefaultCommands()
  8680. {
  8681. $commands = array_merge(parent::getDefaultCommands(), array(
  8682. new Command\AboutCommand(),
  8683. new Command\ConfigCommand(),
  8684. new Command\DependsCommand(),
  8685. new Command\ProhibitsCommand(),
  8686. new Command\InitCommand(),
  8687. new Command\InstallCommand(),
  8688. new Command\CreateProjectCommand(),
  8689. new Command\UpdateCommand(),
  8690. new Command\SearchCommand(),
  8691. new Command\ValidateCommand(),
  8692. new Command\ShowCommand(),
  8693. new Command\SuggestsCommand(),
  8694. new Command\RequireCommand(),
  8695. new Command\DumpAutoloadCommand(),
  8696. new Command\StatusCommand(),
  8697. new Command\ArchiveCommand(),
  8698. new Command\DiagnoseCommand(),
  8699. new Command\RunScriptCommand(),
  8700. new Command\LicensesCommand(),
  8701. new Command\GlobalCommand(),
  8702. new Command\ClearCacheCommand(),
  8703. new Command\RemoveCommand(),
  8704. new Command\HomeCommand(),
  8705. new Command\ExecCommand(),
  8706. new Command\OutdatedCommand(),
  8707. new Command\CheckPlatformReqsCommand(),
  8708. new Command\FundCommand(),
  8709. ));
  8710. if (strpos(__FILE__, 'phar:') === 0) {
  8711. $commands[] = new Command\SelfUpdateCommand();
  8712. }
  8713. return $commands;
  8714. }
  8715. public function getLongVersion()
  8716. {
  8717. if (Composer::BRANCH_ALIAS_VERSION && Composer::BRANCH_ALIAS_VERSION !== '@package_branch_alias_version'.'@') {
  8718. return sprintf(
  8719. '<info>%s</info> version <comment>%s (%s)</comment> %s',
  8720. $this->getName(),
  8721. Composer::BRANCH_ALIAS_VERSION,
  8722. $this->getVersion(),
  8723. Composer::RELEASE_DATE
  8724. );
  8725. }
  8726. return parent::getLongVersion() . ' ' . Composer::RELEASE_DATE;
  8727. }
  8728. protected function getDefaultInputDefinition()
  8729. {
  8730. $definition = parent::getDefaultInputDefinition();
  8731. $definition->addOption(new InputOption('--profile', null, InputOption::VALUE_NONE, 'Display timing and memory usage information'));
  8732. $definition->addOption(new InputOption('--no-plugins', null, InputOption::VALUE_NONE, 'Whether to disable plugins.'));
  8733. $definition->addOption(new InputOption('--working-dir', '-d', InputOption::VALUE_REQUIRED, 'If specified, use the given directory as working directory.'));
  8734. $definition->addOption(new InputOption('--no-cache', null, InputOption::VALUE_NONE, 'Prevent use of the cache'));
  8735. return $definition;
  8736. }
  8737. private function getPluginCommands()
  8738. {
  8739. $commands = array();
  8740. $composer = $this->getComposer(false, false);
  8741. if (null === $composer) {
  8742. $composer = Factory::createGlobal($this->io);
  8743. }
  8744. if (null !== $composer) {
  8745. $pm = $composer->getPluginManager();
  8746. foreach ($pm->getPluginCapabilities('Composer\Plugin\Capability\CommandProvider', array('composer' => $composer, 'io' => $this->io)) as $capability) {
  8747. $newCommands = $capability->getCommands();
  8748. if (!is_array($newCommands)) {
  8749. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' failed to return an array from getCommands');
  8750. }
  8751. foreach ($newCommands as $command) {
  8752. if (!$command instanceof Command\BaseCommand) {
  8753. throw new \UnexpectedValueException('Plugin capability '.get_class($capability).' returned an invalid value, we expected an array of Composer\Command\BaseCommand objects');
  8754. }
  8755. }
  8756. $commands = array_merge($commands, $newCommands);
  8757. }
  8758. }
  8759. return $commands;
  8760. }
  8761. public function getInitialWorkingDirectory()
  8762. {
  8763. return $this->initialWorkingDirectory;
  8764. }
  8765. }
  8766. <?php
  8767. namespace Composer\Console;
  8768. use Composer\IO\IOInterface;
  8769. final class GithubActionError
  8770. {
  8771. protected $io;
  8772. public function __construct(IOInterface $io)
  8773. {
  8774. $this->io = $io;
  8775. }
  8776. public function emit($message, $file = null, $line = null)
  8777. {
  8778. if (getenv('GITHUB_ACTIONS') && !getenv('COMPOSER_TESTS_ARE_RUNNING')) {
  8779. $message = str_replace("\n", '%0A', $message);
  8780. if ($file && $line) {
  8781. $this->io->write("::error file=". $file .",line=". $line ."::". $message);
  8782. } elseif ($file) {
  8783. $this->io->write("::error file=". $file ."::". $message);
  8784. } else {
  8785. $this->io->write("::error ::". $message);
  8786. }
  8787. }
  8788. }
  8789. }
  8790. <?php
  8791. namespace Composer\Console;
  8792. use Symfony\Component\Console\Formatter\OutputFormatter;
  8793. class HtmlOutputFormatter extends OutputFormatter
  8794. {
  8795. private static $availableForegroundColors = array(
  8796. 30 => 'black',
  8797. 31 => 'red',
  8798. 32 => 'green',
  8799. 33 => 'yellow',
  8800. 34 => 'blue',
  8801. 35 => 'magenta',
  8802. 36 => 'cyan',
  8803. 37 => 'white',
  8804. );
  8805. private static $availableBackgroundColors = array(
  8806. 40 => 'black',
  8807. 41 => 'red',
  8808. 42 => 'green',
  8809. 43 => 'yellow',
  8810. 44 => 'blue',
  8811. 45 => 'magenta',
  8812. 46 => 'cyan',
  8813. 47 => 'white',
  8814. );
  8815. private static $availableOptions = array(
  8816. 1 => 'bold',
  8817. 4 => 'underscore',
  8818. );
  8819. public function __construct(array $styles = array())
  8820. {
  8821. parent::__construct(true, $styles);
  8822. }
  8823. public function format($message)
  8824. {
  8825. $formatted = parent::format($message);
  8826. $clearEscapeCodes = '(?:39|49|0|22|24|25|27|28)';
  8827. return preg_replace_callback("{\033\[([0-9;]+)m(.*?)\033\[(?:".$clearEscapeCodes.";)*?".$clearEscapeCodes."m}s", array($this, 'formatHtml'), $formatted);
  8828. }
  8829. private function formatHtml($matches)
  8830. {
  8831. $out = '<span style="';
  8832. foreach (explode(';', $matches[1]) as $code) {
  8833. if (isset(self::$availableForegroundColors[$code])) {
  8834. $out .= 'color:'.self::$availableForegroundColors[$code].';';
  8835. } elseif (isset(self::$availableBackgroundColors[$code])) {
  8836. $out .= 'background-color:'.self::$availableBackgroundColors[$code].';';
  8837. } elseif (isset(self::$availableOptions[$code])) {
  8838. switch (self::$availableOptions[$code]) {
  8839. case 'bold':
  8840. $out .= 'font-weight:bold;';
  8841. break;
  8842. case 'underscore':
  8843. $out .= 'text-decoration:underline;';
  8844. break;
  8845. }
  8846. }
  8847. }
  8848. return $out.'">'.$matches[2].'</span>';
  8849. }
  8850. }
  8851. <?php
  8852. namespace Composer\DependencyResolver;
  8853. class Decisions implements \Iterator, \Countable
  8854. {
  8855. const DECISION_LITERAL = 0;
  8856. const DECISION_REASON = 1;
  8857. protected $pool;
  8858. protected $decisionMap;
  8859. protected $decisionQueue = array();
  8860. public function __construct($pool)
  8861. {
  8862. $this->pool = $pool;
  8863. $this->decisionMap = array();
  8864. }
  8865. public function decide($literal, $level, $why)
  8866. {
  8867. $this->addDecision($literal, $level);
  8868. $this->decisionQueue[] = array(
  8869. self::DECISION_LITERAL => $literal,
  8870. self::DECISION_REASON => $why,
  8871. );
  8872. }
  8873. public function satisfy($literal)
  8874. {
  8875. $packageId = abs($literal);
  8876. return (
  8877. $literal > 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 ||
  8878. $literal < 0 && isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0
  8879. );
  8880. }
  8881. public function conflict($literal)
  8882. {
  8883. $packageId = abs($literal);
  8884. return (
  8885. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0 && $literal < 0) ||
  8886. (isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] < 0 && $literal > 0)
  8887. );
  8888. }
  8889. public function decided($literalOrPackageId)
  8890. {
  8891. return !empty($this->decisionMap[abs($literalOrPackageId)]);
  8892. }
  8893. public function undecided($literalOrPackageId)
  8894. {
  8895. return empty($this->decisionMap[abs($literalOrPackageId)]);
  8896. }
  8897. public function decidedInstall($literalOrPackageId)
  8898. {
  8899. $packageId = abs($literalOrPackageId);
  8900. return isset($this->decisionMap[$packageId]) && $this->decisionMap[$packageId] > 0;
  8901. }
  8902. public function decisionLevel($literalOrPackageId)
  8903. {
  8904. $packageId = abs($literalOrPackageId);
  8905. if (isset($this->decisionMap[$packageId])) {
  8906. return abs($this->decisionMap[$packageId]);
  8907. }
  8908. return 0;
  8909. }
  8910. public function decisionRule($literalOrPackageId)
  8911. {
  8912. $packageId = abs($literalOrPackageId);
  8913. foreach ($this->decisionQueue as $i => $decision) {
  8914. if ($packageId === abs($decision[self::DECISION_LITERAL])) {
  8915. return $decision[self::DECISION_REASON];
  8916. }
  8917. }
  8918. return null;
  8919. }
  8920. public function atOffset($queueOffset)
  8921. {
  8922. return $this->decisionQueue[$queueOffset];
  8923. }
  8924. public function validOffset($queueOffset)
  8925. {
  8926. return $queueOffset >= 0 && $queueOffset < \count($this->decisionQueue);
  8927. }
  8928. public function lastReason()
  8929. {
  8930. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_REASON];
  8931. }
  8932. public function lastLiteral()
  8933. {
  8934. return $this->decisionQueue[\count($this->decisionQueue) - 1][self::DECISION_LITERAL];
  8935. }
  8936. public function reset()
  8937. {
  8938. while ($decision = array_pop($this->decisionQueue)) {
  8939. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  8940. }
  8941. }
  8942. public function resetToOffset($offset)
  8943. {
  8944. while (\count($this->decisionQueue) > $offset + 1) {
  8945. $decision = array_pop($this->decisionQueue);
  8946. $this->decisionMap[abs($decision[self::DECISION_LITERAL])] = 0;
  8947. }
  8948. }
  8949. public function revertLast()
  8950. {
  8951. $this->decisionMap[abs($this->lastLiteral())] = 0;
  8952. array_pop($this->decisionQueue);
  8953. }
  8954. public function count()
  8955. {
  8956. return \count($this->decisionQueue);
  8957. }
  8958. public function rewind()
  8959. {
  8960. end($this->decisionQueue);
  8961. }
  8962. public function current()
  8963. {
  8964. return current($this->decisionQueue);
  8965. }
  8966. public function key()
  8967. {
  8968. return key($this->decisionQueue);
  8969. }
  8970. public function next()
  8971. {
  8972. return prev($this->decisionQueue);
  8973. }
  8974. public function valid()
  8975. {
  8976. return false !== current($this->decisionQueue);
  8977. }
  8978. public function isEmpty()
  8979. {
  8980. return \count($this->decisionQueue) === 0;
  8981. }
  8982. protected function addDecision($literal, $level)
  8983. {
  8984. $packageId = abs($literal);
  8985. $previousDecision = isset($this->decisionMap[$packageId]) ? $this->decisionMap[$packageId] : null;
  8986. if ($previousDecision != 0) {
  8987. $literalString = $this->pool->literalToPrettyString($literal, array());
  8988. $package = $this->pool->literalToPackage($literal);
  8989. throw new SolverBugException(
  8990. "Trying to decide $literalString on level $level, even though $package was previously decided as ".(int) $previousDecision."."
  8991. );
  8992. }
  8993. if ($literal > 0) {
  8994. $this->decisionMap[$packageId] = $level;
  8995. } else {
  8996. $this->decisionMap[$packageId] = -$level;
  8997. }
  8998. }
  8999. public function toString(Pool $pool = null)
  9000. {
  9001. $decisionMap = $this->decisionMap;
  9002. ksort($decisionMap);
  9003. $str = '[';
  9004. foreach ($decisionMap as $packageId => $level) {
  9005. $str .= (($pool) ? $pool->literalToPackage($packageId) : $packageId).':'.$level.',';
  9006. }
  9007. $str .= ']';
  9008. return $str;
  9009. }
  9010. public function __toString()
  9011. {
  9012. return $this->toString();
  9013. }
  9014. }
  9015. <?php
  9016. namespace Composer\DependencyResolver;
  9017. use Composer\Package\PackageInterface;
  9018. use Composer\Package\AliasPackage;
  9019. use Composer\Package\BasePackage;
  9020. use Composer\Semver\Constraint\Constraint;
  9021. class DefaultPolicy implements PolicyInterface
  9022. {
  9023. private $preferStable;
  9024. private $preferLowest;
  9025. public function __construct($preferStable = false, $preferLowest = false)
  9026. {
  9027. $this->preferStable = $preferStable;
  9028. $this->preferLowest = $preferLowest;
  9029. }
  9030. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator)
  9031. {
  9032. if ($this->preferStable && ($stabA = $a->getStability()) !== ($stabB = $b->getStability())) {
  9033. return BasePackage::$stabilities[$stabA] < BasePackage::$stabilities[$stabB];
  9034. }
  9035. $constraint = new Constraint($operator, $b->getVersion());
  9036. $version = new Constraint('==', $a->getVersion());
  9037. return $constraint->matchSpecific($version, true);
  9038. }
  9039. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null)
  9040. {
  9041. $packages = $this->groupLiteralsByName($pool, $literals);
  9042. $policy = $this;
  9043. foreach ($packages as &$nameLiterals) {
  9044. usort($nameLiterals, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  9045. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage, true);
  9046. });
  9047. }
  9048. foreach ($packages as &$sortedLiterals) {
  9049. $sortedLiterals = $this->pruneToBestVersion($pool, $sortedLiterals);
  9050. $sortedLiterals = $this->pruneRemoteAliases($pool, $sortedLiterals);
  9051. }
  9052. $selected = \call_user_func_array('array_merge', array_values($packages));
  9053. usort($selected, function ($a, $b) use ($policy, $pool, $requiredPackage) {
  9054. return $policy->compareByPriority($pool, $pool->literalToPackage($a), $pool->literalToPackage($b), $requiredPackage);
  9055. });
  9056. return $selected;
  9057. }
  9058. protected function groupLiteralsByName(Pool $pool, $literals)
  9059. {
  9060. $packages = array();
  9061. foreach ($literals as $literal) {
  9062. $packageName = $pool->literalToPackage($literal)->getName();
  9063. if (!isset($packages[$packageName])) {
  9064. $packages[$packageName] = array();
  9065. }
  9066. $packages[$packageName][] = $literal;
  9067. }
  9068. return $packages;
  9069. }
  9070. public function compareByPriority(Pool $pool, PackageInterface $a, PackageInterface $b, $requiredPackage = null, $ignoreReplace = false)
  9071. {
  9072. if ($a->getName() === $b->getName()) {
  9073. $aAliased = $a instanceof AliasPackage;
  9074. $bAliased = $b instanceof AliasPackage;
  9075. if ($aAliased && !$bAliased) {
  9076. return -1;
  9077. }
  9078. if (!$aAliased && $bAliased) {
  9079. return 1;
  9080. }
  9081. }
  9082. if (!$ignoreReplace) {
  9083. if ($this->replaces($a, $b)) {
  9084. return 1;
  9085. }
  9086. if ($this->replaces($b, $a)) {
  9087. return -1;
  9088. }
  9089. if ($requiredPackage && false !== ($pos = strpos($requiredPackage, '/'))) {
  9090. $requiredVendor = substr($requiredPackage, 0, $pos);
  9091. $aIsSameVendor = strpos($a->getName(), $requiredVendor) === 0;
  9092. $bIsSameVendor = strpos($b->getName(), $requiredVendor) === 0;
  9093. if ($bIsSameVendor !== $aIsSameVendor) {
  9094. return $aIsSameVendor ? -1 : 1;
  9095. }
  9096. }
  9097. }
  9098. if ($a->id === $b->id) {
  9099. return 0;
  9100. }
  9101. return ($a->id < $b->id) ? -1 : 1;
  9102. }
  9103. protected function replaces(PackageInterface $source, PackageInterface $target)
  9104. {
  9105. foreach ($source->getReplaces() as $link) {
  9106. if ($link->getTarget() === $target->getName()
  9107. ) {
  9108. return true;
  9109. }
  9110. }
  9111. return false;
  9112. }
  9113. protected function pruneToBestVersion(Pool $pool, $literals)
  9114. {
  9115. $operator = $this->preferLowest ? '<' : '>';
  9116. $bestLiterals = array($literals[0]);
  9117. $bestPackage = $pool->literalToPackage($literals[0]);
  9118. foreach ($literals as $i => $literal) {
  9119. if (0 === $i) {
  9120. continue;
  9121. }
  9122. $package = $pool->literalToPackage($literal);
  9123. if ($this->versionCompare($package, $bestPackage, $operator)) {
  9124. $bestPackage = $package;
  9125. $bestLiterals = array($literal);
  9126. } elseif ($this->versionCompare($package, $bestPackage, '==')) {
  9127. $bestLiterals[] = $literal;
  9128. }
  9129. }
  9130. return $bestLiterals;
  9131. }
  9132. protected function pruneRemoteAliases(Pool $pool, array $literals)
  9133. {
  9134. $hasLocalAlias = false;
  9135. foreach ($literals as $literal) {
  9136. $package = $pool->literalToPackage($literal);
  9137. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9138. $hasLocalAlias = true;
  9139. break;
  9140. }
  9141. }
  9142. if (!$hasLocalAlias) {
  9143. return $literals;
  9144. }
  9145. $selected = array();
  9146. foreach ($literals as $literal) {
  9147. $package = $pool->literalToPackage($literal);
  9148. if ($package instanceof AliasPackage && $package->isRootPackageAlias()) {
  9149. $selected[] = $literal;
  9150. }
  9151. }
  9152. return $selected;
  9153. }
  9154. }
  9155. <?php
  9156. namespace Composer\DependencyResolver;
  9157. use Composer\Package\PackageInterface;
  9158. use Composer\Package\Link;
  9159. class GenericRule extends Rule
  9160. {
  9161. protected $literals;
  9162. public function __construct(array $literals, $reason, $reasonData)
  9163. {
  9164. parent::__construct($reason, $reasonData);
  9165. sort($literals);
  9166. $this->literals = $literals;
  9167. }
  9168. public function getLiterals()
  9169. {
  9170. return $this->literals;
  9171. }
  9172. public function getHash()
  9173. {
  9174. $data = unpack('ihash', md5(implode(',', $this->literals), true));
  9175. return $data['hash'];
  9176. }
  9177. public function equals(Rule $rule)
  9178. {
  9179. return $this->literals === $rule->getLiterals();
  9180. }
  9181. public function isAssertion()
  9182. {
  9183. return 1 === \count($this->literals);
  9184. }
  9185. public function __toString()
  9186. {
  9187. $result = $this->isDisabled() ? 'disabled(' : '(';
  9188. foreach ($this->literals as $i => $literal) {
  9189. if ($i != 0) {
  9190. $result .= '|';
  9191. }
  9192. $result .= $literal;
  9193. }
  9194. $result .= ')';
  9195. return $result;
  9196. }
  9197. }
  9198. <?php
  9199. namespace Composer\DependencyResolver;
  9200. use Composer\Repository\RepositoryInterface;
  9201. class LocalRepoTransaction extends Transaction
  9202. {
  9203. public function __construct(RepositoryInterface $lockedRepository, $localRepository)
  9204. {
  9205. parent::__construct(
  9206. $localRepository->getPackages(),
  9207. $lockedRepository->getPackages()
  9208. );
  9209. }
  9210. }
  9211. <?php
  9212. namespace Composer\DependencyResolver;
  9213. use Composer\Package\AliasPackage;
  9214. use Composer\Package\RootAliasPackage;
  9215. class LockTransaction extends Transaction
  9216. {
  9217. protected $presentMap;
  9218. protected $unlockableMap;
  9219. protected $resultPackages;
  9220. public function __construct(Pool $pool, $presentMap, $unlockableMap, $decisions)
  9221. {
  9222. $this->presentMap = $presentMap;
  9223. $this->unlockableMap = $unlockableMap;
  9224. $this->setResultPackages($pool, $decisions);
  9225. parent::__construct($this->presentMap, $this->resultPackages['all']);
  9226. }
  9227. public function setResultPackages(Pool $pool, Decisions $decisions)
  9228. {
  9229. $this->resultPackages = array('all' => array(), 'non-dev' => array(), 'dev' => array());
  9230. foreach ($decisions as $i => $decision) {
  9231. $literal = $decision[Decisions::DECISION_LITERAL];
  9232. if ($literal > 0) {
  9233. $package = $pool->literalToPackage($literal);
  9234. $this->resultPackages['all'][] = $package;
  9235. if (!isset($this->unlockableMap[$package->id])) {
  9236. $this->resultPackages['non-dev'][] = $package;
  9237. }
  9238. }
  9239. }
  9240. }
  9241. public function setNonDevPackages(LockTransaction $extractionResult)
  9242. {
  9243. $packages = $extractionResult->getNewLockPackages(false);
  9244. $this->resultPackages['dev'] = $this->resultPackages['non-dev'];
  9245. $this->resultPackages['non-dev'] = array();
  9246. foreach ($packages as $package) {
  9247. foreach ($this->resultPackages['dev'] as $i => $resultPackage) {
  9248. if ($package->getName() == $resultPackage->getName()) {
  9249. $this->resultPackages['non-dev'][] = $resultPackage;
  9250. unset($this->resultPackages['dev'][$i]);
  9251. }
  9252. }
  9253. }
  9254. }
  9255. public function getNewLockPackages($devMode, $updateMirrors = false)
  9256. {
  9257. $packages = array();
  9258. foreach ($this->resultPackages[$devMode ? 'dev' : 'non-dev'] as $package) {
  9259. if (!($package instanceof AliasPackage) && !($package instanceof RootAliasPackage)) {
  9260. if ($updateMirrors && !isset($this->presentMap[spl_object_hash($package)])) {
  9261. foreach ($this->presentMap as $presentPackage) {
  9262. if ($package->getName() == $presentPackage->getName() &&
  9263. $package->getVersion() == $presentPackage->getVersion() &&
  9264. $presentPackage->getSourceReference() &&
  9265. $presentPackage->getSourceType() === $package->getSourceType()
  9266. ) {
  9267. $package->setSourceDistReferences($presentPackage->getSourceReference());
  9268. }
  9269. }
  9270. }
  9271. $packages[] = $package;
  9272. }
  9273. }
  9274. return $packages;
  9275. }
  9276. public function getAliases($aliases)
  9277. {
  9278. $usedAliases = array();
  9279. foreach ($this->resultPackages['all'] as $package) {
  9280. if ($package instanceof AliasPackage) {
  9281. foreach ($aliases as $index => $alias) {
  9282. if ($alias['package'] === $package->getName()) {
  9283. $usedAliases[] = $alias;
  9284. unset($aliases[$index]);
  9285. }
  9286. }
  9287. }
  9288. }
  9289. usort($usedAliases, function ($a, $b) {
  9290. return strcmp($a['package'], $b['package']);
  9291. });
  9292. return $usedAliases;
  9293. }
  9294. }
  9295. <?php
  9296. namespace Composer\DependencyResolver;
  9297. use Composer\Package\PackageInterface;
  9298. use Composer\Package\Link;
  9299. class MultiConflictRule extends Rule
  9300. {
  9301. protected $literals;
  9302. public function __construct(array $literals, $reason, $reasonData)
  9303. {
  9304. parent::__construct($reason, $reasonData);
  9305. if (\count($literals) < 3) {
  9306. throw new \RuntimeException("multi conflict rule requires at least 3 literals");
  9307. }
  9308. sort($literals);
  9309. $this->literals = $literals;
  9310. }
  9311. public function getLiterals()
  9312. {
  9313. return $this->literals;
  9314. }
  9315. public function getHash()
  9316. {
  9317. $data = unpack('ihash', md5('c:'.implode(',', $this->literals), true));
  9318. return $data['hash'];
  9319. }
  9320. public function equals(Rule $rule)
  9321. {
  9322. if ($rule instanceof MultiConflictRule) {
  9323. return $this->literals === $rule->getLiterals();
  9324. }
  9325. return false;
  9326. }
  9327. public function isAssertion()
  9328. {
  9329. return false;
  9330. }
  9331. public function disable()
  9332. {
  9333. 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.");
  9334. }
  9335. public function __toString()
  9336. {
  9337. $result = $this->isDisabled() ? 'disabled(multi(' : '(multi(';
  9338. foreach ($this->literals as $i => $literal) {
  9339. if ($i != 0) {
  9340. $result .= '|';
  9341. }
  9342. $result .= $literal;
  9343. }
  9344. $result .= '))';
  9345. return $result;
  9346. }
  9347. }
  9348. <?php
  9349. namespace Composer\DependencyResolver\Operation;
  9350. use Composer\Package\PackageInterface;
  9351. class InstallOperation extends SolverOperation implements OperationInterface
  9352. {
  9353. const TYPE = 'install';
  9354. protected $package;
  9355. public function __construct(PackageInterface $package)
  9356. {
  9357. $this->package = $package;
  9358. }
  9359. public function getPackage()
  9360. {
  9361. return $this->package;
  9362. }
  9363. public function show($lock)
  9364. {
  9365. return self::format($this->package, $lock);
  9366. }
  9367. public static function format(PackageInterface $package, $lock = false)
  9368. {
  9369. return ($lock ? 'Locking ' : 'Installing ').'<info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  9370. }
  9371. }
  9372. <?php
  9373. namespace Composer\DependencyResolver\Operation;
  9374. use Composer\Package\AliasPackage;
  9375. class MarkAliasInstalledOperation extends SolverOperation implements OperationInterface
  9376. {
  9377. const TYPE = 'markAliasInstalled';
  9378. protected $package;
  9379. public function __construct(AliasPackage $package)
  9380. {
  9381. $this->package = $package;
  9382. }
  9383. public function getPackage()
  9384. {
  9385. return $this->package;
  9386. }
  9387. public function show($lock)
  9388. {
  9389. 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>)';
  9390. }
  9391. }
  9392. <?php
  9393. namespace Composer\DependencyResolver\Operation;
  9394. use Composer\Package\AliasPackage;
  9395. class MarkAliasUninstalledOperation extends SolverOperation implements OperationInterface
  9396. {
  9397. const TYPE = 'markAliasUninstalled';
  9398. protected $package;
  9399. public function __construct(AliasPackage $package)
  9400. {
  9401. $this->package = $package;
  9402. }
  9403. public function getPackage()
  9404. {
  9405. return $this->package;
  9406. }
  9407. public function show($lock)
  9408. {
  9409. 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>)';
  9410. }
  9411. }
  9412. <?php
  9413. namespace Composer\DependencyResolver\Operation;
  9414. interface OperationInterface
  9415. {
  9416. public function getOperationType();
  9417. public function show($lock);
  9418. public function __toString();
  9419. }
  9420. <?php
  9421. namespace Composer\DependencyResolver\Operation;
  9422. abstract class SolverOperation implements OperationInterface
  9423. {
  9424. const TYPE = null;
  9425. public function getOperationType()
  9426. {
  9427. return static::TYPE;
  9428. }
  9429. public function __toString()
  9430. {
  9431. return $this->show(false);
  9432. }
  9433. }
  9434. <?php
  9435. namespace Composer\DependencyResolver\Operation;
  9436. use Composer\Package\PackageInterface;
  9437. class UninstallOperation extends SolverOperation implements OperationInterface
  9438. {
  9439. const TYPE = 'uninstall';
  9440. protected $package;
  9441. public function __construct(PackageInterface $package)
  9442. {
  9443. $this->package = $package;
  9444. }
  9445. public function getPackage()
  9446. {
  9447. return $this->package;
  9448. }
  9449. public function show($lock)
  9450. {
  9451. return self::format($this->package, $lock);
  9452. }
  9453. public static function format(PackageInterface $package, $lock = false)
  9454. {
  9455. return 'Removing <info>'.$package->getPrettyName().'</info> (<comment>'.$package->getFullPrettyVersion().'</comment>)';
  9456. }
  9457. }
  9458. <?php
  9459. namespace Composer\DependencyResolver\Operation;
  9460. use Composer\Package\PackageInterface;
  9461. use Composer\Package\Version\VersionParser;
  9462. class UpdateOperation extends SolverOperation implements OperationInterface
  9463. {
  9464. const TYPE = 'update';
  9465. protected $initialPackage;
  9466. protected $targetPackage;
  9467. public function __construct(PackageInterface $initial, PackageInterface $target)
  9468. {
  9469. $this->initialPackage = $initial;
  9470. $this->targetPackage = $target;
  9471. }
  9472. public function getInitialPackage()
  9473. {
  9474. return $this->initialPackage;
  9475. }
  9476. public function getTargetPackage()
  9477. {
  9478. return $this->targetPackage;
  9479. }
  9480. public function show($lock)
  9481. {
  9482. return self::format($this->initialPackage, $this->targetPackage, $lock);
  9483. }
  9484. public static function format(PackageInterface $initialPackage, PackageInterface $targetPackage, $lock = false)
  9485. {
  9486. $fromVersion = $initialPackage->getFullPrettyVersion();
  9487. $toVersion = $targetPackage->getFullPrettyVersion();
  9488. if ($fromVersion === $toVersion && $initialPackage->getSourceReference() !== $targetPackage->getSourceReference()) {
  9489. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  9490. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_SOURCE_REF);
  9491. } elseif ($fromVersion === $toVersion && $initialPackage->getDistReference() !== $targetPackage->getDistReference()) {
  9492. $fromVersion = $initialPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  9493. $toVersion = $targetPackage->getFullPrettyVersion(true, PackageInterface::DISPLAY_DIST_REF);
  9494. }
  9495. $actionName = VersionParser::isUpgrade($initialPackage->getVersion(), $targetPackage->getVersion()) ? 'Upgrading' : 'Downgrading';
  9496. return $actionName.' <info>'.$initialPackage->getPrettyName().'</info> (<comment>'.$fromVersion.'</comment> => <comment>'.$toVersion.'</comment>)';
  9497. }
  9498. }
  9499. <?php
  9500. namespace Composer\DependencyResolver;
  9501. use Composer\Package\PackageInterface;
  9502. interface PolicyInterface
  9503. {
  9504. public function versionCompare(PackageInterface $a, PackageInterface $b, $operator);
  9505. public function selectPreferredPackages(Pool $pool, array $literals, $requiredPackage = null);
  9506. }
  9507. <?php
  9508. namespace Composer\DependencyResolver;
  9509. use Composer\Package\Version\VersionParser;
  9510. use Composer\Semver\CompilingMatcher;
  9511. use Composer\Semver\Constraint\ConstraintInterface;
  9512. use Composer\Semver\Constraint\Constraint;
  9513. use Composer\Package\PackageInterface;
  9514. class Pool implements \Countable
  9515. {
  9516. protected $packages = array();
  9517. protected $packageByName = array();
  9518. protected $versionParser;
  9519. protected $providerCache = array();
  9520. protected $unacceptableFixedOrLockedPackages;
  9521. public function __construct(array $packages = array(), array $unacceptableFixedOrLockedPackages = array())
  9522. {
  9523. $this->versionParser = new VersionParser;
  9524. $this->setPackages($packages);
  9525. $this->unacceptableFixedOrLockedPackages = $unacceptableFixedOrLockedPackages;
  9526. }
  9527. private function setPackages(array $packages)
  9528. {
  9529. $id = 1;
  9530. foreach ($packages as $package) {
  9531. $this->packages[] = $package;
  9532. $package->id = $id++;
  9533. foreach ($package->getNames() as $provided) {
  9534. $this->packageByName[$provided][] = $package;
  9535. }
  9536. }
  9537. }
  9538. public function getPackages()
  9539. {
  9540. return $this->packages;
  9541. }
  9542. public function packageById($id)
  9543. {
  9544. return $this->packages[$id - 1];
  9545. }
  9546. public function count()
  9547. {
  9548. return \count($this->packages);
  9549. }
  9550. public function whatProvides($name, ConstraintInterface $constraint = null)
  9551. {
  9552. $key = (string) $constraint;
  9553. if (isset($this->providerCache[$name][$key])) {
  9554. return $this->providerCache[$name][$key];
  9555. }
  9556. return $this->providerCache[$name][$key] = $this->computeWhatProvides($name, $constraint);
  9557. }
  9558. private function computeWhatProvides($name, $constraint)
  9559. {
  9560. if (!isset($this->packageByName[$name])) {
  9561. return array();
  9562. }
  9563. $matches = array();
  9564. foreach ($this->packageByName[$name] as $candidate) {
  9565. if ($this->match($candidate, $name, $constraint)) {
  9566. $matches[] = $candidate;
  9567. }
  9568. }
  9569. return $matches;
  9570. }
  9571. public function literalToPackage($literal)
  9572. {
  9573. $packageId = abs($literal);
  9574. return $this->packageById($packageId);
  9575. }
  9576. public function literalToPrettyString($literal, $installedMap)
  9577. {
  9578. $package = $this->literalToPackage($literal);
  9579. if (isset($installedMap[$package->id])) {
  9580. $prefix = ($literal > 0 ? 'keep' : 'remove');
  9581. } else {
  9582. $prefix = ($literal > 0 ? 'install' : 'don\'t install');
  9583. }
  9584. return $prefix.' '.$package->getPrettyString();
  9585. }
  9586. public function match($candidate, $name, ConstraintInterface $constraint = null)
  9587. {
  9588. $candidateName = $candidate->getName();
  9589. $candidateVersion = $candidate->getVersion();
  9590. if ($candidateName === $name) {
  9591. return $constraint === null || CompilingMatcher::match($constraint, Constraint::OP_EQ, $candidateVersion);
  9592. }
  9593. $provides = $candidate->getProvides();
  9594. $replaces = $candidate->getReplaces();
  9595. if (isset($replaces[0]) || isset($provides[0])) {
  9596. foreach ($provides as $link) {
  9597. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  9598. return true;
  9599. }
  9600. }
  9601. foreach ($replaces as $link) {
  9602. if ($link->getTarget() === $name && ($constraint === null || $constraint->matches($link->getConstraint()))) {
  9603. return true;
  9604. }
  9605. }
  9606. return false;
  9607. }
  9608. if (isset($provides[$name]) && ($constraint === null || $constraint->matches($provides[$name]->getConstraint()))) {
  9609. return true;
  9610. }
  9611. if (isset($replaces[$name]) && ($constraint === null || $constraint->matches($replaces[$name]->getConstraint()))) {
  9612. return true;
  9613. }
  9614. return false;
  9615. }
  9616. public function isUnacceptableFixedOrLockedPackage(PackageInterface $package)
  9617. {
  9618. return \in_array($package, $this->unacceptableFixedOrLockedPackages, true);
  9619. }
  9620. public function __toString()
  9621. {
  9622. $str = "Pool:\n";
  9623. foreach ($this->packages as $package) {
  9624. $str .= '- '.str_pad($package->id, 6, ' ', STR_PAD_LEFT).': '.$package->getName()."\n";
  9625. }
  9626. return $str;
  9627. }
  9628. }
  9629. <?php
  9630. namespace Composer\DependencyResolver;
  9631. use Composer\EventDispatcher\EventDispatcher;
  9632. use Composer\IO\IOInterface;
  9633. use Composer\Package\AliasPackage;
  9634. use Composer\Package\BasePackage;
  9635. use Composer\Package\PackageInterface;
  9636. use Composer\Package\Version\StabilityFilter;
  9637. use Composer\Plugin\PluginEvents;
  9638. use Composer\Plugin\PrePoolCreateEvent;
  9639. use Composer\Repository\PlatformRepository;
  9640. use Composer\Repository\RootPackageRepository;
  9641. use Composer\Semver\CompilingMatcher;
  9642. use Composer\Semver\Constraint\Constraint;
  9643. use Composer\Semver\Constraint\ConstraintInterface;
  9644. use Composer\Semver\Constraint\MatchAllConstraint;
  9645. use Composer\Semver\Constraint\MultiConstraint;
  9646. use Composer\Semver\Intervals;
  9647. class PoolBuilder
  9648. {
  9649. private $acceptableStabilities;
  9650. private $stabilityFlags;
  9651. private $rootAliases;
  9652. private $rootReferences;
  9653. private $eventDispatcher;
  9654. private $io;
  9655. private $aliasMap = array();
  9656. private $packagesToLoad = array();
  9657. private $loadedPackages = array();
  9658. private $loadedPerRepo = array();
  9659. private $packages = array();
  9660. private $unacceptableFixedOrLockedPackages = array();
  9661. private $updateAllowList = array();
  9662. private $skippedLoad = array();
  9663. private $maxExtendedReqs = array();
  9664. private $updateAllowWarned = array();
  9665. private $indexCounter = 0;
  9666. public function __construct(array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, IOInterface $io, EventDispatcher $eventDispatcher = null)
  9667. {
  9668. $this->acceptableStabilities = $acceptableStabilities;
  9669. $this->stabilityFlags = $stabilityFlags;
  9670. $this->rootAliases = $rootAliases;
  9671. $this->rootReferences = $rootReferences;
  9672. $this->eventDispatcher = $eventDispatcher;
  9673. $this->io = $io;
  9674. }
  9675. public function buildPool(array $repositories, Request $request)
  9676. {
  9677. if ($request->getUpdateAllowList()) {
  9678. $this->updateAllowList = $request->getUpdateAllowList();
  9679. $this->warnAboutNonMatchingUpdateAllowList($request);
  9680. foreach ($request->getLockedRepository()->getPackages() as $lockedPackage) {
  9681. if (!$this->isUpdateAllowed($lockedPackage)) {
  9682. $request->lockPackage($lockedPackage);
  9683. $lockedName = $lockedPackage->getName();
  9684. $this->skippedLoad[$lockedName] = $lockedName;
  9685. foreach ($lockedPackage->getReplaces() as $link) {
  9686. $this->skippedLoad[$link->getTarget()] = $lockedName;
  9687. }
  9688. }
  9689. }
  9690. }
  9691. foreach ($request->getFixedOrLockedPackages() as $package) {
  9692. $this->loadedPackages[$package->getName()] = new MatchAllConstraint();
  9693. foreach ($package->getReplaces() as $link) {
  9694. $this->loadedPackages[$link->getTarget()] = new MatchAllConstraint();
  9695. }
  9696. if (
  9697. $package->getRepository() instanceof RootPackageRepository
  9698. || $package->getRepository() instanceof PlatformRepository
  9699. || StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $package->getNames(), $package->getStability())
  9700. ) {
  9701. $this->loadPackage($request, $package, false);
  9702. } else {
  9703. $this->unacceptableFixedOrLockedPackages[] = $package;
  9704. }
  9705. }
  9706. foreach ($request->getRequires() as $packageName => $constraint) {
  9707. if (isset($this->loadedPackages[$packageName])) {
  9708. continue;
  9709. }
  9710. $this->packagesToLoad[$packageName] = $constraint;
  9711. $this->maxExtendedReqs[$packageName] = true;
  9712. }
  9713. foreach ($this->packagesToLoad as $name => $constraint) {
  9714. if (isset($this->loadedPackages[$name])) {
  9715. unset($this->packagesToLoad[$name]);
  9716. }
  9717. }
  9718. while (!empty($this->packagesToLoad)) {
  9719. $this->loadPackagesMarkedForLoading($request, $repositories);
  9720. }
  9721. foreach ($this->packages as $i => $package) {
  9722. if (!$package instanceof AliasPackage) {
  9723. $constraint = new Constraint('==', $package->getVersion());
  9724. $aliasedPackages = array($i => $package);
  9725. if (isset($this->aliasMap[spl_object_hash($package)])) {
  9726. $aliasedPackages += $this->aliasMap[spl_object_hash($package)];
  9727. }
  9728. $found = false;
  9729. foreach ($aliasedPackages as $packageOrAlias) {
  9730. if (CompilingMatcher::match($constraint, Constraint::OP_EQ, $packageOrAlias->getVersion())) {
  9731. $found = true;
  9732. }
  9733. }
  9734. if (!$found) {
  9735. foreach ($aliasedPackages as $index => $packageOrAlias) {
  9736. unset($this->packages[$index]);
  9737. }
  9738. }
  9739. }
  9740. }
  9741. if ($this->eventDispatcher) {
  9742. $prePoolCreateEvent = new PrePoolCreateEvent(
  9743. PluginEvents::PRE_POOL_CREATE,
  9744. $repositories,
  9745. $request,
  9746. $this->acceptableStabilities,
  9747. $this->stabilityFlags,
  9748. $this->rootAliases,
  9749. $this->rootReferences,
  9750. $this->packages,
  9751. $this->unacceptableFixedOrLockedPackages
  9752. );
  9753. $this->eventDispatcher->dispatch($prePoolCreateEvent->getName(), $prePoolCreateEvent);
  9754. $this->packages = $prePoolCreateEvent->getPackages();
  9755. $this->unacceptableFixedOrLockedPackages = $prePoolCreateEvent->getUnacceptableFixedPackages();
  9756. }
  9757. $pool = new Pool($this->packages, $this->unacceptableFixedOrLockedPackages);
  9758. $this->aliasMap = array();
  9759. $this->packagesToLoad = array();
  9760. $this->loadedPackages = array();
  9761. $this->loadedPerRepo = array();
  9762. $this->packages = array();
  9763. $this->unacceptableFixedOrLockedPackages = array();
  9764. $this->maxExtendedReqs = array();
  9765. $this->skippedLoad = array();
  9766. $this->indexCounter = 0;
  9767. Intervals::clear();
  9768. return $pool;
  9769. }
  9770. private function markPackageNameForLoading(Request $request, $name, ConstraintInterface $constraint)
  9771. {
  9772. if (PlatformRepository::isPlatformPackage($name)) {
  9773. return;
  9774. }
  9775. if (isset($this->maxExtendedReqs[$name])) {
  9776. return;
  9777. }
  9778. $rootRequires = $request->getRequires();
  9779. if (isset($rootRequires[$name]) && !Intervals::isSubsetOf($constraint, $rootRequires[$name])) {
  9780. $constraint = $rootRequires[$name];
  9781. }
  9782. if (!isset($this->loadedPackages[$name])) {
  9783. if (isset($this->packagesToLoad[$name])) {
  9784. if (Intervals::isSubsetOf($constraint, $this->packagesToLoad[$name])) {
  9785. return;
  9786. }
  9787. $constraint = Intervals::compactConstraint(MultiConstraint::create(array($this->packagesToLoad[$name], $constraint), false));
  9788. }
  9789. $this->packagesToLoad[$name] = $constraint;
  9790. return;
  9791. }
  9792. if (Intervals::isSubsetOf($constraint, $this->loadedPackages[$name])) {
  9793. return;
  9794. }
  9795. $this->packagesToLoad[$name] = Intervals::compactConstraint(MultiConstraint::create(array($this->loadedPackages[$name], $constraint), false));
  9796. unset($this->loadedPackages[$name]);
  9797. }
  9798. private function loadPackagesMarkedForLoading(Request $request, $repositories)
  9799. {
  9800. foreach ($this->packagesToLoad as $name => $constraint) {
  9801. $this->loadedPackages[$name] = $constraint;
  9802. }
  9803. $packageBatch = $this->packagesToLoad;
  9804. $this->packagesToLoad = array();
  9805. foreach ($repositories as $repoIndex => $repository) {
  9806. if (empty($packageBatch)) {
  9807. break;
  9808. }
  9809. if ($repository instanceof PlatformRepository || $repository === $request->getLockedRepository()) {
  9810. continue;
  9811. }
  9812. $result = $repository->loadPackages($packageBatch, $this->acceptableStabilities, $this->stabilityFlags, isset($this->loadedPerRepo[$repoIndex]) ? $this->loadedPerRepo[$repoIndex] : array());
  9813. foreach ($result['namesFound'] as $name) {
  9814. unset($packageBatch[$name]);
  9815. }
  9816. foreach ($result['packages'] as $package) {
  9817. $this->loadedPerRepo[$repoIndex][$package->getName()][$package->getVersion()] = $package;
  9818. $this->loadPackage($request, $package);
  9819. }
  9820. }
  9821. }
  9822. private function loadPackage(Request $request, PackageInterface $package, $propagateUpdate = true)
  9823. {
  9824. $index = $this->indexCounter++;
  9825. $this->packages[$index] = $package;
  9826. if ($package instanceof AliasPackage) {
  9827. $this->aliasMap[spl_object_hash($package->getAliasOf())][$index] = $package;
  9828. }
  9829. $name = $package->getName();
  9830. if (isset($this->rootReferences[$name])) {
  9831. if (!$request->isLockedPackage($package) && !$request->isFixedPackage($package)) {
  9832. $package->setSourceDistReferences($this->rootReferences[$name]);
  9833. }
  9834. }
  9835. if ($propagateUpdate && isset($this->rootAliases[$name][$package->getVersion()])) {
  9836. $alias = $this->rootAliases[$name][$package->getVersion()];
  9837. if ($package instanceof AliasPackage) {
  9838. $basePackage = $package->getAliasOf();
  9839. } else {
  9840. $basePackage = $package;
  9841. }
  9842. $aliasPackage = new AliasPackage($basePackage, $alias['alias_normalized'], $alias['alias']);
  9843. $aliasPackage->setRootPackageAlias(true);
  9844. $newIndex = $this->indexCounter++;
  9845. $this->packages[$newIndex] = $aliasPackage;
  9846. $this->aliasMap[spl_object_hash($aliasPackage->getAliasOf())][$newIndex] = $aliasPackage;
  9847. }
  9848. foreach ($package->getRequires() as $link) {
  9849. $require = $link->getTarget();
  9850. $linkConstraint = $link->getConstraint();
  9851. if (isset($this->skippedLoad[$require])) {
  9852. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  9853. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$require])) {
  9854. $this->unlockPackage($request, $require);
  9855. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9856. } elseif (!isset($this->updateAllowWarned[$this->skippedLoad[$require]])) {
  9857. $this->updateAllowWarned[$this->skippedLoad[$require]] = true;
  9858. $this->io->writeError('<warning>Dependency "'.$this->skippedLoad[$require].'" is also a root requirement. Package has not been listed as an update argument, so keeping locked at old version. Use --with-all-dependencies (-W) to include root dependencies.</warning>');
  9859. }
  9860. }
  9861. } else {
  9862. $this->markPackageNameForLoading($request, $require, $linkConstraint);
  9863. }
  9864. }
  9865. if ($propagateUpdate && $request->getUpdateAllowTransitiveDependencies()) {
  9866. foreach ($package->getReplaces() as $link) {
  9867. $replace = $link->getTarget();
  9868. if (isset($this->loadedPackages[$replace], $this->skippedLoad[$replace])) {
  9869. if ($request->getUpdateAllowTransitiveRootDependencies() || !$this->isRootRequire($request, $this->skippedLoad[$replace])) {
  9870. $this->unlockPackage($request, $replace);
  9871. $this->markPackageNameForLoading($request, $replace, $link->getConstraint());
  9872. } elseif (!$request->getUpdateAllowTransitiveRootDependencies() && $this->isRootRequire($request, $replace) && !isset($this->updateAllowWarned[$replace])) {
  9873. $this->updateAllowWarned[$replace] = true;
  9874. $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>');
  9875. }
  9876. }
  9877. }
  9878. }
  9879. }
  9880. private function isRootRequire(Request $request, $name)
  9881. {
  9882. $rootRequires = $request->getRequires();
  9883. return isset($rootRequires[$name]);
  9884. }
  9885. private function isUpdateAllowed(PackageInterface $package)
  9886. {
  9887. foreach ($this->updateAllowList as $pattern => $void) {
  9888. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  9889. if (preg_match($patternRegexp, $package->getName())) {
  9890. return true;
  9891. }
  9892. }
  9893. return false;
  9894. }
  9895. private function warnAboutNonMatchingUpdateAllowList(Request $request)
  9896. {
  9897. foreach ($this->updateAllowList as $pattern => $void) {
  9898. $patternRegexp = BasePackage::packageNameToRegexp($pattern);
  9899. foreach ($request->getLockedRepository()->getPackages() as $package) {
  9900. if (preg_match($patternRegexp, $package->getName())) {
  9901. continue 2;
  9902. }
  9903. }
  9904. foreach ($request->getRequires() as $packageName => $constraint) {
  9905. if (preg_match($patternRegexp, $packageName)) {
  9906. continue 2;
  9907. }
  9908. }
  9909. if (strpos($pattern, '*') !== false) {
  9910. $this->io->writeError('<warning>Pattern "' . $pattern . '" listed for update does not match any locked packages.</warning>');
  9911. } else {
  9912. $this->io->writeError('<warning>Package "' . $pattern . '" listed for update is not locked.</warning>');
  9913. }
  9914. }
  9915. }
  9916. private function unlockPackage(Request $request, $name)
  9917. {
  9918. if (
  9919. $this->skippedLoad[$name] !== $name
  9920. && isset($this->skippedLoad[$this->skippedLoad[$name]])
  9921. ) {
  9922. $this->unlockPackage($request, $this->skippedLoad[$name]);
  9923. }
  9924. unset($this->skippedLoad[$name], $this->loadedPackages[$name], $this->maxExtendedReqs[$name]);
  9925. foreach ($request->getLockedPackages() as $lockedPackage) {
  9926. if (!($lockedPackage instanceof AliasPackage) && $lockedPackage->getName() === $name) {
  9927. if (false !== $index = array_search($lockedPackage, $this->packages, true)) {
  9928. $request->unlockPackage($lockedPackage);
  9929. $this->removeLoadedPackage($request, $lockedPackage, $index);
  9930. foreach ($request->getFixedOrLockedPackages() as $fixedOrLockedPackage) {
  9931. if ($fixedOrLockedPackage !== $lockedPackage && isset($this->skippedLoad[$fixedOrLockedPackage->getName()])) {
  9932. foreach ($fixedOrLockedPackage->getRequires() as $requireLink) {
  9933. if ($requireLink->getTarget() === $lockedPackage->getName()) {
  9934. $this->markPackageNameForLoading($request, $lockedPackage->getName(), $requireLink->getConstraint());
  9935. }
  9936. }
  9937. }
  9938. }
  9939. }
  9940. }
  9941. }
  9942. }
  9943. private function removeLoadedPackage(Request $request, PackageInterface $package, $index)
  9944. {
  9945. unset($this->packages[$index]);
  9946. if (isset($this->aliasMap[spl_object_hash($package)])) {
  9947. foreach ($this->aliasMap[spl_object_hash($package)] as $aliasIndex => $aliasPackage) {
  9948. $request->unlockPackage($aliasPackage);
  9949. unset($this->packages[$aliasIndex]);
  9950. }
  9951. unset($this->aliasMap[spl_object_hash($package)]);
  9952. }
  9953. }
  9954. }
  9955. <?php
  9956. namespace Composer\DependencyResolver;
  9957. use Composer\Package\CompletePackageInterface;
  9958. use Composer\Package\AliasPackage;
  9959. use Composer\Repository\RepositorySet;
  9960. use Composer\Repository\LockArrayRepository;
  9961. use Composer\Semver\Constraint\Constraint;
  9962. use Composer\Package\Version\VersionParser;
  9963. class Problem
  9964. {
  9965. protected $reasonSeen;
  9966. protected $reasons = array();
  9967. protected $section = 0;
  9968. public function addRule(Rule $rule)
  9969. {
  9970. $this->addReason(spl_object_hash($rule), $rule);
  9971. }
  9972. public function getReasons()
  9973. {
  9974. return $this->reasons;
  9975. }
  9976. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  9977. {
  9978. $reasons = call_user_func_array('array_merge', array_reverse($this->reasons));
  9979. if (count($reasons) === 1) {
  9980. reset($reasons);
  9981. $rule = current($reasons);
  9982. if (!in_array($rule->getReason(), array(Rule::RULE_ROOT_REQUIRE, Rule::RULE_FIXED), true)) {
  9983. throw new \LogicException("Single reason problems must contain a request rule.");
  9984. }
  9985. $reasonData = $rule->getReasonData();
  9986. $packageName = $reasonData['packageName'];
  9987. $constraint = $reasonData['constraint'];
  9988. if (isset($constraint)) {
  9989. $packages = $pool->whatProvides($packageName, $constraint);
  9990. } else {
  9991. $packages = array();
  9992. }
  9993. if (empty($packages)) {
  9994. return "\n ".implode(self::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $packageName, $constraint));
  9995. }
  9996. }
  9997. return self::formatDeduplicatedRules($reasons, ' ', $repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  9998. }
  9999. public static function formatDeduplicatedRules($rules, $indent, RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  10000. {
  10001. $messages = array();
  10002. $templates = array();
  10003. $parser = new VersionParser;
  10004. $deduplicatableRuleTypes = array(Rule::RULE_PACKAGE_REQUIRES, Rule::RULE_PACKAGE_CONFLICT);
  10005. foreach ($rules as $rule) {
  10006. $message = $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $learnedPool);
  10007. if (in_array($rule->getReason(), $deduplicatableRuleTypes, true) && preg_match('{^(?P<package>\S+) (?P<version>\S+) (?P<type>requires|conflicts)}', $message, $m)) {
  10008. $template = preg_replace('{^\S+ \S+ }', '%s%s ', $message);
  10009. $messages[] = $template;
  10010. $templates[$template][$m[1]][$parser->normalize($m[2])] = $m[2];
  10011. } elseif ($message !== '') {
  10012. $messages[] = $message;
  10013. }
  10014. }
  10015. $result = array();
  10016. foreach (array_unique($messages) as $message) {
  10017. if (isset($templates[$message])) {
  10018. foreach ($templates[$message] as $package => $versions) {
  10019. uksort($versions, 'version_compare');
  10020. if (!$isVerbose) {
  10021. $versions = self::condenseVersionList($versions, 1);
  10022. }
  10023. if (count($versions) > 1) {
  10024. $message = preg_replace('{^(%s%s (?:require|conflict))s}', '$1', $message);
  10025. $result[] = sprintf($message, $package, '['.implode(', ', $versions).']');
  10026. } else {
  10027. $result[] = sprintf($message, $package, ' '.reset($versions));
  10028. }
  10029. }
  10030. } else {
  10031. $result[] = $message;
  10032. }
  10033. }
  10034. return "\n$indent- ".implode("\n$indent- ", $result);
  10035. }
  10036. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  10037. {
  10038. foreach ($this->reasons as $sectionRules) {
  10039. foreach ($sectionRules as $rule) {
  10040. if ($rule->isCausedByLock($repositorySet, $request, $pool)) {
  10041. return true;
  10042. }
  10043. }
  10044. }
  10045. }
  10046. protected function addReason($id, Rule $reason)
  10047. {
  10048. if (!isset($this->reasonSeen[$id])) {
  10049. $this->reasonSeen[$id] = true;
  10050. $this->reasons[$this->section][] = $reason;
  10051. }
  10052. }
  10053. public function nextSection()
  10054. {
  10055. $this->section++;
  10056. }
  10057. public static function getMissingPackageReason(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $packageName, $constraint = null)
  10058. {
  10059. if ($packageName === 'php' || $packageName === 'php-64bit' || $packageName === 'hhvm') {
  10060. $version = phpversion();
  10061. $available = $pool->whatProvides($packageName);
  10062. if (count($available)) {
  10063. $firstAvailable = reset($available);
  10064. $version = $firstAvailable->getPrettyVersion();
  10065. $extra = $firstAvailable->getExtra();
  10066. if ($firstAvailable instanceof CompletePackageInterface && isset($extra['config.platform']) && $extra['config.platform'] === true) {
  10067. $version .= '; ' . str_replace('Package ', '', $firstAvailable->getDescription());
  10068. }
  10069. }
  10070. $msg = "- Root composer.json requires ".$packageName.self::constraintToText($constraint).' but ';
  10071. if (defined('HHVM_VERSION') || (count($available) && $packageName === 'hhvm')) {
  10072. return array($msg, 'your HHVM version does not satisfy that requirement.');
  10073. }
  10074. if ($packageName === 'hhvm') {
  10075. return array($msg, 'you are running this with PHP and not HHVM.');
  10076. }
  10077. return array($msg, 'your '.$packageName.' version ('. $version .') does not satisfy that requirement.');
  10078. }
  10079. if (0 === stripos($packageName, 'ext-')) {
  10080. if (false !== strpos($packageName, ' ')) {
  10081. return array('- ', "PHP extension ".$packageName.' should be required as '.str_replace(' ', '-', $packageName).'.');
  10082. }
  10083. $ext = substr($packageName, 4);
  10084. $error = extension_loaded($ext) ? 'it has the wrong version ('.(phpversion($ext) ?: '0').') installed' : 'it is missing from your system';
  10085. return array("- Root composer.json requires PHP extension ".$packageName.self::constraintToText($constraint).' but ', $error.'. Install or enable PHP\'s '.$ext.' extension.');
  10086. }
  10087. if (0 === stripos($packageName, 'lib-')) {
  10088. if (strtolower($packageName) === 'lib-icu') {
  10089. $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.';
  10090. return array("- Root composer.json requires linked library ".$packageName.self::constraintToText($constraint).' but ', $error);
  10091. }
  10092. 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.');
  10093. }
  10094. $lockedPackage = null;
  10095. foreach ($request->getLockedPackages() as $package) {
  10096. if ($package->getName() === $packageName) {
  10097. $lockedPackage = $package;
  10098. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10099. 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.');
  10100. }
  10101. break;
  10102. }
  10103. }
  10104. if ($packages = $repositorySet->findPackages($packageName, $constraint)) {
  10105. $rootReqs = $repositorySet->getRootRequires();
  10106. if (isset($rootReqs[$packageName])) {
  10107. $filtered = array_filter($packages, function ($p) use ($rootReqs, $packageName) {
  10108. return $rootReqs[$packageName]->matches(new Constraint('==', $p->getVersion()));
  10109. });
  10110. if (0 === count($filtered)) {
  10111. 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().').');
  10112. }
  10113. }
  10114. if ($lockedPackage) {
  10115. $fixedConstraint = new Constraint('==', $lockedPackage->getVersion());
  10116. $filtered = array_filter($packages, function ($p) use ($fixedConstraint) {
  10117. return $fixedConstraint->matches(new Constraint('==', $p->getVersion()));
  10118. });
  10119. if (0 === count($filtered)) {
  10120. 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.');
  10121. }
  10122. }
  10123. $nonLockedPackages = array_filter($packages, function ($p) {
  10124. return !$p->getRepository() instanceof LockArrayRepository;
  10125. });
  10126. if (!$nonLockedPackages) {
  10127. 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.');
  10128. }
  10129. return array("- Root composer.json requires $packageName".self::constraintToText($constraint) . ', ', 'found '.self::getPackageList($packages, $isVerbose).' but these were not loaded, likely because '.(self::hasMultipleNames($packages) ? 'they conflict' : 'it conflicts').' with another require.');
  10130. }
  10131. if ($packages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10132. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10133. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, $packages, $allReposPackages, 'minimum-stability');
  10134. }
  10135. 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.');
  10136. }
  10137. if ($packages = $repositorySet->findPackages($packageName, null, RepositorySet::ALLOW_UNACCEPTABLE_STABILITIES)) {
  10138. if ($allReposPackages = $repositorySet->findPackages($packageName, $constraint, RepositorySet::ALLOW_SHADOWED_REPOSITORIES)) {
  10139. return self::computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, $packages, $allReposPackages, 'constraint');
  10140. }
  10141. 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.');
  10142. }
  10143. if (!preg_match('{^[A-Za-z0-9_./-]+$}', $packageName)) {
  10144. $illegalChars = preg_replace('{[A-Za-z0-9_./-]+}', '', $packageName);
  10145. 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.');
  10146. }
  10147. if ($providers = $repositorySet->getProviders($packageName)) {
  10148. $maxProviders = 20;
  10149. $providersStr = implode(array_map(function ($p) {
  10150. $description = $p['description'] ? ' '.substr($p['description'], 0, 100) : '';
  10151. return " - ${p['name']}".$description."\n";
  10152. }, count($providers) > $maxProviders + 1 ? array_slice($providers, 0, $maxProviders) : $providers));
  10153. if (count($providers) > $maxProviders + 1) {
  10154. $providersStr .= ' ... and '.(count($providers) - $maxProviders).' more.'."\n";
  10155. }
  10156. 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.");
  10157. }
  10158. return array("- Root composer.json requires $packageName, it ", "could not be found in any version, there may be a typo in the package name.");
  10159. }
  10160. public static function getPackageList(array $packages, $isVerbose)
  10161. {
  10162. $prepared = array();
  10163. $hasDefaultBranch = array();
  10164. foreach ($packages as $package) {
  10165. $prepared[$package->getName()]['name'] = $package->getPrettyName();
  10166. $prepared[$package->getName()]['versions'][$package->getVersion()] = $package->getPrettyVersion().($package instanceof AliasPackage ? ' (alias of '.$package->getAliasOf()->getPrettyVersion().')' : '');
  10167. if ($package->isDefaultBranch()) {
  10168. $hasDefaultBranch[$package->getName()] = true;
  10169. }
  10170. }
  10171. foreach ($prepared as $name => $package) {
  10172. if (isset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS], $hasDefaultBranch[$name])) {
  10173. unset($package['versions'][VersionParser::DEFAULT_BRANCH_ALIAS]);
  10174. }
  10175. uksort($package['versions'], 'version_compare');
  10176. if (!$isVerbose) {
  10177. $package['versions'] = self::condenseVersionList($package['versions'], 4);
  10178. }
  10179. $prepared[$name] = $package['name'].'['.implode(', ', $package['versions']).']';
  10180. }
  10181. return implode(', ', $prepared);
  10182. }
  10183. private static function condenseVersionList(array $versions, $max)
  10184. {
  10185. if (count($versions) <= $max) {
  10186. return $versions;
  10187. }
  10188. $filtered = array();
  10189. $byMajor = array();
  10190. foreach ($versions as $version => $pretty) {
  10191. $byMajor[preg_replace('{^(\d+)\..*}', '$1', $version)][] = $pretty;
  10192. }
  10193. foreach ($byMajor as $versionsForMajor) {
  10194. if (count($versionsForMajor) > $max) {
  10195. $filtered[] = $versionsForMajor[0];
  10196. $filtered[] = '...';
  10197. $filtered[] = $versionsForMajor[count($versionsForMajor) - 1];
  10198. } else {
  10199. $filtered = array_merge($filtered, $versionsForMajor);
  10200. }
  10201. }
  10202. return $filtered;
  10203. }
  10204. private static function hasMultipleNames(array $packages)
  10205. {
  10206. $name = null;
  10207. foreach ($packages as $package) {
  10208. if ($name === null || $name === $package->getName()) {
  10209. $name = $package->getName();
  10210. } else {
  10211. return true;
  10212. }
  10213. }
  10214. return false;
  10215. }
  10216. private static function computeCheckForLowerPrioRepo($isVerbose, $packageName, $constraint, array $higherRepoPackages, array $allReposPackages, $reason)
  10217. {
  10218. $nextRepoPackages = array();
  10219. $nextRepo = null;
  10220. foreach ($allReposPackages as $package) {
  10221. if ($nextRepo === null || $nextRepo === $package->getRepository()) {
  10222. $nextRepoPackages[] = $package;
  10223. $nextRepo = $package->getRepository();
  10224. } else {
  10225. break;
  10226. }
  10227. }
  10228. 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.');
  10229. }
  10230. protected static function constraintToText($constraint)
  10231. {
  10232. return $constraint ? ' '.$constraint->getPrettyString() : '';
  10233. }
  10234. }
  10235. <?php
  10236. namespace Composer\DependencyResolver;
  10237. use Composer\Package\Package;
  10238. use Composer\Package\PackageInterface;
  10239. use Composer\Repository\LockArrayRepository;
  10240. use Composer\Semver\Constraint\ConstraintInterface;
  10241. use Composer\Semver\Constraint\MatchAllConstraint;
  10242. class Request
  10243. {
  10244. const UPDATE_ONLY_LISTED = 0;
  10245. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS_NO_ROOT_REQUIRE = 1;
  10246. const UPDATE_LISTED_WITH_TRANSITIVE_DEPS = 2;
  10247. protected $lockedRepository;
  10248. protected $requires = array();
  10249. protected $fixedPackages = array();
  10250. protected $lockedPackages = array();
  10251. protected $fixedLockedPackages = array();
  10252. protected $updateAllowList = array();
  10253. protected $updateAllowTransitiveDependencies = false;
  10254. public function __construct(LockArrayRepository $lockedRepository = null)
  10255. {
  10256. $this->lockedRepository = $lockedRepository;
  10257. }
  10258. public function requireName($packageName, ConstraintInterface $constraint = null)
  10259. {
  10260. $packageName = strtolower($packageName);
  10261. if ($constraint === null) {
  10262. $constraint = new MatchAllConstraint();
  10263. }
  10264. if (isset($this->requires[$packageName])) {
  10265. 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');
  10266. }
  10267. $this->requires[$packageName] = $constraint;
  10268. }
  10269. public function fixPackage(PackageInterface $package)
  10270. {
  10271. $this->fixedPackages[spl_object_hash($package)] = $package;
  10272. }
  10273. public function lockPackage(PackageInterface $package)
  10274. {
  10275. $this->lockedPackages[spl_object_hash($package)] = $package;
  10276. }
  10277. public function fixLockedPackage(PackageInterface $package)
  10278. {
  10279. $this->fixedPackages[spl_object_hash($package)] = $package;
  10280. $this->fixedLockedPackages[spl_object_hash($package)] = $package;
  10281. }
  10282. public function unlockPackage(PackageInterface $package)
  10283. {
  10284. unset($this->lockedPackages[spl_object_hash($package)]);
  10285. }
  10286. public function setUpdateAllowList($updateAllowList, $updateAllowTransitiveDependencies)
  10287. {
  10288. $this->updateAllowList = $updateAllowList;
  10289. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  10290. }
  10291. public function getUpdateAllowList()
  10292. {
  10293. return $this->updateAllowList;
  10294. }
  10295. public function getUpdateAllowTransitiveDependencies()
  10296. {
  10297. return $this->updateAllowTransitiveDependencies !== self::UPDATE_ONLY_LISTED;
  10298. }
  10299. public function getUpdateAllowTransitiveRootDependencies()
  10300. {
  10301. return $this->updateAllowTransitiveDependencies === self::UPDATE_LISTED_WITH_TRANSITIVE_DEPS;
  10302. }
  10303. public function getRequires()
  10304. {
  10305. return $this->requires;
  10306. }
  10307. public function getFixedPackages()
  10308. {
  10309. return $this->fixedPackages;
  10310. }
  10311. public function isFixedPackage(PackageInterface $package)
  10312. {
  10313. return isset($this->fixedPackages[spl_object_hash($package)]);
  10314. }
  10315. public function getLockedPackages()
  10316. {
  10317. return $this->lockedPackages;
  10318. }
  10319. public function isLockedPackage(PackageInterface $package)
  10320. {
  10321. return isset($this->lockedPackages[spl_object_hash($package)]) || isset($this->fixedLockedPackages[spl_object_hash($package)]);
  10322. }
  10323. public function getFixedOrLockedPackages()
  10324. {
  10325. return array_merge($this->fixedPackages, $this->lockedPackages);
  10326. }
  10327. public function getPresentMap($packageIds = false)
  10328. {
  10329. $presentMap = array();
  10330. if ($this->lockedRepository) {
  10331. foreach ($this->lockedRepository->getPackages() as $package) {
  10332. $presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
  10333. }
  10334. }
  10335. foreach ($this->fixedPackages as $package) {
  10336. $presentMap[$packageIds ? $package->id : spl_object_hash($package)] = $package;
  10337. }
  10338. return $presentMap;
  10339. }
  10340. public function getFixedPackagesMap()
  10341. {
  10342. $fixedPackagesMap = array();
  10343. foreach ($this->fixedPackages as $package) {
  10344. $fixedPackagesMap[$package->id] = $package;
  10345. }
  10346. return $fixedPackagesMap;
  10347. }
  10348. public function getLockedRepository()
  10349. {
  10350. return $this->lockedRepository;
  10351. }
  10352. }
  10353. <?php
  10354. namespace Composer\DependencyResolver;
  10355. use Composer\Package\Link;
  10356. use Composer\Package\PackageInterface;
  10357. use Composer\Package\AliasPackage;
  10358. use Composer\Repository\RepositorySet;
  10359. use Composer\Repository\PlatformRepository;
  10360. use Composer\Package\Version\VersionParser;
  10361. use Composer\Semver\Constraint\Constraint;
  10362. abstract class Rule
  10363. {
  10364. const RULE_ROOT_REQUIRE = 2;
  10365. const RULE_FIXED = 3;
  10366. const RULE_PACKAGE_CONFLICT = 6;
  10367. const RULE_PACKAGE_REQUIRES = 7;
  10368. const RULE_PACKAGE_SAME_NAME = 10;
  10369. const RULE_LEARNED = 12;
  10370. const RULE_PACKAGE_ALIAS = 13;
  10371. const RULE_PACKAGE_INVERSE_ALIAS = 14;
  10372. const BITFIELD_TYPE = 0;
  10373. const BITFIELD_REASON = 8;
  10374. const BITFIELD_DISABLED = 16;
  10375. protected $bitfield;
  10376. protected $request;
  10377. protected $reasonData;
  10378. public function __construct($reason, $reasonData)
  10379. {
  10380. $this->reasonData = $reasonData;
  10381. $this->bitfield = (0 << self::BITFIELD_DISABLED) |
  10382. ($reason << self::BITFIELD_REASON) |
  10383. (255 << self::BITFIELD_TYPE);
  10384. }
  10385. abstract public function getLiterals();
  10386. abstract public function getHash();
  10387. abstract public function equals(Rule $rule);
  10388. public function getReason()
  10389. {
  10390. return ($this->bitfield & (255 << self::BITFIELD_REASON)) >> self::BITFIELD_REASON;
  10391. }
  10392. public function getReasonData()
  10393. {
  10394. return $this->reasonData;
  10395. }
  10396. public function getRequiredPackage()
  10397. {
  10398. $reason = $this->getReason();
  10399. if ($reason === self::RULE_ROOT_REQUIRE) {
  10400. return $this->reasonData['packageName'];
  10401. }
  10402. if ($reason === self::RULE_FIXED) {
  10403. return $this->reasonData['package']->getName();
  10404. }
  10405. if ($reason === self::RULE_PACKAGE_REQUIRES) {
  10406. return $this->reasonData->getTarget();
  10407. }
  10408. }
  10409. public function setType($type)
  10410. {
  10411. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_TYPE)) | ((255 & $type) << self::BITFIELD_TYPE);
  10412. }
  10413. public function getType()
  10414. {
  10415. return ($this->bitfield & (255 << self::BITFIELD_TYPE)) >> self::BITFIELD_TYPE;
  10416. }
  10417. public function disable()
  10418. {
  10419. $this->bitfield = ($this->bitfield & ~(255 << self::BITFIELD_DISABLED)) | (1 << self::BITFIELD_DISABLED);
  10420. }
  10421. public function enable()
  10422. {
  10423. $this->bitfield &= ~(255 << self::BITFIELD_DISABLED);
  10424. }
  10425. public function isDisabled()
  10426. {
  10427. return (bool) (($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  10428. }
  10429. public function isEnabled()
  10430. {
  10431. return !(($this->bitfield & (255 << self::BITFIELD_DISABLED)) >> self::BITFIELD_DISABLED);
  10432. }
  10433. abstract public function isAssertion();
  10434. public function isCausedByLock(RepositorySet $repositorySet, Request $request, Pool $pool)
  10435. {
  10436. if ($this->getReason() === self::RULE_PACKAGE_REQUIRES) {
  10437. if (PlatformRepository::isPlatformPackage($this->reasonData->getTarget())) {
  10438. return false;
  10439. }
  10440. if ($request->getLockedRepository()) {
  10441. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10442. if ($package->getName() === $this->reasonData->getTarget()) {
  10443. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10444. return true;
  10445. }
  10446. if (!$this->reasonData->getConstraint()->matches(new Constraint('=', $package->getVersion()))) {
  10447. return true;
  10448. }
  10449. if (!$request->isLockedPackage($package)) {
  10450. return true;
  10451. }
  10452. break;
  10453. }
  10454. }
  10455. }
  10456. }
  10457. if ($this->getReason() === self::RULE_ROOT_REQUIRE) {
  10458. if (PlatformRepository::isPlatformPackage($this->reasonData['packageName'])) {
  10459. return false;
  10460. }
  10461. if ($request->getLockedRepository()) {
  10462. foreach ($request->getLockedRepository()->getPackages() as $package) {
  10463. if ($package->getName() === $this->reasonData['packageName']) {
  10464. if ($pool->isUnacceptableFixedOrLockedPackage($package)) {
  10465. return true;
  10466. }
  10467. if (!$this->reasonData['constraint']->matches(new Constraint('=', $package->getVersion()))) {
  10468. return true;
  10469. }
  10470. break;
  10471. }
  10472. }
  10473. }
  10474. }
  10475. return false;
  10476. }
  10477. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, array $installedMap = array(), array $learnedPool = array())
  10478. {
  10479. $literals = $this->getLiterals();
  10480. switch ($this->getReason()) {
  10481. case self::RULE_ROOT_REQUIRE:
  10482. $packageName = $this->reasonData['packageName'];
  10483. $constraint = $this->reasonData['constraint'];
  10484. $packages = $pool->whatProvides($packageName, $constraint);
  10485. if (!$packages) {
  10486. return 'No package found to satisfy root composer.json require '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '');
  10487. }
  10488. $packagesNonAlias = array_values(array_filter($packages, function ($p) {
  10489. return !($p instanceof AliasPackage);
  10490. }));
  10491. if (count($packagesNonAlias) === 1) {
  10492. $package = $packagesNonAlias[0];
  10493. if ($request->isLockedPackage($package)) {
  10494. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion()." and an update of this package was not requested.";
  10495. }
  10496. }
  10497. return 'Root composer.json requires '.$packageName.($constraint ? ' '.$constraint->getPrettyString() : '').' -> satisfiable by '.$this->formatPackagesUnique($pool, $packages, $isVerbose).'.';
  10498. case self::RULE_FIXED:
  10499. $package = $this->deduplicateDefaultBranchAlias($this->reasonData['package']);
  10500. if ($request->isLockedPackage($package)) {
  10501. return $package->getPrettyName().' is locked to version '.$package->getPrettyVersion().' and an update of this package was not requested.';
  10502. }
  10503. return $package->getPrettyName().' is present at version '.$package->getPrettyVersion() . ' and cannot be modified by Composer';
  10504. case self::RULE_PACKAGE_CONFLICT:
  10505. $package1 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  10506. $package2 = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  10507. return $package2->getPrettyString().' conflicts with '.$package1->getPrettyString().'.';
  10508. case self::RULE_PACKAGE_REQUIRES:
  10509. $sourceLiteral = array_shift($literals);
  10510. $sourcePackage = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($sourceLiteral));
  10511. $requires = array();
  10512. foreach ($literals as $literal) {
  10513. $requires[] = $pool->literalToPackage($literal);
  10514. }
  10515. $text = $this->reasonData->getPrettyString($sourcePackage);
  10516. if ($requires) {
  10517. $text .= ' -> satisfiable by ' . $this->formatPackagesUnique($pool, $requires, $isVerbose) . '.';
  10518. } else {
  10519. $targetName = $this->reasonData->getTarget();
  10520. $reason = Problem::getMissingPackageReason($repositorySet, $request, $pool, $isVerbose, $targetName, $this->reasonData->getConstraint());
  10521. return $text . ' -> ' . $reason[1];
  10522. }
  10523. return $text;
  10524. case self::RULE_PACKAGE_SAME_NAME:
  10525. $packageNames = array();
  10526. foreach ($literals as $literal) {
  10527. $package = $pool->literalToPackage($literal);
  10528. $packageNames[$package->getName()] = true;
  10529. }
  10530. $replacedName = $this->reasonData;
  10531. if (count($packageNames) > 1) {
  10532. $reason = null;
  10533. if (!isset($packageNames[$replacedName])) {
  10534. $reason = 'They '.(count($literals) == 2 ? 'both' : 'all').' replace '.$replacedName.' and thus cannot coexist.';
  10535. } else {
  10536. $replacerNames = $packageNames;
  10537. unset($replacerNames[$replacedName]);
  10538. $replacerNames = array_keys($replacerNames);
  10539. if (count($replacerNames) == 1) {
  10540. $reason = $replacerNames[0] . ' replaces ';
  10541. } else {
  10542. $reason = '['.implode(', ', $replacerNames).'] replace ';
  10543. }
  10544. $reason .= $replacedName.' and thus cannot coexist with it.';
  10545. }
  10546. $installedPackages = array();
  10547. $removablePackages = array();
  10548. foreach ($literals as $literal) {
  10549. if (isset($installedMap[abs($literal)])) {
  10550. $installedPackages[] = $pool->literalToPackage($literal);
  10551. } else {
  10552. $removablePackages[] = $pool->literalToPackage($literal);
  10553. }
  10554. }
  10555. if ($installedPackages && $removablePackages) {
  10556. return $this->formatPackagesUnique($pool, $removablePackages, $isVerbose).' cannot be installed as that would require removing '.$this->formatPackagesUnique($pool, $installedPackages, $isVerbose).'. '.$reason;
  10557. }
  10558. return 'Only one of these can be installed: '.$this->formatPackagesUnique($pool, $literals, $isVerbose).'. '.$reason;
  10559. }
  10560. return 'You can only install one version of a package, so only one of these can be installed: ' . $this->formatPackagesUnique($pool, $literals, $isVerbose) . '.';
  10561. case self::RULE_LEARNED:
  10562. $learnedString = ' (conflict analysis result)';
  10563. if (count($literals) === 1) {
  10564. $ruleText = $pool->literalToPrettyString($literals[0], $installedMap);
  10565. } else {
  10566. $groups = array();
  10567. foreach ($literals as $literal) {
  10568. $package = $pool->literalToPackage($literal);
  10569. if (isset($installedMap[$package->id])) {
  10570. $group = $literal > 0 ? 'keep' : 'remove';
  10571. } else {
  10572. $group = $literal > 0 ? 'install' : 'don\'t install';
  10573. }
  10574. $groups[$group][] = $this->deduplicateDefaultBranchAlias($package);
  10575. }
  10576. $ruleTexts = array();
  10577. foreach ($groups as $group => $packages) {
  10578. $ruleTexts[] = $group . (count($packages) > 1 ? ' one of' : '').' ' . $this->formatPackagesUnique($pool, $packages, $isVerbose);
  10579. }
  10580. $ruleText = implode(' | ', $ruleTexts);
  10581. }
  10582. return 'Conclusion: '.$ruleText.$learnedString;
  10583. case self::RULE_PACKAGE_ALIAS:
  10584. $aliasPackage = $pool->literalToPackage($literals[0]);
  10585. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10586. return '';
  10587. }
  10588. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[1]));
  10589. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and thus requires it to be installed too.';
  10590. case self::RULE_PACKAGE_INVERSE_ALIAS:
  10591. $aliasPackage = $pool->literalToPackage($literals[1]);
  10592. if ($aliasPackage->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10593. return '';
  10594. }
  10595. $package = $this->deduplicateDefaultBranchAlias($pool->literalToPackage($literals[0]));
  10596. return $aliasPackage->getPrettyString() .' is an alias of '.$package->getPrettyString().' and must be installed with it.';
  10597. default:
  10598. $ruleText = '';
  10599. foreach ($literals as $i => $literal) {
  10600. if ($i != 0) {
  10601. $ruleText .= '|';
  10602. }
  10603. $ruleText .= $pool->literalToPrettyString($literal, $installedMap);
  10604. }
  10605. return '('.$ruleText.')';
  10606. }
  10607. }
  10608. protected function formatPackagesUnique($pool, array $packages, $isVerbose)
  10609. {
  10610. foreach ($packages as $index => $package) {
  10611. if (!\is_object($package)) {
  10612. $packages[$index] = $pool->literalToPackage($package);
  10613. }
  10614. }
  10615. return Problem::getPackageList($packages, $isVerbose);
  10616. }
  10617. private function deduplicateDefaultBranchAlias(PackageInterface $package)
  10618. {
  10619. if ($package instanceof AliasPackage && $package->getPrettyVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  10620. $package = $package->getAliasOf();
  10621. }
  10622. return $package;
  10623. }
  10624. }
  10625. <?php
  10626. namespace Composer\DependencyResolver;
  10627. use Composer\Package\PackageInterface;
  10628. use Composer\Package\Link;
  10629. class Rule2Literals extends Rule
  10630. {
  10631. protected $literal1;
  10632. protected $literal2;
  10633. public function __construct($literal1, $literal2, $reason, $reasonData)
  10634. {
  10635. parent::__construct($reason, $reasonData);
  10636. if ($literal1 < $literal2) {
  10637. $this->literal1 = $literal1;
  10638. $this->literal2 = $literal2;
  10639. } else {
  10640. $this->literal1 = $literal2;
  10641. $this->literal2 = $literal1;
  10642. }
  10643. }
  10644. public function getLiterals()
  10645. {
  10646. return array($this->literal1, $this->literal2);
  10647. }
  10648. public function getHash()
  10649. {
  10650. return $this->literal1.','.$this->literal2;
  10651. }
  10652. public function equals(Rule $rule)
  10653. {
  10654. if ($rule instanceof self) {
  10655. if ($this->literal1 !== $rule->literal1) {
  10656. return false;
  10657. }
  10658. if ($this->literal2 !== $rule->literal2) {
  10659. return false;
  10660. }
  10661. return true;
  10662. }
  10663. $literals = $rule->getLiterals();
  10664. if (2 != \count($literals)) {
  10665. return false;
  10666. }
  10667. if ($this->literal1 !== $literals[0]) {
  10668. return false;
  10669. }
  10670. if ($this->literal2 !== $literals[1]) {
  10671. return false;
  10672. }
  10673. return true;
  10674. }
  10675. public function isAssertion()
  10676. {
  10677. return false;
  10678. }
  10679. public function __toString()
  10680. {
  10681. $result = $this->isDisabled() ? 'disabled(' : '(';
  10682. $result .= $this->literal1 . '|' . $this->literal2 . ')';
  10683. return $result;
  10684. }
  10685. }
  10686. <?php
  10687. namespace Composer\DependencyResolver;
  10688. use Composer\Repository\RepositorySet;
  10689. class RuleSet implements \IteratorAggregate, \Countable
  10690. {
  10691. const TYPE_PACKAGE = 0;
  10692. const TYPE_REQUEST = 1;
  10693. const TYPE_LEARNED = 4;
  10694. public $ruleById;
  10695. protected static $types = array(
  10696. 255 => 'UNKNOWN',
  10697. self::TYPE_PACKAGE => 'PACKAGE',
  10698. self::TYPE_REQUEST => 'REQUEST',
  10699. self::TYPE_LEARNED => 'LEARNED',
  10700. );
  10701. protected $rules;
  10702. protected $nextRuleId;
  10703. protected $rulesByHash;
  10704. public function __construct()
  10705. {
  10706. $this->nextRuleId = 0;
  10707. foreach ($this->getTypes() as $type) {
  10708. $this->rules[$type] = array();
  10709. }
  10710. $this->rulesByHash = array();
  10711. }
  10712. public function add(Rule $rule, $type)
  10713. {
  10714. if (!isset(self::$types[$type])) {
  10715. throw new \OutOfBoundsException('Unknown rule type: ' . $type);
  10716. }
  10717. $hash = $rule->getHash();
  10718. if (isset($this->rulesByHash[$hash])) {
  10719. $potentialDuplicates = $this->rulesByHash[$hash];
  10720. if (\is_array($potentialDuplicates)) {
  10721. foreach ($potentialDuplicates as $potentialDuplicate) {
  10722. if ($rule->equals($potentialDuplicate)) {
  10723. return;
  10724. }
  10725. }
  10726. } else {
  10727. if ($rule->equals($potentialDuplicates)) {
  10728. return;
  10729. }
  10730. }
  10731. }
  10732. if (!isset($this->rules[$type])) {
  10733. $this->rules[$type] = array();
  10734. }
  10735. $this->rules[$type][] = $rule;
  10736. $this->ruleById[$this->nextRuleId] = $rule;
  10737. $rule->setType($type);
  10738. $this->nextRuleId++;
  10739. if (!isset($this->rulesByHash[$hash])) {
  10740. $this->rulesByHash[$hash] = $rule;
  10741. } elseif (\is_array($this->rulesByHash[$hash])) {
  10742. $this->rulesByHash[$hash][] = $rule;
  10743. } else {
  10744. $originalRule = $this->rulesByHash[$hash];
  10745. $this->rulesByHash[$hash] = array($originalRule, $rule);
  10746. }
  10747. }
  10748. public function count()
  10749. {
  10750. return $this->nextRuleId;
  10751. }
  10752. public function ruleById($id)
  10753. {
  10754. return $this->ruleById[$id];
  10755. }
  10756. public function getRules()
  10757. {
  10758. return $this->rules;
  10759. }
  10760. public function getIterator()
  10761. {
  10762. return new RuleSetIterator($this->getRules());
  10763. }
  10764. public function getIteratorFor($types)
  10765. {
  10766. if (!\is_array($types)) {
  10767. $types = array($types);
  10768. }
  10769. $allRules = $this->getRules();
  10770. $rules = array();
  10771. foreach ($types as $type) {
  10772. $rules[$type] = $allRules[$type];
  10773. }
  10774. return new RuleSetIterator($rules);
  10775. }
  10776. public function getIteratorWithout($types)
  10777. {
  10778. if (!\is_array($types)) {
  10779. $types = array($types);
  10780. }
  10781. $rules = $this->getRules();
  10782. foreach ($types as $type) {
  10783. unset($rules[$type]);
  10784. }
  10785. return new RuleSetIterator($rules);
  10786. }
  10787. public function getTypes()
  10788. {
  10789. $types = self::$types;
  10790. unset($types[255]);
  10791. return array_keys($types);
  10792. }
  10793. public function getPrettyString(RepositorySet $repositorySet = null, Request $request = null, Pool $pool = null, $isVerbose = false)
  10794. {
  10795. $string = "\n";
  10796. foreach ($this->rules as $type => $rules) {
  10797. $string .= str_pad(self::$types[$type], 8, ' ') . ": ";
  10798. foreach ($rules as $rule) {
  10799. $string .= ($repositorySet && $request && $pool ? $rule->getPrettyString($repositorySet, $request, $pool, $isVerbose) : $rule)."\n";
  10800. }
  10801. $string .= "\n\n";
  10802. }
  10803. return $string;
  10804. }
  10805. public function __toString()
  10806. {
  10807. return $this->getPrettyString();
  10808. }
  10809. }
  10810. <?php
  10811. namespace Composer\DependencyResolver;
  10812. use Composer\Package\PackageInterface;
  10813. use Composer\Package\AliasPackage;
  10814. use Composer\Repository\PlatformRepository;
  10815. class RuleSetGenerator
  10816. {
  10817. protected $policy;
  10818. protected $pool;
  10819. protected $rules;
  10820. protected $addedMap;
  10821. protected $conflictAddedMap;
  10822. protected $addedPackagesByNames;
  10823. protected $conflictsForName;
  10824. public function __construct(PolicyInterface $policy, Pool $pool)
  10825. {
  10826. $this->policy = $policy;
  10827. $this->pool = $pool;
  10828. }
  10829. protected function createRequireRule(PackageInterface $package, array $providers, $reason, $reasonData = null)
  10830. {
  10831. $literals = array(-$package->id);
  10832. foreach ($providers as $provider) {
  10833. if ($provider === $package) {
  10834. return null;
  10835. }
  10836. $literals[] = $provider->id;
  10837. }
  10838. return new GenericRule($literals, $reason, $reasonData);
  10839. }
  10840. protected function createInstallOneOfRule(array $packages, $reason, $reasonData)
  10841. {
  10842. $literals = array();
  10843. foreach ($packages as $package) {
  10844. $literals[] = $package->id;
  10845. }
  10846. return new GenericRule($literals, $reason, $reasonData);
  10847. }
  10848. protected function createRule2Literals(PackageInterface $issuer, PackageInterface $provider, $reason, $reasonData = null)
  10849. {
  10850. if ($issuer === $provider) {
  10851. return null;
  10852. }
  10853. return new Rule2Literals(-$issuer->id, -$provider->id, $reason, $reasonData);
  10854. }
  10855. protected function createMultiConflictRule(array $packages, $reason, $reasonData = null)
  10856. {
  10857. $literals = array();
  10858. foreach ($packages as $package) {
  10859. $literals[] = -$package->id;
  10860. }
  10861. if (\count($literals) == 2) {
  10862. return new Rule2Literals($literals[0], $literals[1], $reason, $reasonData);
  10863. }
  10864. return new MultiConflictRule($literals, $reason, $reasonData);
  10865. }
  10866. private function addRule($type, Rule $newRule = null)
  10867. {
  10868. if (!$newRule) {
  10869. return;
  10870. }
  10871. $this->rules->add($newRule, $type);
  10872. }
  10873. protected function addRulesForPackage(PackageInterface $package, $ignorePlatformReqs)
  10874. {
  10875. $workQueue = new \SplQueue;
  10876. $workQueue->enqueue($package);
  10877. while (!$workQueue->isEmpty()) {
  10878. $package = $workQueue->dequeue();
  10879. if (isset($this->addedMap[$package->id])) {
  10880. continue;
  10881. }
  10882. $this->addedMap[$package->id] = $package;
  10883. if (!$package instanceof AliasPackage) {
  10884. foreach ($package->getNames(false) as $name) {
  10885. $this->addedPackagesByNames[$name][] = $package;
  10886. }
  10887. } else {
  10888. $workQueue->enqueue($package->getAliasOf());
  10889. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, array($package->getAliasOf()), Rule::RULE_PACKAGE_ALIAS, $package));
  10890. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package->getAliasOf(), array($package), Rule::RULE_PACKAGE_INVERSE_ALIAS, $package->getAliasOf()));
  10891. if (!$package->hasSelfVersionRequires()) {
  10892. continue;
  10893. }
  10894. }
  10895. foreach ($package->getRequires() as $link) {
  10896. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  10897. continue;
  10898. }
  10899. $possibleRequires = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  10900. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRequireRule($package, $possibleRequires, Rule::RULE_PACKAGE_REQUIRES, $link));
  10901. foreach ($possibleRequires as $require) {
  10902. $workQueue->enqueue($require);
  10903. }
  10904. }
  10905. }
  10906. }
  10907. protected function addConflictRules($ignorePlatformReqs = false)
  10908. {
  10909. foreach ($this->addedMap as $package) {
  10910. foreach ($package->getConflicts() as $link) {
  10911. if (!isset($this->addedPackagesByNames[$link->getTarget()])) {
  10912. continue;
  10913. }
  10914. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($link->getTarget(), $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($link->getTarget())) {
  10915. continue;
  10916. }
  10917. $conflicts = $this->pool->whatProvides($link->getTarget(), $link->getConstraint());
  10918. foreach ($conflicts as $conflict) {
  10919. if (!$conflict instanceof AliasPackage || $conflict->getName() === $link->getTarget()) {
  10920. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createRule2Literals($package, $conflict, Rule::RULE_PACKAGE_CONFLICT, $link));
  10921. }
  10922. }
  10923. }
  10924. }
  10925. foreach ($this->addedPackagesByNames as $name => $packages) {
  10926. if (\count($packages) > 1) {
  10927. $reason = Rule::RULE_PACKAGE_SAME_NAME;
  10928. $this->addRule(RuleSet::TYPE_PACKAGE, $this->createMultiConflictRule($packages, $reason, $name));
  10929. }
  10930. }
  10931. }
  10932. protected function addRulesForRequest(Request $request, $ignorePlatformReqs)
  10933. {
  10934. foreach ($request->getFixedPackages() as $package) {
  10935. if ($package->id == -1) {
  10936. if ($this->pool->isUnacceptableFixedOrLockedPackage($package)) {
  10937. continue;
  10938. }
  10939. throw new \LogicException("Fixed package ".$package->getPrettyString()." was not added to solver pool.");
  10940. }
  10941. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10942. $rule = $this->createInstallOneOfRule(array($package), Rule::RULE_FIXED, array(
  10943. 'package' => $package,
  10944. ));
  10945. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  10946. }
  10947. foreach ($request->getRequires() as $packageName => $constraint) {
  10948. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  10949. continue;
  10950. }
  10951. $packages = $this->pool->whatProvides($packageName, $constraint);
  10952. if ($packages) {
  10953. foreach ($packages as $package) {
  10954. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10955. }
  10956. $rule = $this->createInstallOneOfRule($packages, Rule::RULE_ROOT_REQUIRE, array(
  10957. 'packageName' => $packageName,
  10958. 'constraint' => $constraint,
  10959. ));
  10960. $this->addRule(RuleSet::TYPE_REQUEST, $rule);
  10961. }
  10962. }
  10963. }
  10964. protected function addRulesForRootAliases($ignorePlatformReqs)
  10965. {
  10966. foreach ($this->pool->getPackages() as $package) {
  10967. if (!isset($this->addedMap[$package->id]) &&
  10968. $package instanceof AliasPackage &&
  10969. ($package->isRootPackageAlias() || isset($this->addedMap[$package->getAliasOf()->id]))
  10970. ) {
  10971. $this->addRulesForPackage($package, $ignorePlatformReqs);
  10972. }
  10973. }
  10974. }
  10975. public function getRulesFor(Request $request, $ignorePlatformReqs = false)
  10976. {
  10977. $this->rules = new RuleSet;
  10978. $this->addedMap = array();
  10979. $this->conflictAddedMap = array();
  10980. $this->addedPackagesByNames = array();
  10981. $this->conflictsForName = array();
  10982. $this->addRulesForRequest($request, $ignorePlatformReqs);
  10983. $this->addRulesForRootAliases($ignorePlatformReqs);
  10984. $this->addConflictRules($ignorePlatformReqs);
  10985. $this->addedMap = $this->addedPackagesByNames = null;
  10986. return $this->rules;
  10987. }
  10988. }
  10989. <?php
  10990. namespace Composer\DependencyResolver;
  10991. class RuleSetIterator implements \Iterator
  10992. {
  10993. protected $rules;
  10994. protected $types;
  10995. protected $currentOffset;
  10996. protected $currentType;
  10997. protected $currentTypeOffset;
  10998. public function __construct(array $rules)
  10999. {
  11000. $this->rules = $rules;
  11001. $this->types = array_keys($rules);
  11002. sort($this->types);
  11003. $this->rewind();
  11004. }
  11005. public function current()
  11006. {
  11007. return $this->rules[$this->currentType][$this->currentOffset];
  11008. }
  11009. public function key()
  11010. {
  11011. return $this->currentType;
  11012. }
  11013. public function next()
  11014. {
  11015. $this->currentOffset++;
  11016. if (!isset($this->rules[$this->currentType])) {
  11017. return;
  11018. }
  11019. if ($this->currentOffset >= \count($this->rules[$this->currentType])) {
  11020. $this->currentOffset = 0;
  11021. do {
  11022. $this->currentTypeOffset++;
  11023. if (!isset($this->types[$this->currentTypeOffset])) {
  11024. $this->currentType = -1;
  11025. break;
  11026. }
  11027. $this->currentType = $this->types[$this->currentTypeOffset];
  11028. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  11029. }
  11030. }
  11031. public function rewind()
  11032. {
  11033. $this->currentOffset = 0;
  11034. $this->currentTypeOffset = -1;
  11035. $this->currentType = -1;
  11036. do {
  11037. $this->currentTypeOffset++;
  11038. if (!isset($this->types[$this->currentTypeOffset])) {
  11039. $this->currentType = -1;
  11040. break;
  11041. }
  11042. $this->currentType = $this->types[$this->currentTypeOffset];
  11043. } while (isset($this->types[$this->currentTypeOffset]) && !\count($this->rules[$this->currentType]));
  11044. }
  11045. public function valid()
  11046. {
  11047. return isset($this->rules[$this->currentType], $this->rules[$this->currentType][$this->currentOffset]);
  11048. }
  11049. }
  11050. <?php
  11051. namespace Composer\DependencyResolver;
  11052. class RuleWatchChain extends \SplDoublyLinkedList
  11053. {
  11054. protected $offset = 0;
  11055. public function seek($offset)
  11056. {
  11057. $this->rewind();
  11058. for ($i = 0; $i < $offset; $i++, $this->next());
  11059. }
  11060. public function remove()
  11061. {
  11062. $offset = $this->key();
  11063. $this->offsetUnset($offset);
  11064. $this->seek($offset);
  11065. }
  11066. }
  11067. <?php
  11068. namespace Composer\DependencyResolver;
  11069. class RuleWatchGraph
  11070. {
  11071. protected $watchChains = array();
  11072. public function insert(RuleWatchNode $node)
  11073. {
  11074. if ($node->getRule()->isAssertion()) {
  11075. return;
  11076. }
  11077. if (!$node->getRule() instanceof MultiConflictRule) {
  11078. foreach (array($node->watch1, $node->watch2) as $literal) {
  11079. if (!isset($this->watchChains[$literal])) {
  11080. $this->watchChains[$literal] = new RuleWatchChain;
  11081. }
  11082. $this->watchChains[$literal]->unshift($node);
  11083. }
  11084. } else {
  11085. foreach ($node->getRule()->getLiterals() as $literal) {
  11086. if (!isset($this->watchChains[$literal])) {
  11087. $this->watchChains[$literal] = new RuleWatchChain;
  11088. }
  11089. $this->watchChains[$literal]->unshift($node);
  11090. }
  11091. }
  11092. }
  11093. public function propagateLiteral($decidedLiteral, $level, $decisions)
  11094. {
  11095. $literal = -$decidedLiteral;
  11096. if (!isset($this->watchChains[$literal])) {
  11097. return null;
  11098. }
  11099. $chain = $this->watchChains[$literal];
  11100. $chain->rewind();
  11101. while ($chain->valid()) {
  11102. $node = $chain->current();
  11103. if (!$node->getRule() instanceof MultiConflictRule) {
  11104. $otherWatch = $node->getOtherWatch($literal);
  11105. if (!$node->getRule()->isDisabled() && !$decisions->satisfy($otherWatch)) {
  11106. $ruleLiterals = $node->getRule()->getLiterals();
  11107. $alternativeLiterals = array_filter($ruleLiterals, function ($ruleLiteral) use ($literal, $otherWatch, $decisions) {
  11108. return $literal !== $ruleLiteral &&
  11109. $otherWatch !== $ruleLiteral &&
  11110. !$decisions->conflict($ruleLiteral);
  11111. });
  11112. if ($alternativeLiterals) {
  11113. reset($alternativeLiterals);
  11114. $this->moveWatch($literal, current($alternativeLiterals), $node);
  11115. continue;
  11116. }
  11117. if ($decisions->conflict($otherWatch)) {
  11118. return $node->getRule();
  11119. }
  11120. $decisions->decide($otherWatch, $level, $node->getRule());
  11121. }
  11122. } else {
  11123. foreach ($node->getRule()->getLiterals() as $otherLiteral) {
  11124. if ($literal !== $otherLiteral && !$decisions->satisfy($otherLiteral)) {
  11125. if ($decisions->conflict($otherLiteral)) {
  11126. return $node->getRule();
  11127. }
  11128. $decisions->decide($otherLiteral, $level, $node->getRule());
  11129. }
  11130. }
  11131. }
  11132. $chain->next();
  11133. }
  11134. return null;
  11135. }
  11136. protected function moveWatch($fromLiteral, $toLiteral, $node)
  11137. {
  11138. if (!isset($this->watchChains[$toLiteral])) {
  11139. $this->watchChains[$toLiteral] = new RuleWatchChain;
  11140. }
  11141. $node->moveWatch($fromLiteral, $toLiteral);
  11142. $this->watchChains[$fromLiteral]->remove();
  11143. $this->watchChains[$toLiteral]->unshift($node);
  11144. }
  11145. }
  11146. <?php
  11147. namespace Composer\DependencyResolver;
  11148. class RuleWatchNode
  11149. {
  11150. public $watch1;
  11151. public $watch2;
  11152. protected $rule;
  11153. public function __construct($rule)
  11154. {
  11155. $this->rule = $rule;
  11156. $literals = $rule->getLiterals();
  11157. $literalCount = \count($literals);
  11158. $this->watch1 = $literalCount > 0 ? $literals[0] : 0;
  11159. $this->watch2 = $literalCount > 1 ? $literals[1] : 0;
  11160. }
  11161. public function watch2OnHighest(Decisions $decisions)
  11162. {
  11163. $literals = $this->rule->getLiterals();
  11164. if (\count($literals) < 3 || $this->rule instanceof MultiConflictRule) {
  11165. return;
  11166. }
  11167. $watchLevel = 0;
  11168. foreach ($literals as $literal) {
  11169. $level = $decisions->decisionLevel($literal);
  11170. if ($level > $watchLevel) {
  11171. $this->watch2 = $literal;
  11172. $watchLevel = $level;
  11173. }
  11174. }
  11175. }
  11176. public function getRule()
  11177. {
  11178. return $this->rule;
  11179. }
  11180. public function getOtherWatch($literal)
  11181. {
  11182. if ($this->watch1 == $literal) {
  11183. return $this->watch2;
  11184. }
  11185. return $this->watch1;
  11186. }
  11187. public function moveWatch($from, $to)
  11188. {
  11189. if ($this->watch1 == $from) {
  11190. $this->watch1 = $to;
  11191. } else {
  11192. $this->watch2 = $to;
  11193. }
  11194. }
  11195. }
  11196. <?php
  11197. namespace Composer\DependencyResolver;
  11198. use Composer\IO\IOInterface;
  11199. use Composer\Package\PackageInterface;
  11200. use Composer\Repository\PlatformRepository;
  11201. class Solver
  11202. {
  11203. const BRANCH_LITERALS = 0;
  11204. const BRANCH_LEVEL = 1;
  11205. protected $policy;
  11206. protected $pool;
  11207. protected $rules;
  11208. protected $watchGraph;
  11209. protected $decisions;
  11210. protected $fixedMap;
  11211. protected $propagateIndex;
  11212. protected $branches = array();
  11213. protected $problems = array();
  11214. protected $learnedPool = array();
  11215. protected $learnedWhy = array();
  11216. public $testFlagLearnedPositiveLiteral = false;
  11217. protected $io;
  11218. public function __construct(PolicyInterface $policy, Pool $pool, IOInterface $io)
  11219. {
  11220. $this->io = $io;
  11221. $this->policy = $policy;
  11222. $this->pool = $pool;
  11223. }
  11224. public function getRuleSetSize()
  11225. {
  11226. return \count($this->rules);
  11227. }
  11228. public function getPool()
  11229. {
  11230. return $this->pool;
  11231. }
  11232. private function makeAssertionRuleDecisions()
  11233. {
  11234. $decisionStart = \count($this->decisions) - 1;
  11235. $rulesCount = \count($this->rules);
  11236. for ($ruleIndex = 0; $ruleIndex < $rulesCount; $ruleIndex++) {
  11237. $rule = $this->rules->ruleById[$ruleIndex];
  11238. if (!$rule->isAssertion() || $rule->isDisabled()) {
  11239. continue;
  11240. }
  11241. $literals = $rule->getLiterals();
  11242. $literal = $literals[0];
  11243. if (!$this->decisions->decided($literal)) {
  11244. $this->decisions->decide($literal, 1, $rule);
  11245. continue;
  11246. }
  11247. if ($this->decisions->satisfy($literal)) {
  11248. continue;
  11249. }
  11250. if (RuleSet::TYPE_LEARNED === $rule->getType()) {
  11251. $rule->disable();
  11252. continue;
  11253. }
  11254. $conflict = $this->decisions->decisionRule($literal);
  11255. if ($conflict && RuleSet::TYPE_PACKAGE === $conflict->getType()) {
  11256. $problem = new Problem();
  11257. $problem->addRule($rule);
  11258. $problem->addRule($conflict);
  11259. $rule->disable();
  11260. $this->problems[] = $problem;
  11261. continue;
  11262. }
  11263. $problem = new Problem();
  11264. $problem->addRule($rule);
  11265. $problem->addRule($conflict);
  11266. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_REQUEST) as $assertRule) {
  11267. if ($assertRule->isDisabled() || !$assertRule->isAssertion()) {
  11268. continue;
  11269. }
  11270. $assertRuleLiterals = $assertRule->getLiterals();
  11271. $assertRuleLiteral = $assertRuleLiterals[0];
  11272. if (abs($literal) !== abs($assertRuleLiteral)) {
  11273. continue;
  11274. }
  11275. $problem->addRule($assertRule);
  11276. $assertRule->disable();
  11277. }
  11278. $this->problems[] = $problem;
  11279. $this->decisions->resetToOffset($decisionStart);
  11280. $ruleIndex = -1;
  11281. }
  11282. }
  11283. protected function setupFixedMap(Request $request)
  11284. {
  11285. $this->fixedMap = array();
  11286. foreach ($request->getFixedPackages() as $package) {
  11287. $this->fixedMap[$package->id] = $package;
  11288. }
  11289. }
  11290. protected function checkForRootRequireProblems(Request $request, $ignorePlatformReqs)
  11291. {
  11292. foreach ($request->getRequires() as $packageName => $constraint) {
  11293. if ((true === $ignorePlatformReqs || (is_array($ignorePlatformReqs) && in_array($packageName, $ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($packageName)) {
  11294. continue;
  11295. }
  11296. if (!$this->pool->whatProvides($packageName, $constraint)) {
  11297. $problem = new Problem();
  11298. $problem->addRule(new GenericRule(array(), Rule::RULE_ROOT_REQUIRE, array('packageName' => $packageName, 'constraint' => $constraint)));
  11299. $this->problems[] = $problem;
  11300. }
  11301. }
  11302. }
  11303. public function solve(Request $request, $ignorePlatformReqs = false)
  11304. {
  11305. $this->setupFixedMap($request);
  11306. $this->io->writeError('Generating rules', true, IOInterface::DEBUG);
  11307. $ruleSetGenerator = new RuleSetGenerator($this->policy, $this->pool);
  11308. $this->rules = $ruleSetGenerator->getRulesFor($request, $ignorePlatformReqs);
  11309. unset($ruleSetGenerator);
  11310. $this->checkForRootRequireProblems($request, $ignorePlatformReqs);
  11311. $this->decisions = new Decisions($this->pool);
  11312. $this->watchGraph = new RuleWatchGraph;
  11313. foreach ($this->rules as $rule) {
  11314. $this->watchGraph->insert(new RuleWatchNode($rule));
  11315. }
  11316. $this->makeAssertionRuleDecisions();
  11317. $this->io->writeError('Resolving dependencies through SAT', true, IOInterface::DEBUG);
  11318. $before = microtime(true);
  11319. $this->runSat();
  11320. $this->io->writeError('', true, IOInterface::DEBUG);
  11321. $this->io->writeError(sprintf('Dependency resolution completed in %.3f seconds', microtime(true) - $before), true, IOInterface::VERBOSE);
  11322. if ($this->problems) {
  11323. throw new SolverProblemsException($this->problems, $this->learnedPool);
  11324. }
  11325. return new LockTransaction($this->pool, $request->getPresentMap(), $request->getFixedPackagesMap(), $this->decisions);
  11326. }
  11327. protected function propagate($level)
  11328. {
  11329. while ($this->decisions->validOffset($this->propagateIndex)) {
  11330. $decision = $this->decisions->atOffset($this->propagateIndex);
  11331. $conflict = $this->watchGraph->propagateLiteral(
  11332. $decision[Decisions::DECISION_LITERAL],
  11333. $level,
  11334. $this->decisions
  11335. );
  11336. $this->propagateIndex++;
  11337. if ($conflict) {
  11338. return $conflict;
  11339. }
  11340. }
  11341. return null;
  11342. }
  11343. private function revert($level)
  11344. {
  11345. while (!$this->decisions->isEmpty()) {
  11346. $literal = $this->decisions->lastLiteral();
  11347. if ($this->decisions->undecided($literal)) {
  11348. break;
  11349. }
  11350. $decisionLevel = $this->decisions->decisionLevel($literal);
  11351. if ($decisionLevel <= $level) {
  11352. break;
  11353. }
  11354. $this->decisions->revertLast();
  11355. $this->propagateIndex = \count($this->decisions);
  11356. }
  11357. while (!empty($this->branches) && $this->branches[\count($this->branches) - 1][self::BRANCH_LEVEL] >= $level) {
  11358. array_pop($this->branches);
  11359. }
  11360. }
  11361. private function setPropagateLearn($level, $literal, Rule $rule)
  11362. {
  11363. $level++;
  11364. $this->decisions->decide($literal, $level, $rule);
  11365. while (true) {
  11366. $rule = $this->propagate($level);
  11367. if (!$rule) {
  11368. break;
  11369. }
  11370. if ($level == 1) {
  11371. return $this->analyzeUnsolvable($rule);
  11372. }
  11373. list($learnLiteral, $newLevel, $newRule, $why) = $this->analyze($level, $rule);
  11374. if ($newLevel <= 0 || $newLevel >= $level) {
  11375. throw new SolverBugException(
  11376. "Trying to revert to invalid level ".(int) $newLevel." from level ".(int) $level."."
  11377. );
  11378. }
  11379. if (!$newRule) {
  11380. throw new SolverBugException(
  11381. "No rule was learned from analyzing $rule at level $level."
  11382. );
  11383. }
  11384. $level = $newLevel;
  11385. $this->revert($level);
  11386. $this->rules->add($newRule, RuleSet::TYPE_LEARNED);
  11387. $this->learnedWhy[spl_object_hash($newRule)] = $why;
  11388. $ruleNode = new RuleWatchNode($newRule);
  11389. $ruleNode->watch2OnHighest($this->decisions);
  11390. $this->watchGraph->insert($ruleNode);
  11391. $this->decisions->decide($learnLiteral, $level, $newRule);
  11392. }
  11393. return $level;
  11394. }
  11395. private function selectAndInstall($level, array $decisionQueue, Rule $rule)
  11396. {
  11397. $literals = $this->policy->selectPreferredPackages($this->pool, $decisionQueue, $rule->getRequiredPackage());
  11398. $selectedLiteral = array_shift($literals);
  11399. if (\count($literals)) {
  11400. $this->branches[] = array($literals, $level);
  11401. }
  11402. return $this->setPropagateLearn($level, $selectedLiteral, $rule);
  11403. }
  11404. protected function analyze($level, Rule $rule)
  11405. {
  11406. $analyzedRule = $rule;
  11407. $ruleLevel = 1;
  11408. $num = 0;
  11409. $l1num = 0;
  11410. $seen = array();
  11411. $learnedLiterals = array(null);
  11412. $decisionId = \count($this->decisions);
  11413. $this->learnedPool[] = array();
  11414. while (true) {
  11415. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  11416. foreach ($rule->getLiterals() as $literal) {
  11417. if ($rule instanceof MultiConflictRule && !$this->decisions->decided($literal)) {
  11418. continue;
  11419. }
  11420. if ($this->decisions->satisfy($literal)) {
  11421. continue;
  11422. }
  11423. if (isset($seen[abs($literal)])) {
  11424. continue;
  11425. }
  11426. $seen[abs($literal)] = true;
  11427. $l = $this->decisions->decisionLevel($literal);
  11428. if (1 === $l) {
  11429. $l1num++;
  11430. } elseif ($level === $l) {
  11431. $num++;
  11432. } else {
  11433. $learnedLiterals[] = $literal;
  11434. if ($l > $ruleLevel) {
  11435. $ruleLevel = $l;
  11436. }
  11437. }
  11438. }
  11439. unset($literal);
  11440. $l1retry = true;
  11441. while ($l1retry) {
  11442. $l1retry = false;
  11443. if (!$num && !--$l1num) {
  11444. break 2;
  11445. }
  11446. while (true) {
  11447. if ($decisionId <= 0) {
  11448. throw new SolverBugException(
  11449. "Reached invalid decision id $decisionId while looking through $rule for a literal present in the analyzed rule $analyzedRule."
  11450. );
  11451. }
  11452. $decisionId--;
  11453. $decision = $this->decisions->atOffset($decisionId);
  11454. $literal = $decision[Decisions::DECISION_LITERAL];
  11455. if (isset($seen[abs($literal)])) {
  11456. break;
  11457. }
  11458. }
  11459. unset($seen[abs($literal)]);
  11460. if ($num && 0 === --$num) {
  11461. if ($literal < 0) {
  11462. $this->testFlagLearnedPositiveLiteral = true;
  11463. }
  11464. $learnedLiterals[0] = -$literal;
  11465. if (!$l1num) {
  11466. break 2;
  11467. }
  11468. foreach ($learnedLiterals as $i => $learnedLiteral) {
  11469. if ($i !== 0) {
  11470. unset($seen[abs($learnedLiteral)]);
  11471. }
  11472. }
  11473. $l1num++;
  11474. $l1retry = true;
  11475. } else {
  11476. $decision = $this->decisions->atOffset($decisionId);
  11477. $rule = $decision[Decisions::DECISION_REASON];
  11478. if ($rule instanceof MultiConflictRule) {
  11479. foreach ($rule->getLiterals() as $literal) {
  11480. if (!isset($seen[abs($literal)]) && $this->decisions->satisfy(-$literal)) {
  11481. $this->learnedPool[\count($this->learnedPool) - 1][] = $rule;
  11482. $l = $this->decisions->decisionLevel($literal);
  11483. if (1 === $l) {
  11484. $l1num++;
  11485. } elseif ($level === $l) {
  11486. $num++;
  11487. } else {
  11488. $learnedLiterals[] = $literal;
  11489. if ($l > $ruleLevel) {
  11490. $ruleLevel = $l;
  11491. }
  11492. }
  11493. $seen[abs($literal)] = true;
  11494. break;
  11495. }
  11496. }
  11497. $l1retry = true;
  11498. }
  11499. }
  11500. }
  11501. $decision = $this->decisions->atOffset($decisionId);
  11502. $rule = $decision[Decisions::DECISION_REASON];
  11503. }
  11504. $why = \count($this->learnedPool) - 1;
  11505. if (!$learnedLiterals[0]) {
  11506. throw new SolverBugException(
  11507. "Did not find a learnable literal in analyzed rule $analyzedRule."
  11508. );
  11509. }
  11510. $newRule = new GenericRule($learnedLiterals, Rule::RULE_LEARNED, $why);
  11511. return array($learnedLiterals[0], $ruleLevel, $newRule, $why);
  11512. }
  11513. private function analyzeUnsolvableRule(Problem $problem, Rule $conflictRule, array &$ruleSeen)
  11514. {
  11515. $why = spl_object_hash($conflictRule);
  11516. $ruleSeen[$why] = true;
  11517. if ($conflictRule->getType() == RuleSet::TYPE_LEARNED) {
  11518. $learnedWhy = $this->learnedWhy[$why];
  11519. $problemRules = $this->learnedPool[$learnedWhy];
  11520. foreach ($problemRules as $problemRule) {
  11521. if (!isset($ruleSeen[spl_object_hash($problemRule)])) {
  11522. $this->analyzeUnsolvableRule($problem, $problemRule, $ruleSeen);
  11523. }
  11524. }
  11525. return;
  11526. }
  11527. if ($conflictRule->getType() == RuleSet::TYPE_PACKAGE) {
  11528. return;
  11529. }
  11530. $problem->nextSection();
  11531. $problem->addRule($conflictRule);
  11532. }
  11533. private function analyzeUnsolvable(Rule $conflictRule)
  11534. {
  11535. $problem = new Problem();
  11536. $problem->addRule($conflictRule);
  11537. $ruleSeen = array();
  11538. $this->analyzeUnsolvableRule($problem, $conflictRule, $ruleSeen);
  11539. $this->problems[] = $problem;
  11540. $seen = array();
  11541. $literals = $conflictRule->getLiterals();
  11542. foreach ($literals as $literal) {
  11543. if ($this->decisions->satisfy($literal)) {
  11544. continue;
  11545. }
  11546. $seen[abs($literal)] = true;
  11547. }
  11548. foreach ($this->decisions as $decision) {
  11549. $literal = $decision[Decisions::DECISION_LITERAL];
  11550. if (!isset($seen[abs($literal)])) {
  11551. continue;
  11552. }
  11553. $why = $decision[Decisions::DECISION_REASON];
  11554. $problem->addRule($why);
  11555. $this->analyzeUnsolvableRule($problem, $why, $ruleSeen);
  11556. $literals = $why->getLiterals();
  11557. foreach ($literals as $literal) {
  11558. if ($this->decisions->satisfy($literal)) {
  11559. continue;
  11560. }
  11561. $seen[abs($literal)] = true;
  11562. }
  11563. }
  11564. return 0;
  11565. }
  11566. private function enableDisableLearnedRules()
  11567. {
  11568. foreach ($this->rules->getIteratorFor(RuleSet::TYPE_LEARNED) as $rule) {
  11569. $why = $this->learnedWhy[spl_object_hash($rule)];
  11570. $problemRules = $this->learnedPool[$why];
  11571. $foundDisabled = false;
  11572. foreach ($problemRules as $problemRule) {
  11573. if ($problemRule->isDisabled()) {
  11574. $foundDisabled = true;
  11575. break;
  11576. }
  11577. }
  11578. if ($foundDisabled && $rule->isEnabled()) {
  11579. $rule->disable();
  11580. } elseif (!$foundDisabled && $rule->isDisabled()) {
  11581. $rule->enable();
  11582. }
  11583. }
  11584. }
  11585. private function runSat()
  11586. {
  11587. $this->propagateIndex = 0;
  11588. $level = 1;
  11589. $systemLevel = $level + 1;
  11590. while (true) {
  11591. if (1 === $level) {
  11592. $conflictRule = $this->propagate($level);
  11593. if (null !== $conflictRule) {
  11594. if ($this->analyzeUnsolvable($conflictRule)) {
  11595. continue;
  11596. }
  11597. return;
  11598. }
  11599. }
  11600. if ($level < $systemLevel) {
  11601. $iterator = $this->rules->getIteratorFor(RuleSet::TYPE_REQUEST);
  11602. foreach ($iterator as $rule) {
  11603. if ($rule->isEnabled()) {
  11604. $decisionQueue = array();
  11605. $noneSatisfied = true;
  11606. foreach ($rule->getLiterals() as $literal) {
  11607. if ($this->decisions->satisfy($literal)) {
  11608. $noneSatisfied = false;
  11609. break;
  11610. }
  11611. if ($literal > 0 && $this->decisions->undecided($literal)) {
  11612. $decisionQueue[] = $literal;
  11613. }
  11614. }
  11615. if ($noneSatisfied && \count($decisionQueue)) {
  11616. $prunedQueue = array();
  11617. foreach ($decisionQueue as $literal) {
  11618. if (isset($this->fixedMap[abs($literal)])) {
  11619. $prunedQueue[] = $literal;
  11620. }
  11621. }
  11622. if (!empty($prunedQueue)) {
  11623. $decisionQueue = $prunedQueue;
  11624. }
  11625. }
  11626. if ($noneSatisfied && \count($decisionQueue)) {
  11627. $oLevel = $level;
  11628. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  11629. if (0 === $level) {
  11630. return;
  11631. }
  11632. if ($level <= $oLevel) {
  11633. break;
  11634. }
  11635. }
  11636. }
  11637. }
  11638. $systemLevel = $level + 1;
  11639. $iterator->next();
  11640. if ($iterator->valid()) {
  11641. continue;
  11642. }
  11643. }
  11644. if ($level < $systemLevel) {
  11645. $systemLevel = $level;
  11646. }
  11647. $rulesCount = \count($this->rules);
  11648. $pass = 1;
  11649. $this->io->writeError('Looking at all rules.', true, IOInterface::DEBUG);
  11650. for ($i = 0, $n = 0; $n < $rulesCount; $i++, $n++) {
  11651. if ($i == $rulesCount) {
  11652. if (1 === $pass) {
  11653. $this->io->writeError("Something's changed, looking at all rules again (pass #$pass)", false, IOInterface::DEBUG);
  11654. } else {
  11655. $this->io->overwriteError("Something's changed, looking at all rules again (pass #$pass)", false, null, IOInterface::DEBUG);
  11656. }
  11657. $i = 0;
  11658. $pass++;
  11659. }
  11660. $rule = $this->rules->ruleById[$i];
  11661. $literals = $rule->getLiterals();
  11662. if ($rule->isDisabled()) {
  11663. continue;
  11664. }
  11665. $decisionQueue = array();
  11666. foreach ($literals as $literal) {
  11667. if ($literal <= 0) {
  11668. if (!$this->decisions->decidedInstall($literal)) {
  11669. continue 2;
  11670. }
  11671. } else {
  11672. if ($this->decisions->decidedInstall($literal)) {
  11673. continue 2;
  11674. }
  11675. if ($this->decisions->undecided($literal)) {
  11676. $decisionQueue[] = $literal;
  11677. }
  11678. }
  11679. }
  11680. if (\count($decisionQueue) < 2) {
  11681. continue;
  11682. }
  11683. $level = $this->selectAndInstall($level, $decisionQueue, $rule);
  11684. if (0 === $level) {
  11685. return;
  11686. }
  11687. $rulesCount = \count($this->rules);
  11688. $n = -1;
  11689. }
  11690. if ($level < $systemLevel) {
  11691. continue;
  11692. }
  11693. if (\count($this->branches)) {
  11694. $lastLiteral = null;
  11695. $lastLevel = null;
  11696. $lastBranchIndex = 0;
  11697. $lastBranchOffset = 0;
  11698. for ($i = \count($this->branches) - 1; $i >= 0; $i--) {
  11699. list($literals, $l) = $this->branches[$i];
  11700. foreach ($literals as $offset => $literal) {
  11701. if ($literal && $literal > 0 && $this->decisions->decisionLevel($literal) > $l + 1) {
  11702. $lastLiteral = $literal;
  11703. $lastBranchIndex = $i;
  11704. $lastBranchOffset = $offset;
  11705. $lastLevel = $l;
  11706. }
  11707. }
  11708. }
  11709. if ($lastLiteral) {
  11710. unset($this->branches[$lastBranchIndex][self::BRANCH_LITERALS][$lastBranchOffset]);
  11711. $level = $lastLevel;
  11712. $this->revert($level);
  11713. $why = $this->decisions->lastReason();
  11714. $level = $this->setPropagateLearn($level, $lastLiteral, $why);
  11715. if ($level == 0) {
  11716. return;
  11717. }
  11718. continue;
  11719. }
  11720. }
  11721. break;
  11722. }
  11723. }
  11724. }
  11725. <?php
  11726. namespace Composer\DependencyResolver;
  11727. class SolverBugException extends \RuntimeException
  11728. {
  11729. public function __construct($message)
  11730. {
  11731. parent::__construct(
  11732. $message."\nThis exception was most likely caused by a bug in Composer.\n".
  11733. "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"
  11734. );
  11735. }
  11736. }
  11737. <?php
  11738. namespace Composer\DependencyResolver;
  11739. use Composer\Util\IniHelper;
  11740. use Composer\Repository\RepositorySet;
  11741. class SolverProblemsException extends \RuntimeException
  11742. {
  11743. protected $problems;
  11744. protected $learnedPool;
  11745. public function __construct(array $problems, array $learnedPool)
  11746. {
  11747. $this->problems = $problems;
  11748. $this->learnedPool = $learnedPool;
  11749. parent::__construct('Failed resolving dependencies with '.count($problems).' problems, call getPrettyString to get formatted details', 2);
  11750. }
  11751. public function getPrettyString(RepositorySet $repositorySet, Request $request, Pool $pool, $isVerbose, $isDevExtraction = false)
  11752. {
  11753. $installedMap = $request->getPresentMap(true);
  11754. $hasExtensionProblems = false;
  11755. $isCausedByLock = false;
  11756. $problems = array();
  11757. foreach ($this->problems as $problem) {
  11758. $problems[] = $problem->getPrettyString($repositorySet, $request, $pool, $isVerbose, $installedMap, $this->learnedPool)."\n";
  11759. if (!$hasExtensionProblems && $this->hasExtensionProblems($problem->getReasons())) {
  11760. $hasExtensionProblems = true;
  11761. }
  11762. $isCausedByLock |= $problem->isCausedByLock($repositorySet, $request, $pool);
  11763. }
  11764. $i = 1;
  11765. $text = "\n";
  11766. foreach (array_unique($problems) as $problem) {
  11767. $text .= " Problem ".($i++).$problem;
  11768. }
  11769. $hints = array();
  11770. if (!$isDevExtraction && (strpos($text, 'could not be found') || strpos($text, 'no matching package found'))) {
  11771. $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.";
  11772. }
  11773. if ($hasExtensionProblems) {
  11774. $hints[] = $this->createExtensionHint();
  11775. }
  11776. if ($isCausedByLock && !$isDevExtraction) {
  11777. $hints[] = "Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.";
  11778. }
  11779. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match') && strpos($text, '- ocramius/package-versions')) {
  11780. $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+.";
  11781. }
  11782. if (!class_exists('PHPUnit\Framework\TestCase', false)) {
  11783. if (strpos($text, 'found composer-plugin-api[2.0.0] but it does not match')) {
  11784. $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.";
  11785. }
  11786. }
  11787. if ($hints) {
  11788. $text .= "\n" . implode("\n\n", $hints);
  11789. }
  11790. return $text;
  11791. }
  11792. public function getProblems()
  11793. {
  11794. return $this->problems;
  11795. }
  11796. private function createExtensionHint()
  11797. {
  11798. $paths = IniHelper::getAll();
  11799. if (count($paths) === 1 && empty($paths[0])) {
  11800. return '';
  11801. }
  11802. $text = "To enable extensions, verify that they are enabled in your .ini files:\n - ";
  11803. $text .= implode("\n - ", $paths);
  11804. $text .= "\nYou can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.";
  11805. return $text;
  11806. }
  11807. private function hasExtensionProblems(array $reasonSets)
  11808. {
  11809. foreach ($reasonSets as $reasonSet) {
  11810. foreach ($reasonSet as $rule) {
  11811. if (0 === strpos($rule->getRequiredPackage(), 'ext-')) {
  11812. return true;
  11813. }
  11814. }
  11815. }
  11816. return false;
  11817. }
  11818. }
  11819. <?php
  11820. namespace Composer\DependencyResolver;
  11821. use Composer\Package\AliasPackage;
  11822. use Composer\Package\Link;
  11823. use Composer\Package\PackageInterface;
  11824. use Composer\Repository\PlatformRepository;
  11825. class Transaction
  11826. {
  11827. protected $operations;
  11828. protected $presentPackages;
  11829. protected $resultPackageMap;
  11830. protected $resultPackagesByName = array();
  11831. public function __construct($presentPackages, $resultPackages)
  11832. {
  11833. $this->presentPackages = $presentPackages;
  11834. $this->setResultPackageMaps($resultPackages);
  11835. $this->operations = $this->calculateOperations();
  11836. }
  11837. public function getOperations()
  11838. {
  11839. return $this->operations;
  11840. }
  11841. private function setResultPackageMaps($resultPackages)
  11842. {
  11843. $packageSort = function (PackageInterface $a, PackageInterface $b) {
  11844. if ($a->getName() == $b->getName()) {
  11845. if ($a instanceof AliasPackage != $b instanceof AliasPackage) {
  11846. return $a instanceof AliasPackage ? -1 : 1;
  11847. }
  11848. return strcmp($b->getVersion(), $a->getVersion());
  11849. }
  11850. return strcmp($b->getName(), $a->getName());
  11851. };
  11852. $this->resultPackageMap = array();
  11853. foreach ($resultPackages as $package) {
  11854. $this->resultPackageMap[spl_object_hash($package)] = $package;
  11855. foreach ($package->getNames() as $name) {
  11856. $this->resultPackagesByName[$name][] = $package;
  11857. }
  11858. }
  11859. uasort($this->resultPackageMap, $packageSort);
  11860. foreach ($this->resultPackagesByName as $name => $packages) {
  11861. uasort($this->resultPackagesByName[$name], $packageSort);
  11862. }
  11863. }
  11864. protected function calculateOperations()
  11865. {
  11866. $operations = array();
  11867. $presentPackageMap = array();
  11868. $removeMap = array();
  11869. $presentAliasMap = array();
  11870. $removeAliasMap = array();
  11871. foreach ($this->presentPackages as $package) {
  11872. if ($package instanceof AliasPackage) {
  11873. $presentAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  11874. $removeAliasMap[$package->getName().'::'.$package->getVersion()] = $package;
  11875. } else {
  11876. $presentPackageMap[$package->getName()] = $package;
  11877. $removeMap[$package->getName()] = $package;
  11878. }
  11879. }
  11880. $stack = $this->getRootPackages();
  11881. $visited = array();
  11882. $processed = array();
  11883. while (!empty($stack)) {
  11884. $package = array_pop($stack);
  11885. if (isset($processed[spl_object_hash($package)])) {
  11886. continue;
  11887. }
  11888. if (!isset($visited[spl_object_hash($package)])) {
  11889. $visited[spl_object_hash($package)] = true;
  11890. $stack[] = $package;
  11891. if ($package instanceof AliasPackage) {
  11892. $stack[] = $package->getAliasOf();
  11893. } else {
  11894. foreach ($package->getRequires() as $link) {
  11895. $possibleRequires = $this->getProvidersInResult($link);
  11896. foreach ($possibleRequires as $require) {
  11897. $stack[] = $require;
  11898. }
  11899. }
  11900. }
  11901. } elseif (!isset($processed[spl_object_hash($package)])) {
  11902. $processed[spl_object_hash($package)] = true;
  11903. if ($package instanceof AliasPackage) {
  11904. $aliasKey = $package->getName().'::'.$package->getVersion();
  11905. if (isset($presentAliasMap[$aliasKey])) {
  11906. unset($removeAliasMap[$aliasKey]);
  11907. } else {
  11908. $operations[] = new Operation\MarkAliasInstalledOperation($package);
  11909. }
  11910. } else {
  11911. if (isset($presentPackageMap[$package->getName()])) {
  11912. $source = $presentPackageMap[$package->getName()];
  11913. if ($package->getVersion() != $presentPackageMap[$package->getName()]->getVersion() ||
  11914. $package->getDistReference() !== $presentPackageMap[$package->getName()]->getDistReference() ||
  11915. $package->getSourceReference() !== $presentPackageMap[$package->getName()]->getSourceReference()
  11916. ) {
  11917. $operations[] = new Operation\UpdateOperation($source, $package);
  11918. }
  11919. unset($removeMap[$package->getName()]);
  11920. } else {
  11921. $operations[] = new Operation\InstallOperation($package);
  11922. unset($removeMap[$package->getName()]);
  11923. }
  11924. }
  11925. }
  11926. }
  11927. foreach ($removeMap as $name => $package) {
  11928. array_unshift($operations, new Operation\UninstallOperation($package));
  11929. }
  11930. foreach ($removeAliasMap as $nameVersion => $package) {
  11931. $operations[] = new Operation\MarkAliasUninstalledOperation($package);
  11932. }
  11933. $operations = $this->movePluginsToFront($operations);
  11934. $operations = $this->moveUninstallsToFront($operations);
  11935. return $this->operations = $operations;
  11936. }
  11937. protected function getRootPackages()
  11938. {
  11939. $roots = $this->resultPackageMap;
  11940. foreach ($this->resultPackageMap as $packageHash => $package) {
  11941. if (!isset($roots[$packageHash])) {
  11942. continue;
  11943. }
  11944. foreach ($package->getRequires() as $link) {
  11945. $possibleRequires = $this->getProvidersInResult($link);
  11946. foreach ($possibleRequires as $require) {
  11947. if ($require !== $package) {
  11948. unset($roots[spl_object_hash($require)]);
  11949. }
  11950. }
  11951. }
  11952. }
  11953. return $roots;
  11954. }
  11955. protected function getProvidersInResult(Link $link)
  11956. {
  11957. if (!isset($this->resultPackagesByName[$link->getTarget()])) {
  11958. return array();
  11959. }
  11960. return $this->resultPackagesByName[$link->getTarget()];
  11961. }
  11962. private function movePluginsToFront(array $operations)
  11963. {
  11964. $dlModifyingPluginsNoDeps = array();
  11965. $dlModifyingPluginsWithDeps = array();
  11966. $dlModifyingPluginRequires = array();
  11967. $pluginsNoDeps = array();
  11968. $pluginsWithDeps = array();
  11969. $pluginRequires = array();
  11970. foreach (array_reverse($operations, true) as $idx => $op) {
  11971. if ($op instanceof Operation\InstallOperation) {
  11972. $package = $op->getPackage();
  11973. } elseif ($op instanceof Operation\UpdateOperation) {
  11974. $package = $op->getTargetPackage();
  11975. } else {
  11976. continue;
  11977. }
  11978. $isDownloadsModifyingPlugin = $package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true;
  11979. if ($isDownloadsModifyingPlugin || count(array_intersect($package->getNames(), $dlModifyingPluginRequires))) {
  11980. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  11981. return !PlatformRepository::isPlatformPackage($req);
  11982. });
  11983. if ($isDownloadsModifyingPlugin && !count($requires)) {
  11984. array_unshift($dlModifyingPluginsNoDeps, $op);
  11985. } else {
  11986. $dlModifyingPluginRequires = array_merge($dlModifyingPluginRequires, $requires);
  11987. array_unshift($dlModifyingPluginsWithDeps, $op);
  11988. }
  11989. unset($operations[$idx]);
  11990. continue;
  11991. }
  11992. $isPlugin = $package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer';
  11993. if ($isPlugin || count(array_intersect($package->getNames(), $pluginRequires))) {
  11994. $requires = array_filter(array_keys($package->getRequires()), function ($req) {
  11995. return !PlatformRepository::isPlatformPackage($req);
  11996. });
  11997. if ($isPlugin && !count($requires)) {
  11998. array_unshift($pluginsNoDeps, $op);
  11999. } else {
  12000. $pluginRequires = array_merge($pluginRequires, $requires);
  12001. array_unshift($pluginsWithDeps, $op);
  12002. }
  12003. unset($operations[$idx]);
  12004. }
  12005. }
  12006. return array_merge($dlModifyingPluginsNoDeps, $dlModifyingPluginsWithDeps, $pluginsNoDeps, $pluginsWithDeps, $operations);
  12007. }
  12008. private function moveUninstallsToFront(array $operations)
  12009. {
  12010. $uninstOps = array();
  12011. foreach ($operations as $idx => $op) {
  12012. if ($op instanceof Operation\UninstallOperation || $op instanceof Operation\MarkAliasUninstalledOperation) {
  12013. $uninstOps[] = $op;
  12014. unset($operations[$idx]);
  12015. }
  12016. }
  12017. return array_merge($uninstOps, $operations);
  12018. }
  12019. }
  12020. <?php
  12021. namespace Composer\Downloader;
  12022. use Composer\Package\PackageInterface;
  12023. use Symfony\Component\Finder\Finder;
  12024. use React\Promise\PromiseInterface;
  12025. use Composer\DependencyResolver\Operation\InstallOperation;
  12026. abstract class ArchiveDownloader extends FileDownloader
  12027. {
  12028. public function install(PackageInterface $package, $path, $output = true)
  12029. {
  12030. if ($output) {
  12031. $this->io->writeError(" - " . InstallOperation::format($package).": Extracting archive");
  12032. } else {
  12033. $this->io->writeError('Extracting archive', false);
  12034. }
  12035. $vendorDir = $this->config->get('vendor-dir');
  12036. if (false === strpos($this->filesystem->normalizePath($vendorDir), $this->filesystem->normalizePath($path.DIRECTORY_SEPARATOR))) {
  12037. $this->filesystem->emptyDirectory($path);
  12038. }
  12039. do {
  12040. $temporaryDir = $vendorDir.'/composer/'.substr(md5(uniqid('', true)), 0, 8);
  12041. } while (is_dir($temporaryDir));
  12042. $this->addCleanupPath($package, $temporaryDir);
  12043. if (!is_dir($path) || realpath($path) !== getcwd()) {
  12044. $this->addCleanupPath($package, $path);
  12045. }
  12046. $this->filesystem->ensureDirectoryExists($temporaryDir);
  12047. $fileName = $this->getFileName($package, $path);
  12048. $filesystem = $this->filesystem;
  12049. $self = $this;
  12050. $cleanup = function () use ($path, $filesystem, $temporaryDir, $package, $self) {
  12051. $self->clearLastCacheWrite($package);
  12052. $filesystem->removeDirectory($temporaryDir);
  12053. if (is_dir($path) && realpath($path) !== getcwd()) {
  12054. $filesystem->removeDirectory($path);
  12055. }
  12056. $self->removeCleanupPath($package, $temporaryDir);
  12057. $self->removeCleanupPath($package, realpath($path));
  12058. };
  12059. $promise = null;
  12060. try {
  12061. $promise = $this->extract($package, $fileName, $temporaryDir);
  12062. } catch (\Exception $e) {
  12063. $cleanup();
  12064. throw $e;
  12065. }
  12066. if (!$promise instanceof PromiseInterface) {
  12067. $promise = \React\Promise\resolve();
  12068. }
  12069. return $promise->then(function () use ($self, $package, $filesystem, $fileName, $temporaryDir, $path) {
  12070. $filesystem->unlink($fileName);
  12071. $getFolderContent = function ($dir) {
  12072. $finder = Finder::create()
  12073. ->ignoreVCS(false)
  12074. ->ignoreDotFiles(false)
  12075. ->notName('.DS_Store')
  12076. ->depth(0)
  12077. ->in($dir);
  12078. return iterator_to_array($finder);
  12079. };
  12080. $renameAsOne = false;
  12081. if (!file_exists($path) || ($filesystem->isDirEmpty($path) && $filesystem->removeDirectory($path))) {
  12082. $renameAsOne = true;
  12083. }
  12084. $contentDir = $getFolderContent($temporaryDir);
  12085. $singleDirAtTopLevel = 1 === count($contentDir) && is_dir(reset($contentDir));
  12086. if ($renameAsOne) {
  12087. if ($singleDirAtTopLevel) {
  12088. $extractedDir = (string) reset($contentDir);
  12089. } else {
  12090. $extractedDir = $temporaryDir;
  12091. }
  12092. $filesystem->rename($extractedDir, $path);
  12093. } else {
  12094. if ($singleDirAtTopLevel) {
  12095. $contentDir = $getFolderContent((string) reset($contentDir));
  12096. }
  12097. foreach ($contentDir as $file) {
  12098. $file = (string) $file;
  12099. $filesystem->rename($file, $path . '/' . basename($file));
  12100. }
  12101. }
  12102. $filesystem->removeDirectory($temporaryDir);
  12103. $self->removeCleanupPath($package, $temporaryDir);
  12104. $self->removeCleanupPath($package, $path);
  12105. }, function ($e) use ($cleanup) {
  12106. $cleanup();
  12107. throw $e;
  12108. });
  12109. }
  12110. abstract protected function extract(PackageInterface $package, $file, $path);
  12111. }
  12112. <?php
  12113. namespace Composer\Downloader;
  12114. use Composer\Package\PackageInterface;
  12115. interface ChangeReportInterface
  12116. {
  12117. public function getLocalChanges(PackageInterface $package, $path);
  12118. }
  12119. <?php
  12120. namespace Composer\Downloader;
  12121. use Composer\Package\PackageInterface;
  12122. use Composer\IO\IOInterface;
  12123. use Composer\Util\Filesystem;
  12124. use Composer\Exception\IrrecoverableDownloadException;
  12125. use React\Promise\PromiseInterface;
  12126. class DownloadManager
  12127. {
  12128. private $io;
  12129. private $preferDist = false;
  12130. private $preferSource;
  12131. private $packagePreferences = array();
  12132. private $filesystem;
  12133. private $downloaders = array();
  12134. public function __construct(IOInterface $io, $preferSource = false, Filesystem $filesystem = null)
  12135. {
  12136. $this->io = $io;
  12137. $this->preferSource = $preferSource;
  12138. $this->filesystem = $filesystem ?: new Filesystem();
  12139. }
  12140. public function setPreferSource($preferSource)
  12141. {
  12142. $this->preferSource = $preferSource;
  12143. return $this;
  12144. }
  12145. public function setPreferDist($preferDist)
  12146. {
  12147. $this->preferDist = $preferDist;
  12148. return $this;
  12149. }
  12150. public function setPreferences(array $preferences)
  12151. {
  12152. $this->packagePreferences = $preferences;
  12153. return $this;
  12154. }
  12155. public function setDownloader($type, DownloaderInterface $downloader)
  12156. {
  12157. $type = strtolower($type);
  12158. $this->downloaders[$type] = $downloader;
  12159. return $this;
  12160. }
  12161. public function getDownloader($type)
  12162. {
  12163. $type = strtolower($type);
  12164. if (!isset($this->downloaders[$type])) {
  12165. throw new \InvalidArgumentException(sprintf('Unknown downloader type: %s. Available types: %s.', $type, implode(', ', array_keys($this->downloaders))));
  12166. }
  12167. return $this->downloaders[$type];
  12168. }
  12169. public function getDownloaderForPackage(PackageInterface $package)
  12170. {
  12171. $installationSource = $package->getInstallationSource();
  12172. if ('metapackage' === $package->getType()) {
  12173. return;
  12174. }
  12175. if ('dist' === $installationSource) {
  12176. $downloader = $this->getDownloader($package->getDistType());
  12177. } elseif ('source' === $installationSource) {
  12178. $downloader = $this->getDownloader($package->getSourceType());
  12179. } else {
  12180. throw new \InvalidArgumentException(
  12181. 'Package '.$package.' does not have an installation source set'
  12182. );
  12183. }
  12184. if ($installationSource !== $downloader->getInstallationSource()) {
  12185. throw new \LogicException(sprintf(
  12186. 'Downloader "%s" is a %s type downloader and can not be used to download %s for package %s',
  12187. get_class($downloader),
  12188. $downloader->getInstallationSource(),
  12189. $installationSource,
  12190. $package
  12191. ));
  12192. }
  12193. return $downloader;
  12194. }
  12195. public function getDownloaderType(DownloaderInterface $downloader)
  12196. {
  12197. return array_search($downloader, $this->downloaders);
  12198. }
  12199. public function download(PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12200. {
  12201. $targetDir = $this->normalizeTargetDir($targetDir);
  12202. $this->filesystem->ensureDirectoryExists(dirname($targetDir));
  12203. $sources = $this->getAvailableSources($package, $prevPackage);
  12204. $io = $this->io;
  12205. $self = $this;
  12206. $download = function ($retry = false) use (&$sources, $io, $package, $self, $targetDir, &$download, $prevPackage) {
  12207. $source = array_shift($sources);
  12208. if ($retry) {
  12209. $io->writeError(' <warning>Now trying to download from ' . $source . '</warning>');
  12210. }
  12211. $package->setInstallationSource($source);
  12212. $downloader = $self->getDownloaderForPackage($package);
  12213. if (!$downloader) {
  12214. return \React\Promise\resolve();
  12215. }
  12216. $handleError = function ($e) use ($sources, $source, $package, $io, $download) {
  12217. if ($e instanceof \RuntimeException && !$e instanceof IrrecoverableDownloadException) {
  12218. if (!$sources) {
  12219. throw $e;
  12220. }
  12221. $io->writeError(
  12222. ' <warning>Failed to download '.
  12223. $package->getPrettyName().
  12224. ' from ' . $source . ': '.
  12225. $e->getMessage().'</warning>'
  12226. );
  12227. return $download(true);
  12228. }
  12229. throw $e;
  12230. };
  12231. try {
  12232. $result = $downloader->download($package, $targetDir, $prevPackage);
  12233. } catch (\Exception $e) {
  12234. return $handleError($e);
  12235. }
  12236. if (!$result instanceof PromiseInterface) {
  12237. return \React\Promise\resolve($result);
  12238. }
  12239. $res = $result->then(function ($res) {
  12240. return $res;
  12241. }, $handleError);
  12242. return $res;
  12243. };
  12244. return $download();
  12245. }
  12246. public function prepare($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12247. {
  12248. $targetDir = $this->normalizeTargetDir($targetDir);
  12249. $downloader = $this->getDownloaderForPackage($package);
  12250. if ($downloader) {
  12251. return $downloader->prepare($type, $package, $targetDir, $prevPackage);
  12252. }
  12253. }
  12254. public function install(PackageInterface $package, $targetDir)
  12255. {
  12256. $targetDir = $this->normalizeTargetDir($targetDir);
  12257. $downloader = $this->getDownloaderForPackage($package);
  12258. if ($downloader) {
  12259. return $downloader->install($package, $targetDir);
  12260. }
  12261. }
  12262. public function update(PackageInterface $initial, PackageInterface $target, $targetDir)
  12263. {
  12264. $targetDir = $this->normalizeTargetDir($targetDir);
  12265. $downloader = $this->getDownloaderForPackage($target);
  12266. $initialDownloader = $this->getDownloaderForPackage($initial);
  12267. if (!$initialDownloader && !$downloader) {
  12268. return;
  12269. }
  12270. if (!$downloader) {
  12271. return $initialDownloader->remove($initial, $targetDir);
  12272. }
  12273. $initialType = $this->getDownloaderType($initialDownloader);
  12274. $targetType = $this->getDownloaderType($downloader);
  12275. if ($initialType === $targetType) {
  12276. try {
  12277. return $downloader->update($initial, $target, $targetDir);
  12278. } catch (\RuntimeException $e) {
  12279. if (!$this->io->isInteractive()) {
  12280. throw $e;
  12281. }
  12282. $this->io->writeError('<error> Update failed ('.$e->getMessage().')</error>');
  12283. if (!$this->io->askConfirmation(' Would you like to try reinstalling the package instead [<comment>yes</comment>]? ')) {
  12284. throw $e;
  12285. }
  12286. }
  12287. }
  12288. $promise = $initialDownloader->remove($initial, $targetDir);
  12289. if ($promise) {
  12290. $self = $this;
  12291. return $promise->then(function ($res) use ($self, $target, $targetDir) {
  12292. return $self->install($target, $targetDir);
  12293. });
  12294. }
  12295. return $this->install($target, $targetDir);
  12296. }
  12297. public function remove(PackageInterface $package, $targetDir)
  12298. {
  12299. $targetDir = $this->normalizeTargetDir($targetDir);
  12300. $downloader = $this->getDownloaderForPackage($package);
  12301. if ($downloader) {
  12302. return $downloader->remove($package, $targetDir);
  12303. }
  12304. }
  12305. public function cleanup($type, PackageInterface $package, $targetDir, PackageInterface $prevPackage = null)
  12306. {
  12307. $targetDir = $this->normalizeTargetDir($targetDir);
  12308. $downloader = $this->getDownloaderForPackage($package);
  12309. if ($downloader) {
  12310. return $downloader->cleanup($type, $package, $targetDir, $prevPackage);
  12311. }
  12312. }
  12313. protected function resolvePackageInstallPreference(PackageInterface $package)
  12314. {
  12315. foreach ($this->packagePreferences as $pattern => $preference) {
  12316. $pattern = '{^'.str_replace('\\*', '.*', preg_quote($pattern)).'$}i';
  12317. if (preg_match($pattern, $package->getName())) {
  12318. if ('dist' === $preference || (!$package->isDev() && 'auto' === $preference)) {
  12319. return 'dist';
  12320. }
  12321. return 'source';
  12322. }
  12323. }
  12324. return $package->isDev() ? 'source' : 'dist';
  12325. }
  12326. private function getAvailableSources(PackageInterface $package, PackageInterface $prevPackage = null)
  12327. {
  12328. $sourceType = $package->getSourceType();
  12329. $distType = $package->getDistType();
  12330. $sources = array();
  12331. if ($sourceType) {
  12332. $sources[] = 'source';
  12333. }
  12334. if ($distType) {
  12335. $sources[] = 'dist';
  12336. }
  12337. if (empty($sources)) {
  12338. throw new \InvalidArgumentException('Package '.$package.' must have a source or dist specified');
  12339. }
  12340. if (
  12341. $prevPackage
  12342. && in_array($prevPackage->getInstallationSource(), $sources, true)
  12343. && !(!$prevPackage->isDev() && $prevPackage->getInstallationSource() === 'dist' && $package->isDev())
  12344. ) {
  12345. $prevSource = $prevPackage->getInstallationSource();
  12346. usort($sources, function ($a, $b) use ($prevSource) {
  12347. return $a === $prevSource ? -1 : 1;
  12348. });
  12349. return $sources;
  12350. }
  12351. if (!$this->preferSource && ($this->preferDist || 'dist' === $this->resolvePackageInstallPreference($package))) {
  12352. $sources = array_reverse($sources);
  12353. }
  12354. return $sources;
  12355. }
  12356. private function normalizeTargetDir($dir)
  12357. {
  12358. if ($dir === '\\' || $dir === '/') {
  12359. return $dir;
  12360. }
  12361. return rtrim($dir, '\\/');
  12362. }
  12363. }
  12364. <?php
  12365. namespace Composer\Downloader;
  12366. use Composer\Package\PackageInterface;
  12367. use React\Promise\PromiseInterface;
  12368. interface DownloaderInterface
  12369. {
  12370. public function getInstallationSource();
  12371. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12372. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12373. public function install(PackageInterface $package, $path);
  12374. public function update(PackageInterface $initial, PackageInterface $target, $path);
  12375. public function remove(PackageInterface $package, $path);
  12376. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null);
  12377. }
  12378. <?php
  12379. namespace Composer\Downloader;
  12380. use Composer\Package\PackageInterface;
  12381. interface DvcsDownloaderInterface
  12382. {
  12383. public function getUnpushedChanges(PackageInterface $package, $path);
  12384. }
  12385. <?php
  12386. namespace Composer\Downloader;
  12387. use Composer\Config;
  12388. use Composer\Cache;
  12389. use Composer\IO\IOInterface;
  12390. use Composer\IO\NullIO;
  12391. use Composer\Package\Comparer\Comparer;
  12392. use Composer\DependencyResolver\Operation\UpdateOperation;
  12393. use Composer\DependencyResolver\Operation\InstallOperation;
  12394. use Composer\DependencyResolver\Operation\UninstallOperation;
  12395. use Composer\Package\PackageInterface;
  12396. use Composer\Plugin\PluginEvents;
  12397. use Composer\Plugin\PostFileDownloadEvent;
  12398. use Composer\Plugin\PreFileDownloadEvent;
  12399. use Composer\EventDispatcher\EventDispatcher;
  12400. use Composer\Util\Filesystem;
  12401. use Composer\Util\HttpDownloader;
  12402. use Composer\Util\Url as UrlUtil;
  12403. use Composer\Util\ProcessExecutor;
  12404. use React\Promise\PromiseInterface;
  12405. class FileDownloader implements DownloaderInterface, ChangeReportInterface
  12406. {
  12407. protected $io;
  12408. protected $config;
  12409. protected $httpDownloader;
  12410. protected $filesystem;
  12411. protected $cache;
  12412. protected $eventDispatcher;
  12413. protected $process;
  12414. public $lastCacheWrites = array();
  12415. private $additionalCleanupPaths = array();
  12416. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, Cache $cache = null, Filesystem $filesystem = null, ProcessExecutor $process = null)
  12417. {
  12418. $this->io = $io;
  12419. $this->config = $config;
  12420. $this->eventDispatcher = $eventDispatcher;
  12421. $this->httpDownloader = $httpDownloader;
  12422. $this->cache = $cache;
  12423. $this->process = $process ?: new ProcessExecutor($io);
  12424. $this->filesystem = $filesystem ?: new Filesystem($this->process);
  12425. if ($this->cache && $this->cache->gcIsNecessary()) {
  12426. $this->cache->gc($config->get('cache-files-ttl'), $config->get('cache-files-maxsize'));
  12427. }
  12428. }
  12429. public function getInstallationSource()
  12430. {
  12431. return 'dist';
  12432. }
  12433. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  12434. {
  12435. if (!$package->getDistUrl()) {
  12436. throw new \InvalidArgumentException('The given package is missing url information');
  12437. }
  12438. $cacheKeyGenerator = function (PackageInterface $package, $key) {
  12439. $cacheKey = sha1($key);
  12440. return $package->getName().'/'.$cacheKey.'.'.$package->getDistType();
  12441. };
  12442. $retries = 3;
  12443. $urls = $package->getDistUrls();
  12444. foreach ($urls as $index => $url) {
  12445. $processedUrl = $this->processUrl($package, $url);
  12446. $urls[$index] = array(
  12447. 'base' => $url,
  12448. 'processed' => $processedUrl,
  12449. 'cacheKey' => $cacheKeyGenerator($package, $processedUrl),
  12450. );
  12451. }
  12452. $fileName = $this->getFileName($package, $path);
  12453. $this->filesystem->ensureDirectoryExists($path);
  12454. $this->filesystem->ensureDirectoryExists(dirname($fileName));
  12455. $io = $this->io;
  12456. $cache = $this->cache;
  12457. $httpDownloader = $this->httpDownloader;
  12458. $eventDispatcher = $this->eventDispatcher;
  12459. $filesystem = $this->filesystem;
  12460. $self = $this;
  12461. $accept = null;
  12462. $reject = null;
  12463. $download = function () use ($io, $output, $httpDownloader, $cache, $cacheKeyGenerator, $eventDispatcher, $package, $fileName, &$urls, &$accept, &$reject) {
  12464. $url = reset($urls);
  12465. $index = key($urls);
  12466. if ($eventDispatcher) {
  12467. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $httpDownloader, $url['processed'], 'package', $package);
  12468. $eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  12469. if ($preFileDownloadEvent->getCustomCacheKey() !== null) {
  12470. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getCustomCacheKey());
  12471. } elseif ($preFileDownloadEvent->getProcessedUrl() !== $url['processed']) {
  12472. $url['cacheKey'] = $cacheKeyGenerator($package, $preFileDownloadEvent->getProcessedUrl());
  12473. }
  12474. $url['processed'] = $preFileDownloadEvent->getProcessedUrl();
  12475. }
  12476. $urls[$index] = $url;
  12477. $checksum = $package->getDistSha1Checksum();
  12478. $cacheKey = $url['cacheKey'];
  12479. if ($cache && (!$checksum || $checksum === $cache->sha1($cacheKey)) && $cache->copyTo($cacheKey, $fileName)) {
  12480. if ($output) {
  12481. $io->writeError(" - Loading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) from cache", true, IOInterface::VERY_VERBOSE);
  12482. }
  12483. $result = \React\Promise\resolve($fileName);
  12484. } else {
  12485. if ($output) {
  12486. $io->writeError(" - Downloading <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>)");
  12487. }
  12488. $result = $httpDownloader->addCopy($url['processed'], $fileName, $package->getTransportOptions())
  12489. ->then($accept, $reject);
  12490. }
  12491. return $result->then(function ($result) use ($fileName, $checksum, $url, $package, $eventDispatcher) {
  12492. if (null === $result) {
  12493. return $fileName;
  12494. }
  12495. if (!file_exists($fileName)) {
  12496. throw new \UnexpectedValueException($url['base'].' could not be saved to '.$fileName.', make sure the'
  12497. .' directory is writable and you have internet connectivity');
  12498. }
  12499. if ($checksum && hash_file('sha1', $fileName) !== $checksum) {
  12500. throw new \UnexpectedValueException('The checksum verification of the file failed (downloaded from '.$url['base'].')');
  12501. }
  12502. if ($eventDispatcher) {
  12503. $postFileDownloadEvent = new PostFileDownloadEvent(PluginEvents::POST_FILE_DOWNLOAD, $fileName, $checksum, $url['processed'], $package);
  12504. $eventDispatcher->dispatch($postFileDownloadEvent->getName(), $postFileDownloadEvent);
  12505. }
  12506. return $fileName;
  12507. });
  12508. };
  12509. $accept = function ($response) use ($cache, $package, $fileName, $self, &$urls) {
  12510. $url = reset($urls);
  12511. $cacheKey = $url['cacheKey'];
  12512. if ($cache && !$cache->isReadOnly()) {
  12513. $self->lastCacheWrites[$package->getName()] = $cacheKey;
  12514. $cache->copyFrom($cacheKey, $fileName);
  12515. }
  12516. $response->collect();
  12517. return $fileName;
  12518. };
  12519. $reject = function ($e) use ($io, &$urls, $download, $fileName, $package, &$retries, $filesystem, $self) {
  12520. if (file_exists($fileName)) {
  12521. $filesystem->unlink($fileName);
  12522. }
  12523. $self->clearLastCacheWrite($package);
  12524. if ($e instanceof TransportException) {
  12525. if ((0 !== $e->getCode() && !in_array($e->getCode(), array(500, 502, 503, 504))) || !$retries) {
  12526. $retries = 0;
  12527. }
  12528. }
  12529. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  12530. $retries = 0;
  12531. $urls = array();
  12532. }
  12533. if ($retries) {
  12534. usleep(500000);
  12535. $retries--;
  12536. return $download();
  12537. }
  12538. array_shift($urls);
  12539. if ($urls) {
  12540. if ($io->isDebug()) {
  12541. $io->writeError(' Failed downloading '.$package->getName().': ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
  12542. $io->writeError(' Trying the next URL for '.$package->getName());
  12543. } else {
  12544. $io->writeError(' Failed downloading '.$package->getName().', trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
  12545. }
  12546. $retries = 3;
  12547. usleep(100000);
  12548. return $download();
  12549. }
  12550. throw $e;
  12551. };
  12552. return $download();
  12553. }
  12554. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12555. {
  12556. }
  12557. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  12558. {
  12559. $fileName = $this->getFileName($package, $path);
  12560. if (file_exists($fileName)) {
  12561. $this->filesystem->unlink($fileName);
  12562. }
  12563. $dirsToCleanUp = array(
  12564. $this->config->get('vendor-dir').'/composer/',
  12565. $this->config->get('vendor-dir'),
  12566. $path,
  12567. );
  12568. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  12569. foreach ($this->additionalCleanupPaths[$package->getName()] as $path) {
  12570. $this->filesystem->remove($path);
  12571. }
  12572. }
  12573. foreach ($dirsToCleanUp as $dir) {
  12574. if (is_dir($dir) && $this->filesystem->isDirEmpty($dir) && realpath($dir) !== getcwd()) {
  12575. $this->filesystem->removeDirectory($dir);
  12576. }
  12577. }
  12578. }
  12579. public function install(PackageInterface $package, $path, $output = true)
  12580. {
  12581. if ($output) {
  12582. $this->io->writeError(" - " . InstallOperation::format($package));
  12583. }
  12584. $this->filesystem->emptyDirectory($path);
  12585. $this->filesystem->ensureDirectoryExists($path);
  12586. $this->filesystem->rename($this->getFileName($package, $path), $path . '/' . pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_BASENAME));
  12587. }
  12588. public function clearLastCacheWrite(PackageInterface $package)
  12589. {
  12590. if ($this->cache && isset($this->lastCacheWrites[$package->getName()])) {
  12591. $this->cache->remove($this->lastCacheWrites[$package->getName()]);
  12592. unset($this->lastCacheWrites[$package->getName()]);
  12593. }
  12594. }
  12595. public function addCleanupPath(PackageInterface $package, $path)
  12596. {
  12597. $this->additionalCleanupPaths[$package->getName()][] = $path;
  12598. }
  12599. public function removeCleanupPath(PackageInterface $package, $path)
  12600. {
  12601. if (isset($this->additionalCleanupPaths[$package->getName()])) {
  12602. $idx = array_search($path, $this->additionalCleanupPaths[$package->getName()]);
  12603. if (false !== $idx) {
  12604. unset($this->additionalCleanupPaths[$package->getName()][$idx]);
  12605. }
  12606. }
  12607. }
  12608. public function update(PackageInterface $initial, PackageInterface $target, $path)
  12609. {
  12610. $this->io->writeError(" - " . UpdateOperation::format($initial, $target) . ": ", false);
  12611. $promise = $this->remove($initial, $path, false);
  12612. if ($promise === null || !$promise instanceof PromiseInterface) {
  12613. $promise = \React\Promise\resolve();
  12614. }
  12615. $self = $this;
  12616. $io = $this->io;
  12617. return $promise->then(function () use ($self, $target, $path, $io) {
  12618. $promise = $self->install($target, $path, false);
  12619. $io->writeError('');
  12620. return $promise;
  12621. });
  12622. }
  12623. public function remove(PackageInterface $package, $path, $output = true)
  12624. {
  12625. if ($output) {
  12626. $this->io->writeError(" - " . UninstallOperation::format($package));
  12627. }
  12628. if (!$this->filesystem->removeDirectory($path)) {
  12629. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  12630. }
  12631. }
  12632. protected function getFileName(PackageInterface $package, $path)
  12633. {
  12634. 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), '.');
  12635. }
  12636. protected function processUrl(PackageInterface $package, $url)
  12637. {
  12638. if (!extension_loaded('openssl') && 0 === strpos($url, 'https:')) {
  12639. throw new \RuntimeException('You must enable the openssl extension to download files via https');
  12640. }
  12641. if ($package->getDistReference()) {
  12642. $url = UrlUtil::updateDistReference($this->config, $url, $package->getDistReference());
  12643. }
  12644. return $url;
  12645. }
  12646. public function getLocalChanges(PackageInterface $package, $targetDir)
  12647. {
  12648. $prevIO = $this->io;
  12649. $this->io = new NullIO;
  12650. $this->io->loadConfiguration($this->config);
  12651. $e = null;
  12652. $output = '';
  12653. $targetDir = Filesystem::trimTrailingSlash($targetDir);
  12654. try {
  12655. if (is_dir($targetDir.'_compare')) {
  12656. $this->filesystem->removeDirectory($targetDir.'_compare');
  12657. }
  12658. $this->download($package, $targetDir.'_compare', null, false);
  12659. $this->httpDownloader->wait();
  12660. $this->install($package, $targetDir.'_compare', false);
  12661. $this->process->wait();
  12662. $comparer = new Comparer();
  12663. $comparer->setSource($targetDir.'_compare');
  12664. $comparer->setUpdate($targetDir);
  12665. $comparer->doCompare();
  12666. $output = $comparer->getChanged(true, true);
  12667. $this->filesystem->removeDirectory($targetDir.'_compare');
  12668. } catch (\Exception $e) {
  12669. }
  12670. $this->io = $prevIO;
  12671. if ($e) {
  12672. throw $e;
  12673. }
  12674. return trim($output);
  12675. }
  12676. }
  12677. <?php
  12678. namespace Composer\Downloader;
  12679. class FilesystemException extends \Exception
  12680. {
  12681. public function __construct($message = '', $code = 0, \Exception $previous = null)
  12682. {
  12683. parent::__construct("Filesystem exception: \n".$message, $code, $previous);
  12684. }
  12685. }
  12686. <?php
  12687. namespace Composer\Downloader;
  12688. use Composer\Package\PackageInterface;
  12689. use Composer\Util\ProcessExecutor;
  12690. class FossilDownloader extends VcsDownloader
  12691. {
  12692. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  12693. {
  12694. }
  12695. protected function doInstall(PackageInterface $package, $path, $url)
  12696. {
  12697. $this->config->prohibitUrlByConfig($url, $this->io);
  12698. $url = ProcessExecutor::escape($url);
  12699. $ref = ProcessExecutor::escape($package->getSourceReference());
  12700. $repoFile = $path . '.fossil';
  12701. $this->io->writeError("Cloning ".$package->getSourceReference());
  12702. $command = sprintf('fossil clone %s %s', $url, ProcessExecutor::escape($repoFile));
  12703. if (0 !== $this->process->execute($command, $ignoredOutput)) {
  12704. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12705. }
  12706. $command = sprintf('fossil open %s --nested', ProcessExecutor::escape($repoFile));
  12707. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12708. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12709. }
  12710. $command = sprintf('fossil update %s', $ref);
  12711. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12712. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12713. }
  12714. }
  12715. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  12716. {
  12717. $this->config->prohibitUrlByConfig($url, $this->io);
  12718. $ref = ProcessExecutor::escape($target->getSourceReference());
  12719. $this->io->writeError(" Updating to ".$target->getSourceReference());
  12720. if (!$this->hasMetadataRepository($path)) {
  12721. throw new \RuntimeException('The .fslckout file is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  12722. }
  12723. $command = sprintf('fossil pull && fossil up %s', $ref);
  12724. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  12725. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12726. }
  12727. }
  12728. public function getLocalChanges(PackageInterface $package, $path)
  12729. {
  12730. if (!$this->hasMetadataRepository($path)) {
  12731. return null;
  12732. }
  12733. $this->process->execute('fossil changes', $output, realpath($path));
  12734. return trim($output) ?: null;
  12735. }
  12736. protected function getCommitLogs($fromReference, $toReference, $path)
  12737. {
  12738. $command = sprintf('fossil timeline -t ci -W 0 -n 0 before %s', ProcessExecutor::escape($toReference));
  12739. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  12740. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12741. }
  12742. $log = '';
  12743. $match = '/\d\d:\d\d:\d\d\s+\[' . $toReference . '\]/';
  12744. foreach ($this->process->splitLines($output) as $line) {
  12745. if (preg_match($match, $line)) {
  12746. break;
  12747. }
  12748. $log .= $line;
  12749. }
  12750. return $log;
  12751. }
  12752. protected function hasMetadataRepository($path)
  12753. {
  12754. return is_file($path . '/.fslckout') || is_file($path . '/_FOSSIL_');
  12755. }
  12756. }
  12757. <?php
  12758. namespace Composer\Downloader;
  12759. use Composer\Config;
  12760. use Composer\IO\IOInterface;
  12761. use Composer\Package\PackageInterface;
  12762. use Composer\Util\Filesystem;
  12763. use Composer\Util\Git as GitUtil;
  12764. use Composer\Util\Url;
  12765. use Composer\Util\Platform;
  12766. use Composer\Util\ProcessExecutor;
  12767. use Composer\Cache;
  12768. class GitDownloader extends VcsDownloader implements DvcsDownloaderInterface
  12769. {
  12770. private $hasStashedChanges = array();
  12771. private $hasDiscardedChanges = array();
  12772. private $gitUtil;
  12773. private $cachedPackages = array();
  12774. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  12775. {
  12776. parent::__construct($io, $config, $process, $fs);
  12777. $this->gitUtil = new GitUtil($this->io, $this->config, $this->process, $this->filesystem);
  12778. }
  12779. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  12780. {
  12781. GitUtil::cleanEnv();
  12782. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12783. $gitVersion = GitUtil::getVersion($this->process);
  12784. if ($gitVersion && version_compare($gitVersion, '2.3.0-rc0', '>=') && Cache::isUsable($cachePath)) {
  12785. $this->io->writeError(" - Syncing <info>" . $package->getName() . "</info> (<comment>" . $package->getFullPrettyVersion() . "</comment>) into cache");
  12786. $this->io->writeError(sprintf(' Cloning to cache at %s', ProcessExecutor::escape($cachePath)), true, IOInterface::DEBUG);
  12787. $ref = $package->getSourceReference();
  12788. if ($this->gitUtil->fetchRefOrSyncMirror($url, $cachePath, $ref) && is_dir($cachePath)) {
  12789. $this->cachedPackages[$package->getId()][$ref] = true;
  12790. }
  12791. }
  12792. }
  12793. protected function doInstall(PackageInterface $package, $path, $url)
  12794. {
  12795. GitUtil::cleanEnv();
  12796. $path = $this->normalizePath($path);
  12797. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12798. $ref = $package->getSourceReference();
  12799. $flag = Platform::isWindows() ? '/D ' : '';
  12800. if (!empty($this->cachedPackages[$package->getId()][$ref])) {
  12801. $msg = "Cloning ".$this->getShortHash($ref).' from cache';
  12802. $command =
  12803. 'git clone --no-checkout %cachePath% %path% --dissociate --reference %cachePath% '
  12804. . '&& cd '.$flag.'%path% '
  12805. . '&& git remote set-url origin %sanitizedUrl% && git remote add composer %sanitizedUrl%';
  12806. } else {
  12807. $msg = "Cloning ".$this->getShortHash($ref);
  12808. $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%';
  12809. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  12810. throw new \RuntimeException('The required git reference for '.$package->getName().' is not in cache and network is disabled, aborting');
  12811. }
  12812. }
  12813. $this->io->writeError($msg);
  12814. $commandCallable = function ($url) use ($path, $command, $cachePath) {
  12815. return str_replace(
  12816. array('%url%', '%path%', '%cachePath%', '%sanitizedUrl%'),
  12817. array(
  12818. ProcessExecutor::escape($url),
  12819. ProcessExecutor::escape($path),
  12820. ProcessExecutor::escape($cachePath),
  12821. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  12822. ),
  12823. $command
  12824. );
  12825. };
  12826. $this->gitUtil->runCommand($commandCallable, $url, $path, true);
  12827. if ($url !== $package->getSourceUrl()) {
  12828. $this->updateOriginUrl($path, $package->getSourceUrl());
  12829. } else {
  12830. $this->setPushUrl($path, $url);
  12831. }
  12832. if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) {
  12833. if ($package->getDistReference() === $package->getSourceReference()) {
  12834. $package->setDistReference($newRef);
  12835. }
  12836. $package->setSourceReference($newRef);
  12837. }
  12838. }
  12839. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  12840. {
  12841. GitUtil::cleanEnv();
  12842. $path = $this->normalizePath($path);
  12843. if (!$this->hasMetadataRepository($path)) {
  12844. throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  12845. }
  12846. $cachePath = $this->config->get('cache-vcs-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $url).'/';
  12847. $ref = $target->getSourceReference();
  12848. if (!empty($this->cachedPackages[$target->getId()][$ref])) {
  12849. $msg = "Checking out ".$this->getShortHash($ref).' from cache';
  12850. $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%';
  12851. } else {
  12852. $msg = "Checking out ".$this->getShortHash($ref);
  12853. $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%';
  12854. if (getenv('COMPOSER_DISABLE_NETWORK')) {
  12855. throw new \RuntimeException('The required git reference for '.$target->getName().' is not in cache and network is disabled, aborting');
  12856. }
  12857. }
  12858. $this->io->writeError($msg);
  12859. $commandCallable = function ($url) use ($ref, $command, $cachePath) {
  12860. return str_replace(
  12861. array('%url%', '%ref%', '%cachePath%', '%sanitizedUrl%'),
  12862. array(
  12863. ProcessExecutor::escape($url),
  12864. ProcessExecutor::escape($ref.'^{commit}'),
  12865. ProcessExecutor::escape($cachePath),
  12866. ProcessExecutor::escape(preg_replace('{://([^@]+?):(.+?)@}', '://', $url)),
  12867. ),
  12868. $command
  12869. );
  12870. };
  12871. $this->gitUtil->runCommand($commandCallable, $url, $path);
  12872. if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) {
  12873. if ($target->getDistReference() === $target->getSourceReference()) {
  12874. $target->setDistReference($newRef);
  12875. }
  12876. $target->setSourceReference($newRef);
  12877. }
  12878. $updateOriginUrl = false;
  12879. if (
  12880. 0 === $this->process->execute('git remote -v', $output, $path)
  12881. && preg_match('{^origin\s+(?P<url>\S+)}m', $output, $originMatch)
  12882. && preg_match('{^composer\s+(?P<url>\S+)}m', $output, $composerMatch)
  12883. ) {
  12884. if ($originMatch['url'] === $composerMatch['url'] && $composerMatch['url'] !== $target->getSourceUrl()) {
  12885. $updateOriginUrl = true;
  12886. }
  12887. }
  12888. if ($updateOriginUrl) {
  12889. $this->updateOriginUrl($path, $target->getSourceUrl());
  12890. }
  12891. }
  12892. public function getLocalChanges(PackageInterface $package, $path)
  12893. {
  12894. GitUtil::cleanEnv();
  12895. if (!$this->hasMetadataRepository($path)) {
  12896. return;
  12897. }
  12898. $command = 'git status --porcelain --untracked-files=no';
  12899. if (0 !== $this->process->execute($command, $output, $path)) {
  12900. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12901. }
  12902. return trim($output) ?: null;
  12903. }
  12904. public function getUnpushedChanges(PackageInterface $package, $path)
  12905. {
  12906. GitUtil::cleanEnv();
  12907. $path = $this->normalizePath($path);
  12908. if (!$this->hasMetadataRepository($path)) {
  12909. return;
  12910. }
  12911. $command = 'git show-ref --head -d';
  12912. if (0 !== $this->process->execute($command, $output, $path)) {
  12913. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12914. }
  12915. $refs = trim($output);
  12916. if (!preg_match('{^([a-f0-9]+) HEAD$}mi', $refs, $match)) {
  12917. return;
  12918. }
  12919. $headRef = $match[1];
  12920. if (!preg_match_all('{^'.$headRef.' refs/heads/(.+)$}mi', $refs, $matches)) {
  12921. return;
  12922. }
  12923. $candidateBranches = $matches[1];
  12924. $branch = $candidateBranches[0];
  12925. $unpushedChanges = null;
  12926. $branchNotFoundError = false;
  12927. for ($i = 0; $i <= 1; $i++) {
  12928. $remoteBranches = array();
  12929. foreach ($candidateBranches as $candidate) {
  12930. if (preg_match_all('{^[a-f0-9]+ refs/remotes/((?:[^/]+)/'.preg_quote($candidate).')$}mi', $refs, $matches)) {
  12931. foreach ($matches[1] as $match) {
  12932. $branch = $candidate;
  12933. $remoteBranches[] = $match;
  12934. }
  12935. break;
  12936. }
  12937. }
  12938. if (!$remoteBranches) {
  12939. $unpushedChanges = 'Branch ' . $branch . ' could not be found on any remote and appears to be unpushed';
  12940. $branchNotFoundError = true;
  12941. } else {
  12942. if ($branchNotFoundError) {
  12943. $unpushedChanges = null;
  12944. }
  12945. foreach ($remoteBranches as $remoteBranch) {
  12946. $command = sprintf('git diff --name-status %s...%s --', $remoteBranch, $branch);
  12947. if (0 !== $this->process->execute($command, $output, $path)) {
  12948. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12949. }
  12950. $output = trim($output);
  12951. if ($unpushedChanges === null || strlen($output) < strlen($unpushedChanges)) {
  12952. $unpushedChanges = $output;
  12953. }
  12954. }
  12955. }
  12956. if ($unpushedChanges && $i === 0) {
  12957. $this->process->execute('git fetch --all', $output, $path);
  12958. $command = 'git show-ref --head -d';
  12959. if (0 !== $this->process->execute($command, $output, $path)) {
  12960. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  12961. }
  12962. $refs = trim($output);
  12963. }
  12964. if (!$unpushedChanges) {
  12965. break;
  12966. }
  12967. }
  12968. return $unpushedChanges;
  12969. }
  12970. protected function cleanChanges(PackageInterface $package, $path, $update)
  12971. {
  12972. GitUtil::cleanEnv();
  12973. $path = $this->normalizePath($path);
  12974. $unpushed = $this->getUnpushedChanges($package, $path);
  12975. if ($unpushed && ($this->io->isInteractive() || $this->config->get('discard-changes') !== true)) {
  12976. throw new \RuntimeException('Source directory ' . $path . ' has unpushed changes on the current branch: '."\n".$unpushed);
  12977. }
  12978. if (!$changes = $this->getLocalChanges($package, $path)) {
  12979. return;
  12980. }
  12981. if (!$this->io->isInteractive()) {
  12982. $discardChanges = $this->config->get('discard-changes');
  12983. if (true === $discardChanges) {
  12984. return $this->discardChanges($path);
  12985. }
  12986. if ('stash' === $discardChanges) {
  12987. if (!$update) {
  12988. return parent::cleanChanges($package, $path, $update);
  12989. }
  12990. return $this->stashChanges($path);
  12991. }
  12992. return parent::cleanChanges($package, $path, $update);
  12993. }
  12994. $changes = array_map(function ($elem) {
  12995. return ' '.$elem;
  12996. }, preg_split('{\s*\r?\n\s*}', $changes));
  12997. $this->io->writeError(' <error>'.$package->getPrettyName().' has modified files:</error>');
  12998. $this->io->writeError(array_slice($changes, 0, 10));
  12999. if (count($changes) > 10) {
  13000. $this->io->writeError(' <info>' . (count($changes) - 10) . ' more files modified, choose "v" to view the full list</info>');
  13001. }
  13002. while (true) {
  13003. switch ($this->io->ask(' <info>Discard changes [y,n,v,d,'.($update ? 's,' : '').'?]?</info> ', '?')) {
  13004. case 'y':
  13005. $this->discardChanges($path);
  13006. break 2;
  13007. case 's':
  13008. if (!$update) {
  13009. goto help;
  13010. }
  13011. $this->stashChanges($path);
  13012. break 2;
  13013. case 'n':
  13014. throw new \RuntimeException('Update aborted');
  13015. case 'v':
  13016. $this->io->writeError($changes);
  13017. break;
  13018. case 'd':
  13019. $this->viewDiff($path);
  13020. break;
  13021. case '?':
  13022. default:
  13023. help:
  13024. $this->io->writeError(array(
  13025. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  13026. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  13027. ' v - view modified files',
  13028. ' d - view local modifications (diff)',
  13029. ));
  13030. if ($update) {
  13031. $this->io->writeError(' s - stash changes and try to reapply them after the update');
  13032. }
  13033. $this->io->writeError(' ? - print help');
  13034. break;
  13035. }
  13036. }
  13037. }
  13038. protected function reapplyChanges($path)
  13039. {
  13040. $path = $this->normalizePath($path);
  13041. if (!empty($this->hasStashedChanges[$path])) {
  13042. unset($this->hasStashedChanges[$path]);
  13043. $this->io->writeError(' <info>Re-applying stashed changes</info>');
  13044. if (0 !== $this->process->execute('git stash pop', $output, $path)) {
  13045. throw new \RuntimeException("Failed to apply stashed changes:\n\n".$this->process->getErrorOutput());
  13046. }
  13047. }
  13048. unset($this->hasDiscardedChanges[$path]);
  13049. }
  13050. protected function updateToCommit($path, $reference, $branch, $date)
  13051. {
  13052. $force = !empty($this->hasDiscardedChanges[$path]) || !empty($this->hasStashedChanges[$path]) ? '-f ' : '';
  13053. $template = 'git checkout '.$force.'%s -- && git reset --hard %1$s --';
  13054. $branch = preg_replace('{(?:^dev-|(?:\.x)?-dev$)}i', '', $branch);
  13055. $branches = null;
  13056. if (0 === $this->process->execute('git branch -r', $output, $path)) {
  13057. $branches = $output;
  13058. }
  13059. $gitRef = $reference;
  13060. if (!preg_match('{^[a-f0-9]{40}$}', $reference)
  13061. && $branches
  13062. && preg_match('{^\s+composer/'.preg_quote($reference).'$}m', $branches)
  13063. ) {
  13064. $command = sprintf('git checkout '.$force.'-B %s %s -- && git reset --hard %2$s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$reference));
  13065. if (0 === $this->process->execute($command, $output, $path)) {
  13066. return null;
  13067. }
  13068. }
  13069. if (preg_match('{^[a-f0-9]{40}$}', $reference)) {
  13070. if (!preg_match('{^\s+composer/'.preg_quote($branch).'$}m', $branches) && preg_match('{^\s+composer/v'.preg_quote($branch).'$}m', $branches)) {
  13071. $branch = 'v' . $branch;
  13072. }
  13073. $command = sprintf('git checkout %s --', ProcessExecutor::escape($branch));
  13074. $fallbackCommand = sprintf('git checkout '.$force.'-B %s %s --', ProcessExecutor::escape($branch), ProcessExecutor::escape('composer/'.$branch));
  13075. $resetCommand = sprintf('git reset --hard %s --', ProcessExecutor::escape($reference));
  13076. if (0 === $this->process->execute("($command || $fallbackCommand) && $resetCommand", $output, $path)) {
  13077. return null;
  13078. }
  13079. }
  13080. $command = sprintf($template, ProcessExecutor::escape($gitRef));
  13081. if (0 === $this->process->execute($command, $output, $path)) {
  13082. return null;
  13083. }
  13084. if (false !== strpos($this->process->getErrorOutput(), $reference)) {
  13085. $this->io->writeError(' <warning>'.$reference.' is gone (history was rewritten?)</warning>');
  13086. }
  13087. throw new \RuntimeException(Url::sanitize('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()));
  13088. }
  13089. protected function updateOriginUrl($path, $url)
  13090. {
  13091. $this->process->execute(sprintf('git remote set-url origin %s', ProcessExecutor::escape($url)), $output, $path);
  13092. $this->setPushUrl($path, $url);
  13093. }
  13094. protected function setPushUrl($path, $url)
  13095. {
  13096. if (preg_match('{^(?:https?|git)://'.GitUtil::getGitHubDomainsRegex($this->config).'/([^/]+)/([^/]+?)(?:\.git)?$}', $url, $match)) {
  13097. $protocols = $this->config->get('github-protocols');
  13098. $pushUrl = 'git@'.$match[1].':'.$match[2].'/'.$match[3].'.git';
  13099. if (!in_array('ssh', $protocols, true)) {
  13100. $pushUrl = 'https://' . $match[1] . '/'.$match[2].'/'.$match[3].'.git';
  13101. }
  13102. $cmd = sprintf('git remote set-url --push origin %s', ProcessExecutor::escape($pushUrl));
  13103. $this->process->execute($cmd, $ignoredOutput, $path);
  13104. }
  13105. }
  13106. protected function getCommitLogs($fromReference, $toReference, $path)
  13107. {
  13108. $path = $this->normalizePath($path);
  13109. $command = sprintf('git log %s..%s --pretty=format:"%%h - %%an: %%s"'.GitUtil::getNoShowSignatureFlag($this->process), ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  13110. if (0 !== $this->process->execute($command, $output, $path)) {
  13111. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13112. }
  13113. return $output;
  13114. }
  13115. protected function discardChanges($path)
  13116. {
  13117. $path = $this->normalizePath($path);
  13118. if (0 !== $this->process->execute('git clean -df && git reset --hard', $output, $path)) {
  13119. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  13120. }
  13121. $this->hasDiscardedChanges[$path] = true;
  13122. }
  13123. protected function stashChanges($path)
  13124. {
  13125. $path = $this->normalizePath($path);
  13126. if (0 !== $this->process->execute('git stash --include-untracked', $output, $path)) {
  13127. throw new \RuntimeException("Could not stash changes\n\n:".$this->process->getErrorOutput());
  13128. }
  13129. $this->hasStashedChanges[$path] = true;
  13130. }
  13131. protected function viewDiff($path)
  13132. {
  13133. $path = $this->normalizePath($path);
  13134. if (0 !== $this->process->execute('git diff HEAD', $output, $path)) {
  13135. throw new \RuntimeException("Could not view diff\n\n:".$this->process->getErrorOutput());
  13136. }
  13137. $this->io->writeError($output);
  13138. }
  13139. protected function normalizePath($path)
  13140. {
  13141. if (Platform::isWindows() && strlen($path) > 0) {
  13142. $basePath = $path;
  13143. $removed = array();
  13144. while (!is_dir($basePath) && $basePath !== '\\') {
  13145. array_unshift($removed, basename($basePath));
  13146. $basePath = dirname($basePath);
  13147. }
  13148. if ($basePath === '\\') {
  13149. return $path;
  13150. }
  13151. $path = rtrim(realpath($basePath) . '/' . implode('/', $removed), '/');
  13152. }
  13153. return $path;
  13154. }
  13155. protected function hasMetadataRepository($path)
  13156. {
  13157. $path = $this->normalizePath($path);
  13158. return is_dir($path.'/.git');
  13159. }
  13160. protected function getShortHash($reference)
  13161. {
  13162. if (!$this->io->isVerbose() && preg_match('{^[0-9a-f]{40}$}', $reference)) {
  13163. return substr($reference, 0, 10);
  13164. }
  13165. return $reference;
  13166. }
  13167. }
  13168. <?php
  13169. namespace Composer\Downloader;
  13170. use Composer\Package\PackageInterface;
  13171. use Composer\Util\Platform;
  13172. use Composer\Util\ProcessExecutor;
  13173. class GzipDownloader extends ArchiveDownloader
  13174. {
  13175. protected function extract(PackageInterface $package, $file, $path)
  13176. {
  13177. $filename = pathinfo(parse_url($package->getDistUrl(), PHP_URL_PATH), PATHINFO_FILENAME);
  13178. $targetFilepath = $path . DIRECTORY_SEPARATOR . $filename;
  13179. if (!Platform::isWindows()) {
  13180. $command = 'gzip -cd ' . ProcessExecutor::escape($file) . ' > ' . ProcessExecutor::escape($targetFilepath);
  13181. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13182. return;
  13183. }
  13184. if (extension_loaded('zlib')) {
  13185. $this->extractUsingExt($file, $targetFilepath);
  13186. return;
  13187. }
  13188. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13189. throw new \RuntimeException($processError);
  13190. }
  13191. $this->extractUsingExt($file, $targetFilepath);
  13192. }
  13193. private function extractUsingExt($file, $targetFilepath)
  13194. {
  13195. $archiveFile = gzopen($file, 'rb');
  13196. $targetFile = fopen($targetFilepath, 'wb');
  13197. while ($string = gzread($archiveFile, 4096)) {
  13198. fwrite($targetFile, $string, Platform::strlen($string));
  13199. }
  13200. gzclose($archiveFile);
  13201. fclose($targetFile);
  13202. }
  13203. }
  13204. <?php
  13205. namespace Composer\Downloader;
  13206. use Composer\Package\PackageInterface;
  13207. use Composer\Util\ProcessExecutor;
  13208. use Composer\Util\Hg as HgUtils;
  13209. class HgDownloader extends VcsDownloader
  13210. {
  13211. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13212. {
  13213. }
  13214. protected function doInstall(PackageInterface $package, $path, $url)
  13215. {
  13216. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  13217. $cloneCommand = function ($url) use ($path) {
  13218. return sprintf('hg clone %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($path));
  13219. };
  13220. $hgUtils->runCommand($cloneCommand, $url, $path);
  13221. $ref = ProcessExecutor::escape($package->getSourceReference());
  13222. $command = sprintf('hg up %s', $ref);
  13223. if (0 !== $this->process->execute($command, $ignoredOutput, realpath($path))) {
  13224. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13225. }
  13226. }
  13227. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13228. {
  13229. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  13230. $ref = $target->getSourceReference();
  13231. $this->io->writeError(" Updating to ".$target->getSourceReference());
  13232. if (!$this->hasMetadataRepository($path)) {
  13233. throw new \RuntimeException('The .hg directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13234. }
  13235. $command = function ($url) use ($ref) {
  13236. return sprintf('hg pull %s && hg up %s', ProcessExecutor::escape($url), ProcessExecutor::escape($ref));
  13237. };
  13238. $hgUtils->runCommand($command, $url, $path);
  13239. }
  13240. public function getLocalChanges(PackageInterface $package, $path)
  13241. {
  13242. if (!is_dir($path.'/.hg')) {
  13243. return null;
  13244. }
  13245. $this->process->execute('hg st', $output, realpath($path));
  13246. return trim($output) ?: null;
  13247. }
  13248. protected function getCommitLogs($fromReference, $toReference, $path)
  13249. {
  13250. $command = sprintf('hg log -r %s:%s --style compact', ProcessExecutor::escape($fromReference), ProcessExecutor::escape($toReference));
  13251. if (0 !== $this->process->execute($command, $output, realpath($path))) {
  13252. throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
  13253. }
  13254. return $output;
  13255. }
  13256. protected function hasMetadataRepository($path)
  13257. {
  13258. return is_dir($path . '/.hg');
  13259. }
  13260. }
  13261. <?php
  13262. namespace Composer\Downloader;
  13263. class MaxFileSizeExceededException extends TransportException
  13264. {
  13265. }
  13266. <?php
  13267. namespace Composer\Downloader;
  13268. use Composer\Package\Archiver\ArchivableFilesFinder;
  13269. use Composer\Package\Dumper\ArrayDumper;
  13270. use Composer\Package\PackageInterface;
  13271. use Composer\Package\Version\VersionGuesser;
  13272. use Composer\Package\Version\VersionParser;
  13273. use Composer\Util\Platform;
  13274. use Composer\Util\Filesystem;
  13275. use Symfony\Component\Filesystem\Exception\IOException;
  13276. use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
  13277. use Composer\DependencyResolver\Operation\InstallOperation;
  13278. use Composer\DependencyResolver\Operation\UninstallOperation;
  13279. class PathDownloader extends FileDownloader implements VcsCapableDownloaderInterface
  13280. {
  13281. const STRATEGY_SYMLINK = 10;
  13282. const STRATEGY_MIRROR = 20;
  13283. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  13284. {
  13285. $path = Filesystem::trimTrailingSlash($path);
  13286. $url = $package->getDistUrl();
  13287. $realUrl = realpath($url);
  13288. if (false === $realUrl || !file_exists($realUrl) || !is_dir($realUrl)) {
  13289. throw new \RuntimeException(sprintf(
  13290. 'Source path "%s" is not found for package %s',
  13291. $url,
  13292. $package->getName()
  13293. ));
  13294. }
  13295. if (realpath($path) === $realUrl) {
  13296. return;
  13297. }
  13298. if (strpos(realpath($path) . DIRECTORY_SEPARATOR, $realUrl . DIRECTORY_SEPARATOR) === 0) {
  13299. throw new \RuntimeException(sprintf(
  13300. 'Package %s cannot install to "%s" inside its source at "%s"',
  13301. $package->getName(),
  13302. realpath($path),
  13303. $realUrl
  13304. ));
  13305. }
  13306. }
  13307. public function install(PackageInterface $package, $path, $output = true)
  13308. {
  13309. $path = Filesystem::trimTrailingSlash($path);
  13310. $url = $package->getDistUrl();
  13311. $realUrl = realpath($url);
  13312. if (realpath($path) === $realUrl) {
  13313. if ($output) {
  13314. $this->io->writeError(" - " . InstallOperation::format($package).': Source already present');
  13315. } else {
  13316. $this->io->writeError('Source already present', false);
  13317. }
  13318. return;
  13319. }
  13320. $transportOptions = $package->getTransportOptions() + array('symlink' => null, 'relative' => true);
  13321. $currentStrategy = self::STRATEGY_SYMLINK;
  13322. $allowedStrategies = array(self::STRATEGY_SYMLINK, self::STRATEGY_MIRROR);
  13323. $mirrorPathRepos = getenv('COMPOSER_MIRROR_PATH_REPOS');
  13324. if ($mirrorPathRepos) {
  13325. $currentStrategy = self::STRATEGY_MIRROR;
  13326. }
  13327. if (true === $transportOptions['symlink']) {
  13328. $currentStrategy = self::STRATEGY_SYMLINK;
  13329. $allowedStrategies = array(self::STRATEGY_SYMLINK);
  13330. } elseif (false === $transportOptions['symlink']) {
  13331. $currentStrategy = self::STRATEGY_MIRROR;
  13332. $allowedStrategies = array(self::STRATEGY_MIRROR);
  13333. }
  13334. if (Platform::isWindows() && self::STRATEGY_SYMLINK === $currentStrategy && !$this->safeJunctions()) {
  13335. $currentStrategy = self::STRATEGY_MIRROR;
  13336. $allowedStrategies = array(self::STRATEGY_MIRROR);
  13337. }
  13338. $symfonyFilesystem = new SymfonyFilesystem();
  13339. $this->filesystem->removeDirectory($path);
  13340. if ($output) {
  13341. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  13342. }
  13343. $isFallback = false;
  13344. if (self::STRATEGY_SYMLINK == $currentStrategy) {
  13345. try {
  13346. if (Platform::isWindows()) {
  13347. $this->io->writeError(sprintf('Junctioning from %s', $url), false);
  13348. $this->filesystem->junction($realUrl, $path);
  13349. } else {
  13350. $absolutePath = $path;
  13351. if (!$this->filesystem->isAbsolutePath($absolutePath)) {
  13352. $absolutePath = getcwd() . DIRECTORY_SEPARATOR . $path;
  13353. }
  13354. $shortestPath = $this->filesystem->findShortestPath($absolutePath, $realUrl);
  13355. $path = rtrim($path, "/");
  13356. $this->io->writeError(sprintf('Symlinking from %s', $url), false);
  13357. if ($transportOptions['relative']) {
  13358. $symfonyFilesystem->symlink($shortestPath, $path);
  13359. } else {
  13360. $symfonyFilesystem->symlink($realUrl, $path);
  13361. }
  13362. }
  13363. } catch (IOException $e) {
  13364. if (in_array(self::STRATEGY_MIRROR, $allowedStrategies)) {
  13365. $this->io->writeError('');
  13366. $this->io->writeError(' <error>Symlink failed, fallback to use mirroring!</error>');
  13367. $currentStrategy = self::STRATEGY_MIRROR;
  13368. $isFallback = true;
  13369. } else {
  13370. throw new \RuntimeException(sprintf('Symlink from "%s" to "%s" failed!', $realUrl, $path));
  13371. }
  13372. }
  13373. }
  13374. if (self::STRATEGY_MIRROR == $currentStrategy) {
  13375. $realUrl = $this->filesystem->normalizePath($realUrl);
  13376. $this->io->writeError(sprintf('%sMirroring from %s', $isFallback ? ' ' : '', $url), false);
  13377. $iterator = new ArchivableFilesFinder($realUrl, array());
  13378. $symfonyFilesystem->mirror($realUrl, $path, $iterator);
  13379. }
  13380. if ($output) {
  13381. $this->io->writeError('');
  13382. }
  13383. }
  13384. public function remove(PackageInterface $package, $path, $output = true)
  13385. {
  13386. $path = Filesystem::trimTrailingSlash($path);
  13387. if (Platform::isWindows() && $this->filesystem->isJunction($path)) {
  13388. if ($output) {
  13389. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  13390. }
  13391. if (!$this->filesystem->removeJunction($path)) {
  13392. $this->io->writeError(" <warning>Could not remove junction at " . $path . " - is another process locking it?</warning>");
  13393. throw new \RuntimeException('Could not reliably remove junction for package ' . $package->getName());
  13394. }
  13395. } elseif (realpath($path) === realpath($package->getDistUrl())) {
  13396. if ($output) {
  13397. $this->io->writeError(" - " . UninstallOperation::format($package).", source is still present in $path");
  13398. }
  13399. } else {
  13400. parent::remove($package, $path, $output);
  13401. }
  13402. }
  13403. public function getVcsReference(PackageInterface $package, $path)
  13404. {
  13405. $path = Filesystem::trimTrailingSlash($path);
  13406. $parser = new VersionParser;
  13407. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  13408. $dumper = new ArrayDumper;
  13409. $packageConfig = $dumper->dump($package);
  13410. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  13411. return $packageVersion['commit'];
  13412. }
  13413. }
  13414. private function safeJunctions()
  13415. {
  13416. return function_exists('proc_open') &&
  13417. (PHP_WINDOWS_VERSION_MAJOR > 6 ||
  13418. (PHP_WINDOWS_VERSION_MAJOR === 6 && PHP_WINDOWS_VERSION_MINOR >= 1));
  13419. }
  13420. }
  13421. <?php
  13422. namespace Composer\Downloader;
  13423. use Composer\Package\PackageInterface;
  13424. use Composer\Repository\VcsRepository;
  13425. use Composer\Util\Perforce;
  13426. class PerforceDownloader extends VcsDownloader
  13427. {
  13428. protected $perforce;
  13429. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13430. {
  13431. }
  13432. public function doInstall(PackageInterface $package, $path, $url)
  13433. {
  13434. $ref = $package->getSourceReference();
  13435. $label = $this->getLabelFromSourceReference($ref);
  13436. $this->io->writeError('Cloning ' . $ref);
  13437. $this->initPerforce($package, $path, $url);
  13438. $this->perforce->setStream($ref);
  13439. $this->perforce->p4Login();
  13440. $this->perforce->writeP4ClientSpec();
  13441. $this->perforce->connectClient();
  13442. $this->perforce->syncCodeBase($label);
  13443. $this->perforce->cleanupClientSpec();
  13444. }
  13445. private function getLabelFromSourceReference($ref)
  13446. {
  13447. $pos = strpos($ref, '@');
  13448. if (false !== $pos) {
  13449. return substr($ref, $pos + 1);
  13450. }
  13451. return null;
  13452. }
  13453. public function initPerforce(PackageInterface $package, $path, $url)
  13454. {
  13455. if (!empty($this->perforce)) {
  13456. $this->perforce->initializePath($path);
  13457. return;
  13458. }
  13459. $repository = $package->getRepository();
  13460. $repoConfig = null;
  13461. if ($repository instanceof VcsRepository) {
  13462. $repoConfig = $this->getRepoConfig($repository);
  13463. }
  13464. $this->perforce = Perforce::create($repoConfig, $url, $path, $this->process, $this->io);
  13465. }
  13466. private function getRepoConfig(VcsRepository $repository)
  13467. {
  13468. return $repository->getRepoConfig();
  13469. }
  13470. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13471. {
  13472. $this->doInstall($target, $path, $url);
  13473. }
  13474. public function getLocalChanges(PackageInterface $package, $path)
  13475. {
  13476. $this->io->writeError('Perforce driver does not check for local changes before overriding');
  13477. }
  13478. protected function getCommitLogs($fromReference, $toReference, $path)
  13479. {
  13480. return $this->perforce->getCommitLogs($fromReference, $toReference);
  13481. }
  13482. public function setPerforce($perforce)
  13483. {
  13484. $this->perforce = $perforce;
  13485. }
  13486. protected function hasMetadataRepository($path)
  13487. {
  13488. return true;
  13489. }
  13490. }
  13491. <?php
  13492. namespace Composer\Downloader;
  13493. use Composer\Package\PackageInterface;
  13494. class PharDownloader extends ArchiveDownloader
  13495. {
  13496. protected function extract(PackageInterface $package, $file, $path)
  13497. {
  13498. $archive = new \Phar($file);
  13499. $archive->extractTo($path, null, true);
  13500. }
  13501. }
  13502. <?php
  13503. namespace Composer\Downloader;
  13504. use Composer\Util\IniHelper;
  13505. use Composer\Util\Platform;
  13506. use Composer\Util\ProcessExecutor;
  13507. use Composer\Package\PackageInterface;
  13508. use RarArchive;
  13509. class RarDownloader extends ArchiveDownloader
  13510. {
  13511. protected function extract(PackageInterface $package, $file, $path)
  13512. {
  13513. $processError = null;
  13514. if (!Platform::isWindows()) {
  13515. $command = 'unrar x ' . ProcessExecutor::escape($file) . ' ' . ProcessExecutor::escape($path) . ' >/dev/null && chmod -R u+w ' . ProcessExecutor::escape($path);
  13516. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13517. return;
  13518. }
  13519. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13520. }
  13521. if (!class_exists('RarArchive')) {
  13522. $iniMessage = IniHelper::getMessage();
  13523. $error = "Could not decompress the archive, enable the PHP rar extension or install unrar.\n"
  13524. . $iniMessage . "\n" . $processError;
  13525. if (!Platform::isWindows()) {
  13526. $error = "Could not decompress the archive, enable the PHP rar extension.\n" . $iniMessage;
  13527. }
  13528. throw new \RuntimeException($error);
  13529. }
  13530. $rarArchive = RarArchive::open($file);
  13531. if (false === $rarArchive) {
  13532. throw new \UnexpectedValueException('Could not open RAR archive: ' . $file);
  13533. }
  13534. $entries = $rarArchive->getEntries();
  13535. if (false === $entries) {
  13536. throw new \RuntimeException('Could not retrieve RAR archive entries');
  13537. }
  13538. foreach ($entries as $entry) {
  13539. if (false === $entry->extract($path)) {
  13540. throw new \RuntimeException('Could not extract entry');
  13541. }
  13542. }
  13543. $rarArchive->close();
  13544. }
  13545. }
  13546. <?php
  13547. namespace Composer\Downloader;
  13548. use Composer\Package\PackageInterface;
  13549. use Composer\Util\Svn as SvnUtil;
  13550. use Composer\Repository\VcsRepository;
  13551. use Composer\Util\ProcessExecutor;
  13552. class SvnDownloader extends VcsDownloader
  13553. {
  13554. protected $cacheCredentials = true;
  13555. protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null)
  13556. {
  13557. }
  13558. protected function doInstall(PackageInterface $package, $path, $url)
  13559. {
  13560. SvnUtil::cleanEnv();
  13561. $ref = $package->getSourceReference();
  13562. $repo = $package->getRepository();
  13563. if ($repo instanceof VcsRepository) {
  13564. $repoConfig = $repo->getRepoConfig();
  13565. if (array_key_exists('svn-cache-credentials', $repoConfig)) {
  13566. $this->cacheCredentials = (bool) $repoConfig['svn-cache-credentials'];
  13567. }
  13568. }
  13569. $this->io->writeError(" Checking out ".$package->getSourceReference());
  13570. $this->execute($package, $url, "svn co", sprintf("%s/%s", $url, $ref), null, $path);
  13571. }
  13572. protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url)
  13573. {
  13574. SvnUtil::cleanEnv();
  13575. $ref = $target->getSourceReference();
  13576. if (!$this->hasMetadataRepository($path)) {
  13577. throw new \RuntimeException('The .svn directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information');
  13578. }
  13579. $util = new SvnUtil($url, $this->io, $this->config, $this->process);
  13580. $flags = "";
  13581. if (version_compare($util->binaryVersion(), '1.7.0', '>=')) {
  13582. $flags .= ' --ignore-ancestry';
  13583. }
  13584. $this->io->writeError(" Checking out " . $ref);
  13585. $this->execute($target, $url, "svn switch" . $flags, sprintf("%s/%s", $url, $ref), $path);
  13586. }
  13587. public function getLocalChanges(PackageInterface $package, $path)
  13588. {
  13589. if (!$this->hasMetadataRepository($path)) {
  13590. return null;
  13591. }
  13592. $this->process->execute('svn status --ignore-externals', $output, $path);
  13593. return preg_match('{^ *[^X ] +}m', $output) ? $output : null;
  13594. }
  13595. protected function execute(PackageInterface $package, $baseUrl, $command, $url, $cwd = null, $path = null)
  13596. {
  13597. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  13598. $util->setCacheCredentials($this->cacheCredentials);
  13599. try {
  13600. return $util->execute($command, $url, $cwd, $path, $this->io->isVerbose());
  13601. } catch (\RuntimeException $e) {
  13602. throw new \RuntimeException(
  13603. $package->getPrettyName().' could not be downloaded, '.$e->getMessage()
  13604. );
  13605. }
  13606. }
  13607. protected function cleanChanges(PackageInterface $package, $path, $update)
  13608. {
  13609. if (!$changes = $this->getLocalChanges($package, $path)) {
  13610. return;
  13611. }
  13612. if (!$this->io->isInteractive()) {
  13613. if (true === $this->config->get('discard-changes')) {
  13614. return $this->discardChanges($path);
  13615. }
  13616. return parent::cleanChanges($package, $path, $update);
  13617. }
  13618. $changes = array_map(function ($elem) {
  13619. return ' '.$elem;
  13620. }, preg_split('{\s*\r?\n\s*}', $changes));
  13621. $countChanges = count($changes);
  13622. $this->io->writeError(sprintf(' <error>'.$package->getPrettyName().' has modified file%s:</error>', $countChanges === 1 ? '' : 's'));
  13623. $this->io->writeError(array_slice($changes, 0, 10));
  13624. if ($countChanges > 10) {
  13625. $remainingChanges = $countChanges - 10;
  13626. $this->io->writeError(
  13627. sprintf(
  13628. ' <info>'.$remainingChanges.' more file%s modified, choose "v" to view the full list</info>',
  13629. $remainingChanges === 1 ? '' : 's'
  13630. )
  13631. );
  13632. }
  13633. while (true) {
  13634. switch ($this->io->ask(' <info>Discard changes [y,n,v,?]?</info> ', '?')) {
  13635. case 'y':
  13636. $this->discardChanges($path);
  13637. break 2;
  13638. case 'n':
  13639. throw new \RuntimeException('Update aborted');
  13640. case 'v':
  13641. $this->io->writeError($changes);
  13642. break;
  13643. case '?':
  13644. default:
  13645. $this->io->writeError(array(
  13646. ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'),
  13647. ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up',
  13648. ' v - view modified files',
  13649. ' ? - print help',
  13650. ));
  13651. break;
  13652. }
  13653. }
  13654. }
  13655. protected function getCommitLogs($fromReference, $toReference, $path)
  13656. {
  13657. if (preg_match('{@(\d+)$}', $fromReference) && preg_match('{@(\d+)$}', $toReference)) {
  13658. $command = sprintf('svn info --non-interactive --xml %s', ProcessExecutor::escape($path));
  13659. if (0 !== $this->process->execute($command, $output, $path)) {
  13660. throw new \RuntimeException(
  13661. 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()
  13662. );
  13663. }
  13664. $urlPattern = '#<url>(.*)</url>#';
  13665. if (preg_match($urlPattern, $output, $matches)) {
  13666. $baseUrl = $matches[1];
  13667. } else {
  13668. throw new \RuntimeException(
  13669. 'Unable to determine svn url for path '. $path
  13670. );
  13671. }
  13672. $fromRevision = preg_replace('{.*@(\d+)$}', '$1', $fromReference);
  13673. $toRevision = preg_replace('{.*@(\d+)$}', '$1', $toReference);
  13674. $command = sprintf('svn log -r%s:%s --incremental', ProcessExecutor::escape($fromRevision), ProcessExecutor::escape($toRevision));
  13675. $util = new SvnUtil($baseUrl, $this->io, $this->config, $this->process);
  13676. $util->setCacheCredentials($this->cacheCredentials);
  13677. try {
  13678. return $util->executeLocal($command, $path, null, $this->io->isVerbose());
  13679. } catch (\RuntimeException $e) {
  13680. throw new \RuntimeException(
  13681. 'Failed to execute ' . $command . "\n\n".$e->getMessage()
  13682. );
  13683. }
  13684. }
  13685. return "Could not retrieve changes between $fromReference and $toReference due to missing revision information";
  13686. }
  13687. protected function discardChanges($path)
  13688. {
  13689. if (0 !== $this->process->execute('svn revert -R .', $output, $path)) {
  13690. throw new \RuntimeException("Could not reset changes\n\n:".$this->process->getErrorOutput());
  13691. }
  13692. }
  13693. protected function hasMetadataRepository($path)
  13694. {
  13695. return is_dir($path.'/.svn');
  13696. }
  13697. }
  13698. <?php
  13699. namespace Composer\Downloader;
  13700. use Composer\Package\PackageInterface;
  13701. class TarDownloader extends ArchiveDownloader
  13702. {
  13703. protected function extract(PackageInterface $package, $file, $path)
  13704. {
  13705. $archive = new \PharData($file);
  13706. $archive->extractTo($path, null, true);
  13707. }
  13708. }
  13709. <?php
  13710. namespace Composer\Downloader;
  13711. class TransportException extends \RuntimeException
  13712. {
  13713. protected $headers;
  13714. protected $response;
  13715. protected $statusCode;
  13716. protected $responseInfo = array();
  13717. public function setHeaders($headers)
  13718. {
  13719. $this->headers = $headers;
  13720. }
  13721. public function getHeaders()
  13722. {
  13723. return $this->headers;
  13724. }
  13725. public function setResponse($response)
  13726. {
  13727. $this->response = $response;
  13728. }
  13729. public function getResponse()
  13730. {
  13731. return $this->response;
  13732. }
  13733. public function setStatusCode($statusCode)
  13734. {
  13735. $this->statusCode = $statusCode;
  13736. }
  13737. public function getStatusCode()
  13738. {
  13739. return $this->statusCode;
  13740. }
  13741. public function getResponseInfo()
  13742. {
  13743. return $this->responseInfo;
  13744. }
  13745. public function setResponseInfo(array $responseInfo)
  13746. {
  13747. $this->responseInfo = $responseInfo;
  13748. }
  13749. }
  13750. <?php
  13751. namespace Composer\Downloader;
  13752. use Composer\Package\PackageInterface;
  13753. interface VcsCapableDownloaderInterface
  13754. {
  13755. public function getVcsReference(PackageInterface $package, $path);
  13756. }
  13757. <?php
  13758. namespace Composer\Downloader;
  13759. use Composer\Config;
  13760. use Composer\Package\Dumper\ArrayDumper;
  13761. use Composer\Package\PackageInterface;
  13762. use Composer\Package\Version\VersionGuesser;
  13763. use Composer\Package\Version\VersionParser;
  13764. use Composer\Util\ProcessExecutor;
  13765. use Composer\IO\IOInterface;
  13766. use Composer\Util\Filesystem;
  13767. use React\Promise\PromiseInterface;
  13768. use Composer\DependencyResolver\Operation\UpdateOperation;
  13769. use Composer\DependencyResolver\Operation\InstallOperation;
  13770. use Composer\DependencyResolver\Operation\UninstallOperation;
  13771. abstract class VcsDownloader implements DownloaderInterface, ChangeReportInterface, VcsCapableDownloaderInterface
  13772. {
  13773. protected $io;
  13774. protected $config;
  13775. protected $process;
  13776. protected $filesystem;
  13777. protected $hasCleanedChanges = array();
  13778. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, Filesystem $fs = null)
  13779. {
  13780. $this->io = $io;
  13781. $this->config = $config;
  13782. $this->process = $process ?: new ProcessExecutor($io);
  13783. $this->filesystem = $fs ?: new Filesystem($this->process);
  13784. }
  13785. public function getInstallationSource()
  13786. {
  13787. return 'source';
  13788. }
  13789. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13790. {
  13791. if (!$package->getSourceReference()) {
  13792. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  13793. }
  13794. $urls = $this->prepareUrls($package->getSourceUrls());
  13795. while ($url = array_shift($urls)) {
  13796. try {
  13797. return $this->doDownload($package, $path, $url, $prevPackage);
  13798. } catch (\Exception $e) {
  13799. if ($e instanceof \PHPUnit\Framework\Exception) {
  13800. throw $e;
  13801. }
  13802. if ($this->io->isDebug()) {
  13803. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  13804. } elseif (count($urls)) {
  13805. $this->io->writeError(' Failed, trying the next URL');
  13806. }
  13807. if (!count($urls)) {
  13808. throw $e;
  13809. }
  13810. }
  13811. }
  13812. }
  13813. public function prepare($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13814. {
  13815. if ($type === 'update') {
  13816. $this->cleanChanges($prevPackage, $path, true);
  13817. $this->hasCleanedChanges[$prevPackage->getUniqueName()] = true;
  13818. } elseif ($type === 'install') {
  13819. $this->filesystem->emptyDirectory($path);
  13820. } elseif ($type === 'uninstall') {
  13821. $this->cleanChanges($package, $path, false);
  13822. }
  13823. }
  13824. public function cleanup($type, PackageInterface $package, $path, PackageInterface $prevPackage = null)
  13825. {
  13826. if ($type === 'update' && isset($this->hasCleanedChanges[$prevPackage->getUniqueName()])) {
  13827. $this->reapplyChanges($path);
  13828. unset($this->hasCleanedChanges[$prevPackage->getUniqueName()]);
  13829. }
  13830. }
  13831. public function install(PackageInterface $package, $path)
  13832. {
  13833. if (!$package->getSourceReference()) {
  13834. throw new \InvalidArgumentException('Package '.$package->getPrettyName().' is missing reference information');
  13835. }
  13836. $this->io->writeError(" - " . InstallOperation::format($package).': ', false);
  13837. $urls = $this->prepareUrls($package->getSourceUrls());
  13838. while ($url = array_shift($urls)) {
  13839. try {
  13840. $this->doInstall($package, $path, $url);
  13841. break;
  13842. } catch (\Exception $e) {
  13843. if ($e instanceof \PHPUnit\Framework\Exception) {
  13844. throw $e;
  13845. }
  13846. if ($this->io->isDebug()) {
  13847. $this->io->writeError('Failed: ['.get_class($e).'] '.$e->getMessage());
  13848. } elseif (count($urls)) {
  13849. $this->io->writeError(' Failed, trying the next URL');
  13850. }
  13851. if (!count($urls)) {
  13852. throw $e;
  13853. }
  13854. }
  13855. }
  13856. }
  13857. public function update(PackageInterface $initial, PackageInterface $target, $path)
  13858. {
  13859. if (!$target->getSourceReference()) {
  13860. throw new \InvalidArgumentException('Package '.$target->getPrettyName().' is missing reference information');
  13861. }
  13862. $this->io->writeError(" - " . UpdateOperation::format($initial, $target).': ', false);
  13863. $urls = $this->prepareUrls($target->getSourceUrls());
  13864. $exception = null;
  13865. while ($url = array_shift($urls)) {
  13866. try {
  13867. $this->doUpdate($initial, $target, $path, $url);
  13868. $exception = null;
  13869. break;
  13870. } catch (\Exception $exception) {
  13871. if ($exception instanceof \PHPUnit\Framework\Exception) {
  13872. throw $exception;
  13873. }
  13874. if ($this->io->isDebug()) {
  13875. $this->io->writeError('Failed: ['.get_class($exception).'] '.$exception->getMessage());
  13876. } elseif (count($urls)) {
  13877. $this->io->writeError(' Failed, trying the next URL');
  13878. }
  13879. }
  13880. }
  13881. if (!$exception && $this->io->isVerbose() && $this->hasMetadataRepository($path)) {
  13882. $message = 'Pulling in changes:';
  13883. $logs = $this->getCommitLogs($initial->getSourceReference(), $target->getSourceReference(), $path);
  13884. if (!trim($logs)) {
  13885. $message = 'Rolling back changes:';
  13886. $logs = $this->getCommitLogs($target->getSourceReference(), $initial->getSourceReference(), $path);
  13887. }
  13888. if (trim($logs)) {
  13889. $logs = implode("\n", array_map(function ($line) {
  13890. return ' ' . $line;
  13891. }, explode("\n", $logs)));
  13892. $logs = str_replace('<', '\<', $logs);
  13893. $this->io->writeError(' '.$message);
  13894. $this->io->writeError($logs);
  13895. }
  13896. }
  13897. if (!$urls && $exception) {
  13898. throw $exception;
  13899. }
  13900. }
  13901. public function remove(PackageInterface $package, $path)
  13902. {
  13903. $this->io->writeError(" - " . UninstallOperation::format($package));
  13904. if (!$this->filesystem->removeDirectory($path)) {
  13905. throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
  13906. }
  13907. }
  13908. public function getVcsReference(PackageInterface $package, $path)
  13909. {
  13910. $parser = new VersionParser;
  13911. $guesser = new VersionGuesser($this->config, $this->process, $parser);
  13912. $dumper = new ArrayDumper;
  13913. $packageConfig = $dumper->dump($package);
  13914. if ($packageVersion = $guesser->guessVersion($packageConfig, $path)) {
  13915. return $packageVersion['commit'];
  13916. }
  13917. }
  13918. protected function cleanChanges(PackageInterface $package, $path, $update)
  13919. {
  13920. if (null !== $this->getLocalChanges($package, $path)) {
  13921. throw new \RuntimeException('Source directory ' . $path . ' has uncommitted changes.');
  13922. }
  13923. }
  13924. protected function reapplyChanges($path)
  13925. {
  13926. }
  13927. abstract protected function doDownload(PackageInterface $package, $path, $url, PackageInterface $prevPackage = null);
  13928. abstract protected function doInstall(PackageInterface $package, $path, $url);
  13929. abstract protected function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url);
  13930. abstract protected function getCommitLogs($fromReference, $toReference, $path);
  13931. abstract protected function hasMetadataRepository($path);
  13932. private function prepareUrls(array $urls)
  13933. {
  13934. foreach ($urls as $index => $url) {
  13935. if (Filesystem::isLocalPath($url)) {
  13936. $fileProtocol = 'file://';
  13937. $isFileProtocol = false;
  13938. if (0 === strpos($url, $fileProtocol)) {
  13939. $url = substr($url, strlen($fileProtocol));
  13940. $isFileProtocol = true;
  13941. }
  13942. if (false !== strpos($url, '%')) {
  13943. $url = rawurldecode($url);
  13944. }
  13945. $urls[$index] = realpath($url);
  13946. if ($isFileProtocol) {
  13947. $urls[$index] = $fileProtocol . $urls[$index];
  13948. }
  13949. }
  13950. }
  13951. return $urls;
  13952. }
  13953. }
  13954. <?php
  13955. namespace Composer\Downloader;
  13956. use Composer\Package\PackageInterface;
  13957. use Composer\Util\ProcessExecutor;
  13958. class XzDownloader extends ArchiveDownloader
  13959. {
  13960. protected function extract(PackageInterface $package, $file, $path)
  13961. {
  13962. $command = 'tar -xJf ' . ProcessExecutor::escape($file) . ' -C ' . ProcessExecutor::escape($path);
  13963. if (0 === $this->process->execute($command, $ignoredOutput)) {
  13964. return;
  13965. }
  13966. $processError = 'Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput();
  13967. throw new \RuntimeException($processError);
  13968. }
  13969. }
  13970. <?php
  13971. namespace Composer\Downloader;
  13972. use Composer\Package\PackageInterface;
  13973. use Composer\Util\IniHelper;
  13974. use Composer\Util\Platform;
  13975. use Composer\Util\ProcessExecutor;
  13976. use Symfony\Component\Process\ExecutableFinder;
  13977. use ZipArchive;
  13978. class ZipDownloader extends ArchiveDownloader
  13979. {
  13980. protected static $hasSystemUnzip;
  13981. private static $hasZipArchive;
  13982. private static $isWindows;
  13983. private $zipArchiveObject;
  13984. public function download(PackageInterface $package, $path, PackageInterface $prevPackage = null, $output = true)
  13985. {
  13986. if (null === self::$hasSystemUnzip) {
  13987. $finder = new ExecutableFinder;
  13988. self::$hasSystemUnzip = (bool) $finder->find('unzip');
  13989. }
  13990. if (null === self::$hasZipArchive) {
  13991. self::$hasZipArchive = class_exists('ZipArchive');
  13992. }
  13993. if (!self::$hasZipArchive && !self::$hasSystemUnzip) {
  13994. $iniMessage = IniHelper::getMessage();
  13995. $error = "The zip extension and unzip command are both missing, skipping.\n" . $iniMessage;
  13996. throw new \RuntimeException($error);
  13997. }
  13998. if (null === self::$isWindows) {
  13999. self::$isWindows = Platform::isWindows();
  14000. if (!self::$isWindows && !self::$hasSystemUnzip) {
  14001. $this->io->writeError("<warning>As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.</warning>");
  14002. $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>");
  14003. $this->io->writeError("<warning>Installing 'unzip' may remediate them.</warning>");
  14004. }
  14005. }
  14006. return parent::download($package, $path, $prevPackage, $output);
  14007. }
  14008. private function extractWithSystemUnzip(PackageInterface $package, $file, $path, $isLastChance, $async = false)
  14009. {
  14010. if (!self::$hasZipArchive) {
  14011. $isLastChance = true;
  14012. }
  14013. if (!self::$hasSystemUnzip && !$isLastChance) {
  14014. return $this->extractWithZipArchive($package, $file, $path, true);
  14015. }
  14016. $overwrite = $isLastChance ? '-o' : '';
  14017. $command = 'unzip -qq '.$overwrite.' '.ProcessExecutor::escape($file).' -d '.ProcessExecutor::escape($path);
  14018. if ($async) {
  14019. $self = $this;
  14020. $io = $this->io;
  14021. $tryFallback = function ($processError) use ($isLastChance, $io, $self, $file, $path, $package) {
  14022. if ($isLastChance) {
  14023. throw $processError;
  14024. }
  14025. if (!is_file($file)) {
  14026. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14027. $io->writeError(' <warning>This most likely is due to a custom installer plugin not handling the returned Promise from the downloader</warning>');
  14028. $io->writeError(' <warning>See https://github.com/composer/installers/commit/5006d0c28730ade233a8f42ec31ac68fb1c5c9bb for an example fix</warning>');
  14029. } else {
  14030. $io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14031. $io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  14032. $io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
  14033. }
  14034. return $self->extractWithZipArchive($package, $file, $path, true);
  14035. };
  14036. try {
  14037. $promise = $this->process->executeAsync($command);
  14038. return $promise->then(function ($process) use ($tryFallback, $command, $package, $file) {
  14039. if (!$process->isSuccessful()) {
  14040. $output = $process->getErrorOutput();
  14041. $output = str_replace(', '.$file.'.zip or '.$file.'.ZIP', '', $output);
  14042. return $tryFallback(new \RuntimeException('Failed to extract '.$package->getName().': ('.$process->getExitCode().') '.$command."\n\n".$output));
  14043. }
  14044. });
  14045. } catch (\Exception $e) {
  14046. return $tryFallback($e);
  14047. } catch (\Throwable $e) {
  14048. return $tryFallback($e);
  14049. }
  14050. }
  14051. $processError = null;
  14052. try {
  14053. if (0 === $exitCode = $this->process->execute($command, $ignoredOutput)) {
  14054. return \React\Promise\resolve();
  14055. }
  14056. $processError = new \RuntimeException('Failed to execute ('.$exitCode.') '.$command."\n\n".$this->process->getErrorOutput());
  14057. } catch (\Exception $e) {
  14058. $processError = $e;
  14059. }
  14060. if ($isLastChance) {
  14061. throw $processError;
  14062. }
  14063. $this->io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14064. $this->io->writeError(' The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems)');
  14065. $this->io->writeError(' Unzip with unzip command failed, falling back to ZipArchive class');
  14066. return $this->extractWithZipArchive($package, $file, $path, true);
  14067. }
  14068. public function extractWithZipArchive(PackageInterface $package, $file, $path, $isLastChance)
  14069. {
  14070. if (!self::$hasSystemUnzip) {
  14071. $isLastChance = true;
  14072. }
  14073. if (!self::$hasZipArchive && !$isLastChance) {
  14074. return $this->extractWithSystemUnzip($package, $file, $path, true);
  14075. }
  14076. $processError = null;
  14077. $zipArchive = $this->zipArchiveObject ?: new ZipArchive();
  14078. try {
  14079. if (true === ($retval = $zipArchive->open($file))) {
  14080. $extractResult = $zipArchive->extractTo($path);
  14081. if (true === $extractResult) {
  14082. $zipArchive->close();
  14083. return \React\Promise\resolve();
  14084. }
  14085. $processError = new \RuntimeException(rtrim("There was an error extracting the ZIP file, it is either corrupted or using an invalid format.\n"));
  14086. } else {
  14087. $processError = new \UnexpectedValueException(rtrim($this->getErrorMessage($retval, $file)."\n"), $retval);
  14088. }
  14089. } catch (\ErrorException $e) {
  14090. $processError = new \RuntimeException('The archive may contain identical file names with different capitalization (which fails on case insensitive filesystems): '.$e->getMessage(), 0, $e);
  14091. } catch (\Exception $e) {
  14092. $processError = $e;
  14093. } catch (\Throwable $e) {
  14094. $processError = $e;
  14095. }
  14096. if ($isLastChance) {
  14097. throw $processError;
  14098. }
  14099. $this->io->writeError(' <warning>'.$processError->getMessage().'</warning>');
  14100. $this->io->writeError(' Unzip with ZipArchive class failed, falling back to unzip command');
  14101. return $this->extractWithSystemUnzip($package, $file, $path, true);
  14102. }
  14103. public function extract(PackageInterface $package, $file, $path)
  14104. {
  14105. if (self::$isWindows) {
  14106. return $this->extractWithZipArchive($package, $file, $path, false);
  14107. }
  14108. return $this->extractWithSystemUnzip($package, $file, $path, false, true);
  14109. }
  14110. protected function getErrorMessage($retval, $file)
  14111. {
  14112. switch ($retval) {
  14113. case ZipArchive::ER_EXISTS:
  14114. return sprintf("File '%s' already exists.", $file);
  14115. case ZipArchive::ER_INCONS:
  14116. return sprintf("Zip archive '%s' is inconsistent.", $file);
  14117. case ZipArchive::ER_INVAL:
  14118. return sprintf("Invalid argument (%s)", $file);
  14119. case ZipArchive::ER_MEMORY:
  14120. return sprintf("Malloc failure (%s)", $file);
  14121. case ZipArchive::ER_NOENT:
  14122. return sprintf("No such zip file: '%s'", $file);
  14123. case ZipArchive::ER_NOZIP:
  14124. return sprintf("'%s' is not a zip archive.", $file);
  14125. case ZipArchive::ER_OPEN:
  14126. return sprintf("Can't open zip file: %s", $file);
  14127. case ZipArchive::ER_READ:
  14128. return sprintf("Zip read error (%s)", $file);
  14129. case ZipArchive::ER_SEEK:
  14130. return sprintf("Zip seek error (%s)", $file);
  14131. default:
  14132. return sprintf("'%s' is not a valid zip archive, got error code: %s", $file, $retval);
  14133. }
  14134. }
  14135. }
  14136. <?php
  14137. namespace Composer\EventDispatcher;
  14138. class Event
  14139. {
  14140. protected $name;
  14141. protected $args;
  14142. protected $flags;
  14143. private $propagationStopped = false;
  14144. public function __construct($name, array $args = array(), array $flags = array())
  14145. {
  14146. $this->name = $name;
  14147. $this->args = $args;
  14148. $this->flags = $flags;
  14149. }
  14150. public function getName()
  14151. {
  14152. return $this->name;
  14153. }
  14154. public function getArguments()
  14155. {
  14156. return $this->args;
  14157. }
  14158. public function getFlags()
  14159. {
  14160. return $this->flags;
  14161. }
  14162. public function isPropagationStopped()
  14163. {
  14164. return $this->propagationStopped;
  14165. }
  14166. public function stopPropagation()
  14167. {
  14168. $this->propagationStopped = true;
  14169. }
  14170. }
  14171. <?php
  14172. namespace Composer\EventDispatcher;
  14173. use Composer\DependencyResolver\Transaction;
  14174. use Composer\Installer\InstallerEvent;
  14175. use Composer\IO\IOInterface;
  14176. use Composer\Composer;
  14177. use Composer\DependencyResolver\Operation\OperationInterface;
  14178. use Composer\Repository\RepositoryInterface;
  14179. use Composer\Script;
  14180. use Composer\Installer\PackageEvent;
  14181. use Composer\Installer\BinaryInstaller;
  14182. use Composer\Util\ProcessExecutor;
  14183. use Composer\Script\Event as ScriptEvent;
  14184. use Composer\ClassLoader;
  14185. use Symfony\Component\Process\PhpExecutableFinder;
  14186. class EventDispatcher
  14187. {
  14188. protected $composer;
  14189. protected $io;
  14190. protected $loader;
  14191. protected $process;
  14192. protected $listeners = array();
  14193. private $eventStack;
  14194. public function __construct(Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  14195. {
  14196. $this->composer = $composer;
  14197. $this->io = $io;
  14198. $this->process = $process ?: new ProcessExecutor($io);
  14199. $this->eventStack = array();
  14200. }
  14201. public function dispatch($eventName, Event $event = null)
  14202. {
  14203. if (null === $event) {
  14204. $event = new Event($eventName);
  14205. }
  14206. return $this->doDispatch($event);
  14207. }
  14208. public function dispatchScript($eventName, $devMode = false, $additionalArgs = array(), $flags = array())
  14209. {
  14210. return $this->doDispatch(new Script\Event($eventName, $this->composer, $this->io, $devMode, $additionalArgs, $flags));
  14211. }
  14212. public function dispatchPackageEvent($eventName, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  14213. {
  14214. return $this->doDispatch(new PackageEvent($eventName, $this->composer, $this->io, $devMode, $localRepo, $operations, $operation));
  14215. }
  14216. public function dispatchInstallerEvent($eventName, $devMode, $executeOperations, Transaction $transaction)
  14217. {
  14218. return $this->doDispatch(new InstallerEvent($eventName, $this->composer, $this->io, $devMode, $executeOperations, $transaction));
  14219. }
  14220. protected function doDispatch(Event $event)
  14221. {
  14222. if (getenv('COMPOSER_DEBUG_EVENTS')) {
  14223. $details = null;
  14224. if ($event instanceof PackageEvent) {
  14225. $details = (string) $event->getOperation();
  14226. }
  14227. $this->io->writeError('Dispatching <info>'.$event->getName().'</info>'.($details ? ' ('.$details.')' : '').' event');
  14228. }
  14229. $listeners = $this->getListeners($event);
  14230. $this->pushEvent($event);
  14231. $return = 0;
  14232. foreach ($listeners as $callable) {
  14233. $this->ensureBinDirIsInPath();
  14234. if (!is_string($callable)) {
  14235. if (!is_callable($callable)) {
  14236. $className = is_object($callable[0]) ? get_class($callable[0]) : $callable[0];
  14237. throw new \RuntimeException('Subscriber '.$className.'::'.$callable[1].' for event '.$event->getName().' is not callable, make sure the function is defined and public');
  14238. }
  14239. if (is_array($callable) && (is_string($callable[0]) || is_object($callable[0])) && is_string($callable[1])) {
  14240. $this->io->writeError(sprintf('> %s: %s', $event->getName(), (is_object($callable[0]) ? get_class($callable[0]) : $callable[0]).'->'.$callable[1]), true, IOInterface::VERBOSE);
  14241. }
  14242. $return = false === call_user_func($callable, $event) ? 1 : 0;
  14243. } elseif ($this->isComposerScript($callable)) {
  14244. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $callable), true, IOInterface::VERBOSE);
  14245. $script = explode(' ', substr($callable, 1));
  14246. $scriptName = $script[0];
  14247. unset($script[0]);
  14248. $args = array_merge($script, $event->getArguments());
  14249. $flags = $event->getFlags();
  14250. if (strpos($callable, '@composer ') === 0) {
  14251. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . ' ' . implode(' ', $args);
  14252. if (0 !== ($exitCode = $this->executeTty($exec))) {
  14253. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14254. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  14255. }
  14256. } else {
  14257. if (!$this->getListeners(new Event($scriptName))) {
  14258. $this->io->writeError(sprintf('<warning>You made a reference to a non-existent script %s</warning>', $callable), true, IOInterface::QUIET);
  14259. }
  14260. try {
  14261. $scriptEvent = new Script\Event($scriptName, $event->getComposer(), $event->getIO(), $event->isDevMode(), $args, $flags);
  14262. $scriptEvent->setOriginatingEvent($event);
  14263. $return = $this->dispatch($scriptName, $scriptEvent);
  14264. } catch (ScriptExecutionException $e) {
  14265. $this->io->writeError(sprintf('<error>Script %s was called via %s</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14266. throw $e;
  14267. }
  14268. }
  14269. } elseif ($this->isPhpScript($callable)) {
  14270. $className = substr($callable, 0, strpos($callable, '::'));
  14271. $methodName = substr($callable, strpos($callable, '::') + 2);
  14272. if (!class_exists($className)) {
  14273. $this->io->writeError('<warning>Class '.$className.' is not autoloadable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  14274. continue;
  14275. }
  14276. if (!is_callable($callable)) {
  14277. $this->io->writeError('<warning>Method '.$callable.' is not callable, can not call '.$event->getName().' script</warning>', true, IOInterface::QUIET);
  14278. continue;
  14279. }
  14280. try {
  14281. $return = false === $this->executeEventPhpScript($className, $methodName, $event) ? 1 : 0;
  14282. } catch (\Exception $e) {
  14283. $message = "Script %s handling the %s event terminated with an exception";
  14284. $this->io->writeError('<error>'.sprintf($message, $callable, $event->getName()).'</error>', true, IOInterface::QUIET);
  14285. throw $e;
  14286. }
  14287. } else {
  14288. $args = implode(' ', array_map(array('Composer\Util\ProcessExecutor', 'escape'), $event->getArguments()));
  14289. $exec = $callable . ($args === '' ? '' : ' '.$args);
  14290. if ($this->io->isVerbose()) {
  14291. $this->io->writeError(sprintf('> %s: %s', $event->getName(), $exec));
  14292. } else {
  14293. $this->io->writeError(sprintf('> %s', $exec));
  14294. }
  14295. $possibleLocalBinaries = $this->composer->getPackage()->getBinaries();
  14296. if ($possibleLocalBinaries) {
  14297. foreach ($possibleLocalBinaries as $localExec) {
  14298. if (preg_match('{\b'.preg_quote($callable).'$}', $localExec)) {
  14299. $caller = BinaryInstaller::determineBinaryCaller($localExec);
  14300. $exec = preg_replace('{^'.preg_quote($callable).'}', $caller . ' ' . $localExec, $exec);
  14301. break;
  14302. }
  14303. }
  14304. }
  14305. if (strpos($exec, '@putenv ') === 0) {
  14306. putenv(substr($exec, 8));
  14307. list($var, $value) = explode('=', substr($exec, 8), 2);
  14308. $_SERVER[$var] = $value;
  14309. continue;
  14310. }
  14311. if (strpos($exec, '@php ') === 0) {
  14312. $exec = $this->getPhpExecCommand() . ' ' . substr($exec, 5);
  14313. } else {
  14314. $finder = new PhpExecutableFinder();
  14315. $phpPath = $finder->find(false);
  14316. if ($phpPath) {
  14317. $_SERVER['PHP_BINARY'] = $phpPath;
  14318. putenv('PHP_BINARY=' . $_SERVER['PHP_BINARY']);
  14319. }
  14320. }
  14321. if (strpos($exec, 'composer ') === 0) {
  14322. $exec = $this->getPhpExecCommand() . ' ' . ProcessExecutor::escape(getenv('COMPOSER_BINARY')) . substr($exec, 8);
  14323. }
  14324. if (0 !== ($exitCode = $this->executeTty($exec))) {
  14325. $this->io->writeError(sprintf('<error>Script %s handling the %s event returned with error code '.$exitCode.'</error>', $callable, $event->getName()), true, IOInterface::QUIET);
  14326. throw new ScriptExecutionException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
  14327. }
  14328. }
  14329. if ($event->isPropagationStopped()) {
  14330. break;
  14331. }
  14332. }
  14333. $this->popEvent();
  14334. return $return;
  14335. }
  14336. protected function executeTty($exec)
  14337. {
  14338. if ($this->io->isInteractive()) {
  14339. return $this->process->executeTty($exec);
  14340. }
  14341. return $this->process->execute($exec);
  14342. }
  14343. protected function getPhpExecCommand()
  14344. {
  14345. $finder = new PhpExecutableFinder();
  14346. $phpPath = $finder->find(false);
  14347. if (!$phpPath) {
  14348. throw new \RuntimeException('Failed to locate PHP binary to execute '.$phpPath);
  14349. }
  14350. $phpArgs = $finder->findArguments();
  14351. $phpArgs = $phpArgs ? ' ' . implode(' ', $phpArgs) : '';
  14352. $allowUrlFOpenFlag = ' -d allow_url_fopen=' . ProcessExecutor::escape(ini_get('allow_url_fopen'));
  14353. $disableFunctionsFlag = ' -d disable_functions=' . ProcessExecutor::escape(ini_get('disable_functions'));
  14354. $memoryLimitFlag = ' -d memory_limit=' . ProcessExecutor::escape(ini_get('memory_limit'));
  14355. return ProcessExecutor::escape($phpPath) . $phpArgs . $allowUrlFOpenFlag . $disableFunctionsFlag . $memoryLimitFlag;
  14356. }
  14357. protected function executeEventPhpScript($className, $methodName, Event $event)
  14358. {
  14359. if ($this->io->isVerbose()) {
  14360. $this->io->writeError(sprintf('> %s: %s::%s', $event->getName(), $className, $methodName));
  14361. } else {
  14362. $this->io->writeError(sprintf('> %s::%s', $className, $methodName));
  14363. }
  14364. return $className::$methodName($event);
  14365. }
  14366. public function addListener($eventName, $listener, $priority = 0)
  14367. {
  14368. $this->listeners[$eventName][$priority][] = $listener;
  14369. }
  14370. public function removeListener($listener)
  14371. {
  14372. foreach ($this->listeners as $eventName => $priorities) {
  14373. foreach ($priorities as $priority => $listeners) {
  14374. foreach ($listeners as $index => $candidate) {
  14375. if ($listener === $candidate || (is_array($candidate) && is_object($listener) && $candidate[0] === $listener)) {
  14376. unset($this->listeners[$eventName][$priority][$index]);
  14377. }
  14378. }
  14379. }
  14380. }
  14381. }
  14382. public function addSubscriber(EventSubscriberInterface $subscriber)
  14383. {
  14384. foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
  14385. if (is_string($params)) {
  14386. $this->addListener($eventName, array($subscriber, $params));
  14387. } elseif (is_string($params[0])) {
  14388. $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
  14389. } else {
  14390. foreach ($params as $listener) {
  14391. $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
  14392. }
  14393. }
  14394. }
  14395. }
  14396. protected function getListeners(Event $event)
  14397. {
  14398. $scriptListeners = $this->getScriptListeners($event);
  14399. if (!isset($this->listeners[$event->getName()][0])) {
  14400. $this->listeners[$event->getName()][0] = array();
  14401. }
  14402. krsort($this->listeners[$event->getName()]);
  14403. $listeners = $this->listeners;
  14404. $listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
  14405. return call_user_func_array('array_merge', $listeners[$event->getName()]);
  14406. }
  14407. public function hasEventListeners(Event $event)
  14408. {
  14409. $listeners = $this->getListeners($event);
  14410. return count($listeners) > 0;
  14411. }
  14412. protected function getScriptListeners(Event $event)
  14413. {
  14414. $package = $this->composer->getPackage();
  14415. $scripts = $package->getScripts();
  14416. if (empty($scripts[$event->getName()])) {
  14417. return array();
  14418. }
  14419. if ($this->loader) {
  14420. $this->loader->unregister();
  14421. }
  14422. $generator = $this->composer->getAutoloadGenerator();
  14423. if ($event instanceof ScriptEvent) {
  14424. $generator->setDevMode($event->isDevMode());
  14425. }
  14426. $packages = $this->composer->getRepositoryManager()->getLocalRepository()->getCanonicalPackages();
  14427. $packageMap = $generator->buildPackageMap($this->composer->getInstallationManager(), $package, $packages);
  14428. $map = $generator->parseAutoloads($packageMap, $package);
  14429. $this->loader = $generator->createLoader($map);
  14430. $this->loader->register();
  14431. return $scripts[$event->getName()];
  14432. }
  14433. protected function isPhpScript($callable)
  14434. {
  14435. return false === strpos($callable, ' ') && false !== strpos($callable, '::');
  14436. }
  14437. protected function isComposerScript($callable)
  14438. {
  14439. return strpos($callable, '@') === 0 && strpos($callable, '@php ') !== 0 && strpos($callable, '@putenv ') !== 0;
  14440. }
  14441. protected function pushEvent(Event $event)
  14442. {
  14443. $eventName = $event->getName();
  14444. if (in_array($eventName, $this->eventStack)) {
  14445. throw new \RuntimeException(sprintf("Circular call to script handler '%s' detected", $eventName));
  14446. }
  14447. return array_push($this->eventStack, $eventName);
  14448. }
  14449. protected function popEvent()
  14450. {
  14451. return array_pop($this->eventStack);
  14452. }
  14453. private function ensureBinDirIsInPath()
  14454. {
  14455. $pathStr = 'PATH';
  14456. if (!isset($_SERVER[$pathStr]) && isset($_SERVER['Path'])) {
  14457. $pathStr = 'Path';
  14458. }
  14459. $binDir = $this->composer->getConfig()->get('bin-dir');
  14460. if (is_dir($binDir)) {
  14461. $binDir = realpath($binDir);
  14462. if (isset($_SERVER[$pathStr]) && !preg_match('{(^|'.PATH_SEPARATOR.')'.preg_quote($binDir).'($|'.PATH_SEPARATOR.')}', $_SERVER[$pathStr])) {
  14463. $_SERVER[$pathStr] = $binDir.PATH_SEPARATOR.getenv($pathStr);
  14464. putenv($pathStr.'='.$_SERVER[$pathStr]);
  14465. }
  14466. }
  14467. }
  14468. }
  14469. <?php
  14470. namespace Composer\EventDispatcher;
  14471. interface EventSubscriberInterface
  14472. {
  14473. public static function getSubscribedEvents();
  14474. }
  14475. <?php
  14476. namespace Composer\EventDispatcher;
  14477. class ScriptExecutionException extends \RuntimeException
  14478. {
  14479. }
  14480. <?php
  14481. namespace Composer\Exception;
  14482. class IrrecoverableDownloadException extends \RuntimeException
  14483. {
  14484. }
  14485. <?php
  14486. namespace Composer\Exception;
  14487. class NoSslException extends \RuntimeException
  14488. {
  14489. }
  14490. <?php
  14491. namespace Composer;
  14492. use Composer\Config\JsonConfigSource;
  14493. use Composer\Json\JsonFile;
  14494. use Composer\IO\IOInterface;
  14495. use Composer\Package\Archiver;
  14496. use Composer\Package\Version\VersionGuesser;
  14497. use Composer\Package\RootPackageInterface;
  14498. use Composer\Repository\RepositoryManager;
  14499. use Composer\Repository\RepositoryFactory;
  14500. use Composer\Repository\WritableRepositoryInterface;
  14501. use Composer\Util\Filesystem;
  14502. use Composer\Util\Platform;
  14503. use Composer\Util\ProcessExecutor;
  14504. use Composer\Util\HttpDownloader;
  14505. use Composer\Util\Loop;
  14506. use Composer\Util\Silencer;
  14507. use Composer\Plugin\PluginEvents;
  14508. use Composer\EventDispatcher\Event;
  14509. use Seld\JsonLint\DuplicateKeyException;
  14510. use Symfony\Component\Console\Formatter\OutputFormatter;
  14511. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  14512. use Symfony\Component\Console\Output\ConsoleOutput;
  14513. use Composer\EventDispatcher\EventDispatcher;
  14514. use Composer\Autoload\AutoloadGenerator;
  14515. use Composer\Package\Version\VersionParser;
  14516. use Composer\Downloader\TransportException;
  14517. use Seld\JsonLint\JsonParser;
  14518. class Factory
  14519. {
  14520. protected static function getHomeDir()
  14521. {
  14522. $home = getenv('COMPOSER_HOME');
  14523. if ($home) {
  14524. return $home;
  14525. }
  14526. if (Platform::isWindows()) {
  14527. if (!getenv('APPDATA')) {
  14528. throw new \RuntimeException('The APPDATA or COMPOSER_HOME environment variable must be set for composer to run correctly');
  14529. }
  14530. return rtrim(strtr(getenv('APPDATA'), '\\', '/'), '/') . '/Composer';
  14531. }
  14532. $userDir = self::getUserDir();
  14533. $dirs = array();
  14534. if (self::useXdg()) {
  14535. $xdgConfig = getenv('XDG_CONFIG_HOME');
  14536. if (!$xdgConfig) {
  14537. $xdgConfig = $userDir . '/.config';
  14538. }
  14539. $dirs[] = $xdgConfig . '/composer';
  14540. }
  14541. $dirs[] = $userDir . '/.composer';
  14542. foreach ($dirs as $dir) {
  14543. if (Silencer::call('is_dir', $dir)) {
  14544. return $dir;
  14545. }
  14546. }
  14547. return $dirs[0];
  14548. }
  14549. protected static function getCacheDir($home)
  14550. {
  14551. $cacheDir = getenv('COMPOSER_CACHE_DIR');
  14552. if ($cacheDir) {
  14553. return $cacheDir;
  14554. }
  14555. $homeEnv = getenv('COMPOSER_HOME');
  14556. if ($homeEnv) {
  14557. return $homeEnv . '/cache';
  14558. }
  14559. if (Platform::isWindows()) {
  14560. if ($cacheDir = getenv('LOCALAPPDATA')) {
  14561. $cacheDir .= '/Composer';
  14562. } else {
  14563. $cacheDir = $home . '/cache';
  14564. }
  14565. return rtrim(strtr($cacheDir, '\\', '/'), '/');
  14566. }
  14567. $userDir = self::getUserDir();
  14568. if ($home === $userDir . '/.composer' && is_dir($home . '/cache')) {
  14569. return $home . '/cache';
  14570. }
  14571. if (self::useXdg()) {
  14572. $xdgCache = getenv('XDG_CACHE_HOME') ?: $userDir . '/.cache';
  14573. return $xdgCache . '/composer';
  14574. }
  14575. return $home . '/cache';
  14576. }
  14577. protected static function getDataDir($home)
  14578. {
  14579. $homeEnv = getenv('COMPOSER_HOME');
  14580. if ($homeEnv) {
  14581. return $homeEnv;
  14582. }
  14583. if (Platform::isWindows()) {
  14584. return strtr($home, '\\', '/');
  14585. }
  14586. $userDir = self::getUserDir();
  14587. if ($home !== $userDir . '/.composer' && self::useXdg()) {
  14588. $xdgData = getenv('XDG_DATA_HOME') ?: $userDir . '/.local/share';
  14589. return $xdgData . '/composer';
  14590. }
  14591. return $home;
  14592. }
  14593. public static function createConfig(IOInterface $io = null, $cwd = null)
  14594. {
  14595. $cwd = $cwd ?: getcwd();
  14596. $config = new Config(true, $cwd);
  14597. $home = self::getHomeDir();
  14598. $config->merge(array('config' => array(
  14599. 'home' => $home,
  14600. 'cache-dir' => self::getCacheDir($home),
  14601. 'data-dir' => self::getDataDir($home),
  14602. )));
  14603. $file = new JsonFile($config->get('home').'/config.json');
  14604. if ($file->exists()) {
  14605. if ($io && $io->isDebug()) {
  14606. $io->writeError('Loading config file ' . $file->getPath());
  14607. }
  14608. $config->merge($file->read());
  14609. }
  14610. $config->setConfigSource(new JsonConfigSource($file));
  14611. $htaccessProtect = (bool) $config->get('htaccess-protect');
  14612. if ($htaccessProtect) {
  14613. $dirs = array($config->get('home'), $config->get('cache-dir'), $config->get('data-dir'));
  14614. foreach ($dirs as $dir) {
  14615. if (!file_exists($dir . '/.htaccess')) {
  14616. if (!is_dir($dir)) {
  14617. Silencer::call('mkdir', $dir, 0777, true);
  14618. }
  14619. Silencer::call('file_put_contents', $dir . '/.htaccess', 'Deny from all');
  14620. }
  14621. }
  14622. }
  14623. $file = new JsonFile($config->get('home').'/auth.json');
  14624. if ($file->exists()) {
  14625. if ($io && $io->isDebug()) {
  14626. $io->writeError('Loading config file ' . $file->getPath());
  14627. }
  14628. $config->merge(array('config' => $file->read()));
  14629. }
  14630. $config->setAuthConfigSource(new JsonConfigSource($file, true));
  14631. if ($composerAuthEnv = getenv('COMPOSER_AUTH')) {
  14632. $authData = json_decode($composerAuthEnv, true);
  14633. if (null === $authData) {
  14634. throw new \UnexpectedValueException('COMPOSER_AUTH environment variable is malformed, should be a valid JSON object');
  14635. }
  14636. if ($io && $io->isDebug()) {
  14637. $io->writeError('Loading auth config from COMPOSER_AUTH');
  14638. }
  14639. $config->merge(array('config' => $authData));
  14640. }
  14641. return $config;
  14642. }
  14643. public static function getComposerFile()
  14644. {
  14645. return trim(getenv('COMPOSER')) ?: './composer.json';
  14646. }
  14647. public static function getLockFile($composerFile)
  14648. {
  14649. return "json" === pathinfo($composerFile, PATHINFO_EXTENSION)
  14650. ? substr($composerFile, 0, -4).'lock'
  14651. : $composerFile . '.lock';
  14652. }
  14653. public static function createAdditionalStyles()
  14654. {
  14655. return array(
  14656. 'highlight' => new OutputFormatterStyle('red'),
  14657. 'warning' => new OutputFormatterStyle('black', 'yellow'),
  14658. );
  14659. }
  14660. public static function createOutput()
  14661. {
  14662. $styles = self::createAdditionalStyles();
  14663. $formatter = new OutputFormatter(false, $styles);
  14664. return new ConsoleOutput(ConsoleOutput::VERBOSITY_NORMAL, null, $formatter);
  14665. }
  14666. public function createComposer(IOInterface $io, $localConfig = null, $disablePlugins = false, $cwd = null, $fullLoad = true)
  14667. {
  14668. $cwd = $cwd ?: getcwd();
  14669. if (null === $localConfig) {
  14670. $localConfig = static::getComposerFile();
  14671. }
  14672. if (is_string($localConfig)) {
  14673. $composerFile = $localConfig;
  14674. $file = new JsonFile($localConfig, null, $io);
  14675. if (!$file->exists()) {
  14676. if ($localConfig === './composer.json' || $localConfig === 'composer.json') {
  14677. $message = 'Composer could not find a composer.json file in '.$cwd;
  14678. } else {
  14679. $message = 'Composer could not find the config file: '.$localConfig;
  14680. }
  14681. $instructions = $fullLoad ? 'To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section' : '';
  14682. throw new \InvalidArgumentException($message.PHP_EOL.$instructions);
  14683. }
  14684. $file->validateSchema(JsonFile::LAX_SCHEMA);
  14685. $jsonParser = new JsonParser;
  14686. try {
  14687. $jsonParser->parse(file_get_contents($localConfig), JsonParser::DETECT_KEY_CONFLICTS);
  14688. } catch (DuplicateKeyException $e) {
  14689. $details = $e->getDetails();
  14690. $io->writeError('<warning>Key '.$details['key'].' is a duplicate in '.$localConfig.' at line '.$details['line'].'</warning>');
  14691. }
  14692. $localConfig = $file->read();
  14693. }
  14694. $config = static::createConfig($io, $cwd);
  14695. $config->merge($localConfig);
  14696. if (isset($composerFile)) {
  14697. $io->writeError('Loading config file ' . $composerFile .' ('.realpath($composerFile).')', true, IOInterface::DEBUG);
  14698. $config->setConfigSource(new JsonConfigSource(new JsonFile(realpath($composerFile), null, $io)));
  14699. $localAuthFile = new JsonFile(dirname(realpath($composerFile)) . '/auth.json', null, $io);
  14700. if ($localAuthFile->exists()) {
  14701. $io->writeError('Loading config file ' . $localAuthFile->getPath(), true, IOInterface::DEBUG);
  14702. $config->merge(array('config' => $localAuthFile->read()));
  14703. $config->setAuthConfigSource(new JsonConfigSource($localAuthFile, true));
  14704. }
  14705. }
  14706. $vendorDir = $config->get('vendor-dir');
  14707. $composer = new Composer();
  14708. $composer->setConfig($config);
  14709. if ($fullLoad) {
  14710. $io->loadConfiguration($config);
  14711. if (!class_exists('Composer\InstalledVersions', false) && file_exists($installedVersionsPath = $config->get('vendor-dir').'/composer/InstalledVersions.php')) {
  14712. include $installedVersionsPath;
  14713. }
  14714. }
  14715. $httpDownloader = self::createHttpDownloader($io, $config);
  14716. $process = new ProcessExecutor($io);
  14717. $loop = new Loop($httpDownloader, $process);
  14718. $composer->setLoop($loop);
  14719. $dispatcher = new EventDispatcher($composer, $io, $process);
  14720. $composer->setEventDispatcher($dispatcher);
  14721. $rm = RepositoryFactory::manager($io, $config, $httpDownloader, $dispatcher, $process);
  14722. $composer->setRepositoryManager($rm);
  14723. if (!$fullLoad && !isset($localConfig['version'])) {
  14724. $localConfig['version'] = '1.0.0';
  14725. }
  14726. $parser = new VersionParser;
  14727. $guesser = new VersionGuesser($config, $process, $parser);
  14728. $loader = $this->loadRootPackage($rm, $config, $parser, $guesser, $io);
  14729. $package = $loader->load($localConfig, 'Composer\Package\RootPackage', $cwd);
  14730. $composer->setPackage($package);
  14731. $this->addLocalRepository($io, $rm, $vendorDir, $package);
  14732. $im = $this->createInstallationManager($loop, $io, $dispatcher);
  14733. $composer->setInstallationManager($im);
  14734. if ($fullLoad) {
  14735. $dm = $this->createDownloadManager($io, $config, $httpDownloader, $process, $dispatcher);
  14736. $composer->setDownloadManager($dm);
  14737. $generator = new AutoloadGenerator($dispatcher, $io);
  14738. $composer->setAutoloadGenerator($generator);
  14739. $am = $this->createArchiveManager($config, $dm, $loop);
  14740. $composer->setArchiveManager($am);
  14741. }
  14742. $this->createDefaultInstallers($im, $composer, $io, $process);
  14743. if ($fullLoad) {
  14744. $globalComposer = null;
  14745. if (realpath($config->get('home')) !== $cwd) {
  14746. $globalComposer = $this->createGlobalComposer($io, $config, $disablePlugins);
  14747. }
  14748. $pm = $this->createPluginManager($io, $composer, $globalComposer, $disablePlugins);
  14749. $composer->setPluginManager($pm);
  14750. $pm->loadInstalledPlugins();
  14751. }
  14752. if ($fullLoad && isset($composerFile)) {
  14753. $lockFile = self::getLockFile($composerFile);
  14754. $locker = new Package\Locker($io, new JsonFile($lockFile, null, $io), $im, file_get_contents($composerFile), $process);
  14755. $composer->setLocker($locker);
  14756. }
  14757. if ($fullLoad) {
  14758. $initEvent = new Event(PluginEvents::INIT);
  14759. $composer->getEventDispatcher()->dispatch($initEvent->getName(), $initEvent);
  14760. if ($rm->getLocalRepository()) {
  14761. $this->purgePackages($rm->getLocalRepository(), $im);
  14762. }
  14763. }
  14764. return $composer;
  14765. }
  14766. public static function createGlobal(IOInterface $io, $disablePlugins = false)
  14767. {
  14768. $factory = new static();
  14769. return $factory->createGlobalComposer($io, static::createConfig($io), $disablePlugins, true);
  14770. }
  14771. protected function addLocalRepository(IOInterface $io, RepositoryManager $rm, $vendorDir, RootPackageInterface $rootPackage)
  14772. {
  14773. $rm->setLocalRepository(new Repository\InstalledFilesystemRepository(new JsonFile($vendorDir.'/composer/installed.json', null, $io), true, $rootPackage));
  14774. }
  14775. protected function createGlobalComposer(IOInterface $io, Config $config, $disablePlugins, $fullLoad = false)
  14776. {
  14777. $composer = null;
  14778. try {
  14779. $composer = $this->createComposer($io, $config->get('home') . '/composer.json', $disablePlugins, $config->get('home'), $fullLoad);
  14780. } catch (\Exception $e) {
  14781. $io->writeError('Failed to initialize global composer: '.$e->getMessage(), true, IOInterface::DEBUG);
  14782. }
  14783. return $composer;
  14784. }
  14785. public function createDownloadManager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process, EventDispatcher $eventDispatcher = null)
  14786. {
  14787. $cache = null;
  14788. if ($config->get('cache-files-ttl') > 0) {
  14789. $cache = new Cache($io, $config->get('cache-files-dir'), 'a-z0-9_./');
  14790. $cache->setReadOnly($config->get('cache-read-only'));
  14791. }
  14792. $fs = new Filesystem($process);
  14793. $dm = new Downloader\DownloadManager($io, false, $fs);
  14794. switch ($preferred = $config->get('preferred-install')) {
  14795. case 'dist':
  14796. $dm->setPreferDist(true);
  14797. break;
  14798. case 'source':
  14799. $dm->setPreferSource(true);
  14800. break;
  14801. case 'auto':
  14802. default:
  14803. break;
  14804. }
  14805. if (is_array($preferred)) {
  14806. $dm->setPreferences($preferred);
  14807. }
  14808. $dm->setDownloader('git', new Downloader\GitDownloader($io, $config, $process, $fs));
  14809. $dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config, $process, $fs));
  14810. $dm->setDownloader('fossil', new Downloader\FossilDownloader($io, $config, $process, $fs));
  14811. $dm->setDownloader('hg', new Downloader\HgDownloader($io, $config, $process, $fs));
  14812. $dm->setDownloader('perforce', new Downloader\PerforceDownloader($io, $config, $process, $fs));
  14813. $dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14814. $dm->setDownloader('rar', new Downloader\RarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14815. $dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14816. $dm->setDownloader('gzip', new Downloader\GzipDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14817. $dm->setDownloader('xz', new Downloader\XzDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14818. $dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14819. $dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14820. $dm->setDownloader('path', new Downloader\PathDownloader($io, $config, $httpDownloader, $eventDispatcher, $cache, $fs, $process));
  14821. return $dm;
  14822. }
  14823. public function createArchiveManager(Config $config, Downloader\DownloadManager $dm, Loop $loop)
  14824. {
  14825. $am = new Archiver\ArchiveManager($dm, $loop);
  14826. $am->addArchiver(new Archiver\ZipArchiver);
  14827. $am->addArchiver(new Archiver\PharArchiver);
  14828. return $am;
  14829. }
  14830. protected function createPluginManager(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  14831. {
  14832. return new Plugin\PluginManager($io, $composer, $globalComposer, $disablePlugins);
  14833. }
  14834. public function createInstallationManager(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  14835. {
  14836. return new Installer\InstallationManager($loop, $io, $eventDispatcher);
  14837. }
  14838. protected function createDefaultInstallers(Installer\InstallationManager $im, Composer $composer, IOInterface $io, ProcessExecutor $process = null)
  14839. {
  14840. $fs = new Filesystem($process);
  14841. $binaryInstaller = new Installer\BinaryInstaller($io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $fs);
  14842. $im->addInstaller(new Installer\LibraryInstaller($io, $composer, null, $fs, $binaryInstaller));
  14843. $im->addInstaller(new Installer\PluginInstaller($io, $composer, $fs, $binaryInstaller));
  14844. $im->addInstaller(new Installer\MetapackageInstaller($io));
  14845. }
  14846. protected function purgePackages(WritableRepositoryInterface $repo, Installer\InstallationManager $im)
  14847. {
  14848. foreach ($repo->getPackages() as $package) {
  14849. if (!$im->isPackageInstalled($repo, $package)) {
  14850. $repo->removePackage($package);
  14851. }
  14852. }
  14853. }
  14854. protected function loadRootPackage(RepositoryManager $rm, Config $config, VersionParser $parser, VersionGuesser $guesser, IOInterface $io)
  14855. {
  14856. return new Package\Loader\RootPackageLoader($rm, $config, $parser, $guesser, $io);
  14857. }
  14858. public static function create(IOInterface $io, $config = null, $disablePlugins = false)
  14859. {
  14860. $factory = new static();
  14861. return $factory->createComposer($io, $config, $disablePlugins);
  14862. }
  14863. public static function createHttpDownloader(IOInterface $io, Config $config, $options = array())
  14864. {
  14865. static $warned = false;
  14866. $disableTls = false;
  14867. if (isset($_SERVER['argv']) && in_array('disable-tls', $_SERVER['argv']) && (in_array('conf', $_SERVER['argv']) || in_array('config', $_SERVER['argv']))) {
  14868. $warned = true;
  14869. $disableTls = !extension_loaded('openssl');
  14870. } elseif ($config && $config->get('disable-tls') === true) {
  14871. if (!$warned) {
  14872. $io->writeError('<warning>You are running Composer with SSL/TLS protection disabled.</warning>');
  14873. }
  14874. $warned = true;
  14875. $disableTls = true;
  14876. } elseif (!extension_loaded('openssl')) {
  14877. throw new Exception\NoSslException('The openssl extension is required for SSL/TLS protection but is not available. '
  14878. . '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.');
  14879. }
  14880. $httpDownloaderOptions = array();
  14881. if ($disableTls === false) {
  14882. if ($config && $config->get('cafile')) {
  14883. $httpDownloaderOptions['ssl']['cafile'] = $config->get('cafile');
  14884. }
  14885. if ($config && $config->get('capath')) {
  14886. $httpDownloaderOptions['ssl']['capath'] = $config->get('capath');
  14887. }
  14888. $httpDownloaderOptions = array_replace_recursive($httpDownloaderOptions, $options);
  14889. }
  14890. try {
  14891. $httpDownloader = new HttpDownloader($io, $config, $httpDownloaderOptions, $disableTls);
  14892. } catch (TransportException $e) {
  14893. if (false !== strpos($e->getMessage(), 'cafile')) {
  14894. $io->write('<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>');
  14895. $io->write('<error>A valid CA certificate file is required for SSL/TLS protection.</error>');
  14896. if (PHP_VERSION_ID < 50600) {
  14897. $io->write('<error>It is recommended you upgrade to PHP 5.6+ which can detect your system CA file automatically.</error>');
  14898. }
  14899. $io->write('<error>You can disable this error, at your own risk, by setting the \'disable-tls\' option to true.</error>');
  14900. }
  14901. throw $e;
  14902. }
  14903. return $httpDownloader;
  14904. }
  14905. private static function useXdg()
  14906. {
  14907. foreach (array_keys($_SERVER) as $key) {
  14908. if (strpos($key, 'XDG_') === 0) {
  14909. return true;
  14910. }
  14911. }
  14912. if (Silencer::call('is_dir', '/etc/xdg')) {
  14913. return true;
  14914. }
  14915. return false;
  14916. }
  14917. private static function getUserDir()
  14918. {
  14919. $home = getenv('HOME');
  14920. if (!$home) {
  14921. throw new \RuntimeException('The HOME or COMPOSER_HOME environment variable must be set for composer to run correctly');
  14922. }
  14923. return rtrim(strtr($home, '\\', '/'), '/');
  14924. }
  14925. }
  14926. <?php
  14927. namespace Composer\IO;
  14928. use Composer\Config;
  14929. use Composer\Util\ProcessExecutor;
  14930. use Psr\Log\LogLevel;
  14931. abstract class BaseIO implements IOInterface
  14932. {
  14933. protected $authentications = array();
  14934. public function getAuthentications()
  14935. {
  14936. return $this->authentications;
  14937. }
  14938. public function resetAuthentications()
  14939. {
  14940. $this->authentications = array();
  14941. }
  14942. public function hasAuthentication($repositoryName)
  14943. {
  14944. return isset($this->authentications[$repositoryName]);
  14945. }
  14946. public function getAuthentication($repositoryName)
  14947. {
  14948. if (isset($this->authentications[$repositoryName])) {
  14949. return $this->authentications[$repositoryName];
  14950. }
  14951. return array('username' => null, 'password' => null);
  14952. }
  14953. public function setAuthentication($repositoryName, $username, $password = null)
  14954. {
  14955. $this->authentications[$repositoryName] = array('username' => $username, 'password' => $password);
  14956. }
  14957. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  14958. {
  14959. $this->write($messages, $newline, $verbosity);
  14960. }
  14961. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  14962. {
  14963. $this->writeError($messages, $newline, $verbosity);
  14964. }
  14965. protected function checkAndSetAuthentication($repositoryName, $username, $password = null)
  14966. {
  14967. if ($this->hasAuthentication($repositoryName)) {
  14968. $auth = $this->getAuthentication($repositoryName);
  14969. if ($auth['username'] === $username && $auth['password'] === $password) {
  14970. return;
  14971. }
  14972. $this->writeError(
  14973. sprintf(
  14974. "<warning>Warning: You should avoid overwriting already defined auth settings for %s.</warning>",
  14975. $repositoryName
  14976. )
  14977. );
  14978. }
  14979. $this->setAuthentication($repositoryName, $username, $password);
  14980. }
  14981. public function loadConfiguration(Config $config)
  14982. {
  14983. $bitbucketOauth = $config->get('bitbucket-oauth') ?: array();
  14984. $githubOauth = $config->get('github-oauth') ?: array();
  14985. $gitlabOauth = $config->get('gitlab-oauth') ?: array();
  14986. $gitlabToken = $config->get('gitlab-token') ?: array();
  14987. $httpBasic = $config->get('http-basic') ?: array();
  14988. $bearerToken = $config->get('bearer') ?: array();
  14989. foreach ($bitbucketOauth as $domain => $cred) {
  14990. $this->checkAndSetAuthentication($domain, $cred['consumer-key'], $cred['consumer-secret']);
  14991. }
  14992. foreach ($githubOauth as $domain => $token) {
  14993. if (!preg_match('{^[.a-z0-9]+$}', $token)) {
  14994. throw new \UnexpectedValueException('Your github oauth token for '.$domain.' contains invalid characters: "'.$token.'"');
  14995. }
  14996. $this->checkAndSetAuthentication($domain, $token, 'x-oauth-basic');
  14997. }
  14998. foreach ($gitlabOauth as $domain => $token) {
  14999. $this->checkAndSetAuthentication($domain, $token, 'oauth2');
  15000. }
  15001. foreach ($gitlabToken as $domain => $token) {
  15002. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  15003. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  15004. $this->checkAndSetAuthentication($domain, $username, $password);
  15005. }
  15006. foreach ($httpBasic as $domain => $cred) {
  15007. $this->checkAndSetAuthentication($domain, $cred['username'], $cred['password']);
  15008. }
  15009. foreach ($bearerToken as $domain => $token) {
  15010. $this->checkAndSetAuthentication($domain, $token, 'bearer');
  15011. }
  15012. ProcessExecutor::setTimeout((int) $config->get('process-timeout'));
  15013. }
  15014. public function emergency($message, array $context = array())
  15015. {
  15016. return $this->log(LogLevel::EMERGENCY, $message, $context);
  15017. }
  15018. public function alert($message, array $context = array())
  15019. {
  15020. return $this->log(LogLevel::ALERT, $message, $context);
  15021. }
  15022. public function critical($message, array $context = array())
  15023. {
  15024. return $this->log(LogLevel::CRITICAL, $message, $context);
  15025. }
  15026. public function error($message, array $context = array())
  15027. {
  15028. return $this->log(LogLevel::ERROR, $message, $context);
  15029. }
  15030. public function warning($message, array $context = array())
  15031. {
  15032. return $this->log(LogLevel::WARNING, $message, $context);
  15033. }
  15034. public function notice($message, array $context = array())
  15035. {
  15036. return $this->log(LogLevel::NOTICE, $message, $context);
  15037. }
  15038. public function info($message, array $context = array())
  15039. {
  15040. return $this->log(LogLevel::INFO, $message, $context);
  15041. }
  15042. public function debug($message, array $context = array())
  15043. {
  15044. return $this->log(LogLevel::DEBUG, $message, $context);
  15045. }
  15046. public function log($level, $message, array $context = array())
  15047. {
  15048. if (in_array($level, array(LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, LogLevel::ERROR))) {
  15049. $this->writeError('<error>'.$message.'</error>');
  15050. } elseif ($level === LogLevel::WARNING) {
  15051. $this->writeError('<warning>'.$message.'</warning>');
  15052. } elseif ($level === LogLevel::NOTICE) {
  15053. $this->writeError('<info>'.$message.'</info>', true, self::VERBOSE);
  15054. } elseif ($level === LogLevel::INFO) {
  15055. $this->writeError('<info>'.$message.'</info>', true, self::VERY_VERBOSE);
  15056. } else {
  15057. $this->writeError($message, true, self::DEBUG);
  15058. }
  15059. }
  15060. }
  15061. <?php
  15062. namespace Composer\IO;
  15063. use Symfony\Component\Console\Helper\QuestionHelper;
  15064. use Symfony\Component\Console\Output\StreamOutput;
  15065. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  15066. use Symfony\Component\Console\Input\StreamableInputInterface;
  15067. use Symfony\Component\Console\Input\StringInput;
  15068. use Symfony\Component\Console\Helper\HelperSet;
  15069. class BufferIO extends ConsoleIO
  15070. {
  15071. public function __construct($input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null)
  15072. {
  15073. $input = new StringInput($input);
  15074. $input->setInteractive(false);
  15075. $output = new StreamOutput(fopen('php://memory', 'rw'), $verbosity, $formatter ? $formatter->isDecorated() : false, $formatter);
  15076. parent::__construct($input, $output, new HelperSet(array(
  15077. new QuestionHelper(),
  15078. )));
  15079. }
  15080. public function getOutput()
  15081. {
  15082. fseek($this->output->getStream(), 0);
  15083. $output = stream_get_contents($this->output->getStream());
  15084. $output = preg_replace_callback("{(?<=^|\n|\x08)(.+?)(\x08+)}", function ($matches) {
  15085. $pre = strip_tags($matches[1]);
  15086. if (strlen($pre) === strlen($matches[2])) {
  15087. return '';
  15088. }
  15089. return rtrim($matches[1])."\n";
  15090. }, $output);
  15091. return $output;
  15092. }
  15093. public function setUserInputs(array $inputs)
  15094. {
  15095. if (!$this->input instanceof StreamableInputInterface) {
  15096. throw new \RuntimeException('Setting the user inputs requires at least the version 3.2 of the symfony/console component.');
  15097. }
  15098. $this->input->setStream($this->createStream($inputs));
  15099. $this->input->setInteractive(true);
  15100. }
  15101. private function createStream(array $inputs)
  15102. {
  15103. $stream = fopen('php://memory', 'r+');
  15104. foreach ($inputs as $input) {
  15105. fwrite($stream, $input.PHP_EOL);
  15106. }
  15107. rewind($stream);
  15108. return $stream;
  15109. }
  15110. }
  15111. <?php
  15112. namespace Composer\IO;
  15113. use Composer\Question\StrictConfirmationQuestion;
  15114. use Symfony\Component\Console\Helper\HelperSet;
  15115. use Symfony\Component\Console\Helper\ProgressBar;
  15116. use Symfony\Component\Console\Input\InputInterface;
  15117. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  15118. use Symfony\Component\Console\Output\OutputInterface;
  15119. use Symfony\Component\Console\Question\ChoiceQuestion;
  15120. use Symfony\Component\Console\Question\Question;
  15121. class ConsoleIO extends BaseIO
  15122. {
  15123. protected $input;
  15124. protected $output;
  15125. protected $helperSet;
  15126. protected $lastMessage;
  15127. protected $lastMessageErr;
  15128. private $startTime;
  15129. private $verbosityMap;
  15130. public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet)
  15131. {
  15132. $this->input = $input;
  15133. $this->output = $output;
  15134. $this->helperSet = $helperSet;
  15135. $this->verbosityMap = array(
  15136. self::QUIET => OutputInterface::VERBOSITY_QUIET,
  15137. self::NORMAL => OutputInterface::VERBOSITY_NORMAL,
  15138. self::VERBOSE => OutputInterface::VERBOSITY_VERBOSE,
  15139. self::VERY_VERBOSE => OutputInterface::VERBOSITY_VERY_VERBOSE,
  15140. self::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  15141. );
  15142. }
  15143. public function enableDebugging($startTime)
  15144. {
  15145. $this->startTime = $startTime;
  15146. }
  15147. public function isInteractive()
  15148. {
  15149. return $this->input->isInteractive();
  15150. }
  15151. public function isDecorated()
  15152. {
  15153. return $this->output->isDecorated();
  15154. }
  15155. public function isVerbose()
  15156. {
  15157. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE;
  15158. }
  15159. public function isVeryVerbose()
  15160. {
  15161. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_VERY_VERBOSE;
  15162. }
  15163. public function isDebug()
  15164. {
  15165. return $this->output->getVerbosity() >= OutputInterface::VERBOSITY_DEBUG;
  15166. }
  15167. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  15168. {
  15169. $this->doWrite($messages, $newline, false, $verbosity);
  15170. }
  15171. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  15172. {
  15173. $this->doWrite($messages, $newline, true, $verbosity);
  15174. }
  15175. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15176. {
  15177. $this->doWrite($messages, $newline, false, $verbosity, true);
  15178. }
  15179. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL)
  15180. {
  15181. $this->doWrite($messages, $newline, true, $verbosity, true);
  15182. }
  15183. private function doWrite($messages, $newline, $stderr, $verbosity, $raw = false)
  15184. {
  15185. $sfVerbosity = $this->verbosityMap[$verbosity];
  15186. if ($sfVerbosity > $this->output->getVerbosity()) {
  15187. return;
  15188. }
  15189. if (OutputInterface::VERBOSITY_QUIET === 0) {
  15190. $sfVerbosity = OutputInterface::OUTPUT_NORMAL;
  15191. }
  15192. if ($raw) {
  15193. if ($sfVerbosity === OutputInterface::OUTPUT_NORMAL) {
  15194. $sfVerbosity = OutputInterface::OUTPUT_RAW;
  15195. } else {
  15196. $sfVerbosity |= OutputInterface::OUTPUT_RAW;
  15197. }
  15198. }
  15199. if (null !== $this->startTime) {
  15200. $memoryUsage = memory_get_usage() / 1024 / 1024;
  15201. $timeSpent = microtime(true) - $this->startTime;
  15202. $messages = array_map(function ($message) use ($memoryUsage, $timeSpent) {
  15203. return sprintf('[%.1fMiB/%.2fs] %s', $memoryUsage, $timeSpent, $message);
  15204. }, (array) $messages);
  15205. }
  15206. if (true === $stderr && $this->output instanceof ConsoleOutputInterface) {
  15207. $this->output->getErrorOutput()->write($messages, $newline, $sfVerbosity);
  15208. $this->lastMessageErr = implode($newline ? "\n" : '', (array) $messages);
  15209. return;
  15210. }
  15211. $this->output->write($messages, $newline, $sfVerbosity);
  15212. $this->lastMessage = implode($newline ? "\n" : '', (array) $messages);
  15213. }
  15214. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  15215. {
  15216. $this->doOverwrite($messages, $newline, $size, false, $verbosity);
  15217. }
  15218. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL)
  15219. {
  15220. $this->doOverwrite($messages, $newline, $size, true, $verbosity);
  15221. }
  15222. private function doOverwrite($messages, $newline, $size, $stderr, $verbosity)
  15223. {
  15224. $messages = implode($newline ? "\n" : '', (array) $messages);
  15225. if (!isset($size)) {
  15226. $size = strlen(strip_tags($stderr ? $this->lastMessageErr : $this->lastMessage));
  15227. }
  15228. $this->doWrite(str_repeat("\x08", $size), false, $stderr, $verbosity);
  15229. $this->doWrite($messages, false, $stderr, $verbosity);
  15230. $fill = $size - strlen(strip_tags($messages));
  15231. if ($fill > 0) {
  15232. $this->doWrite(str_repeat(' ', $fill), false, $stderr, $verbosity);
  15233. $this->doWrite(str_repeat("\x08", $fill), false, $stderr, $verbosity);
  15234. }
  15235. if ($newline) {
  15236. $this->doWrite('', true, $stderr, $verbosity);
  15237. }
  15238. if ($stderr) {
  15239. $this->lastMessageErr = $messages;
  15240. } else {
  15241. $this->lastMessage = $messages;
  15242. }
  15243. }
  15244. public function getProgressBar($max = 0)
  15245. {
  15246. return new ProgressBar($this->getErrorOutput(), $max);
  15247. }
  15248. public function ask($question, $default = null)
  15249. {
  15250. $helper = $this->helperSet->get('question');
  15251. $question = new Question($question, $default);
  15252. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15253. }
  15254. public function askConfirmation($question, $default = true)
  15255. {
  15256. $helper = $this->helperSet->get('question');
  15257. $question = new StrictConfirmationQuestion($question, $default);
  15258. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15259. }
  15260. public function askAndValidate($question, $validator, $attempts = null, $default = null)
  15261. {
  15262. $helper = $this->helperSet->get('question');
  15263. $question = new Question($question, $default);
  15264. $question->setValidator($validator);
  15265. $question->setMaxAttempts($attempts);
  15266. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15267. }
  15268. public function askAndHideAnswer($question)
  15269. {
  15270. $helper = $this->helperSet->get('question');
  15271. $question = new Question($question);
  15272. $question->setHidden(true);
  15273. return $helper->ask($this->input, $this->getErrorOutput(), $question);
  15274. }
  15275. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  15276. {
  15277. $helper = $this->helperSet->get('question');
  15278. $question = new ChoiceQuestion($question, $choices, $default);
  15279. $question->setMaxAttempts($attempts ?: null);
  15280. $question->setErrorMessage($errorMessage);
  15281. $question->setMultiselect($multiselect);
  15282. $result = $helper->ask($this->input, $this->getErrorOutput(), $question);
  15283. if (!is_array($result)) {
  15284. return (string) array_search($result, $choices, true);
  15285. }
  15286. $results = array();
  15287. foreach ($choices as $index => $choice) {
  15288. if (in_array($choice, $result, true)) {
  15289. $results[] = (string) $index;
  15290. }
  15291. }
  15292. return $results;
  15293. }
  15294. private function getErrorOutput()
  15295. {
  15296. if ($this->output instanceof ConsoleOutputInterface) {
  15297. return $this->output->getErrorOutput();
  15298. }
  15299. return $this->output;
  15300. }
  15301. }
  15302. <?php
  15303. namespace Composer\IO;
  15304. use Composer\Config;
  15305. use Psr\Log\LoggerInterface;
  15306. interface IOInterface extends LoggerInterface
  15307. {
  15308. const QUIET = 1;
  15309. const NORMAL = 2;
  15310. const VERBOSE = 4;
  15311. const VERY_VERBOSE = 8;
  15312. const DEBUG = 16;
  15313. public function isInteractive();
  15314. public function isVerbose();
  15315. public function isVeryVerbose();
  15316. public function isDebug();
  15317. public function isDecorated();
  15318. public function write($messages, $newline = true, $verbosity = self::NORMAL);
  15319. public function writeError($messages, $newline = true, $verbosity = self::NORMAL);
  15320. public function writeRaw($messages, $newline = true, $verbosity = self::NORMAL);
  15321. public function writeErrorRaw($messages, $newline = true, $verbosity = self::NORMAL);
  15322. public function overwrite($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  15323. public function overwriteError($messages, $newline = true, $size = null, $verbosity = self::NORMAL);
  15324. public function ask($question, $default = null);
  15325. public function askConfirmation($question, $default = true);
  15326. public function askAndValidate($question, $validator, $attempts = null, $default = null);
  15327. public function askAndHideAnswer($question);
  15328. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false);
  15329. public function getAuthentications();
  15330. public function hasAuthentication($repositoryName);
  15331. public function getAuthentication($repositoryName);
  15332. public function setAuthentication($repositoryName, $username, $password = null);
  15333. public function loadConfiguration(Config $config);
  15334. }
  15335. <?php
  15336. namespace Composer\IO;
  15337. class NullIO extends BaseIO
  15338. {
  15339. public function isInteractive()
  15340. {
  15341. return false;
  15342. }
  15343. public function isVerbose()
  15344. {
  15345. return false;
  15346. }
  15347. public function isVeryVerbose()
  15348. {
  15349. return false;
  15350. }
  15351. public function isDebug()
  15352. {
  15353. return false;
  15354. }
  15355. public function isDecorated()
  15356. {
  15357. return false;
  15358. }
  15359. public function write($messages, $newline = true, $verbosity = self::NORMAL)
  15360. {
  15361. }
  15362. public function writeError($messages, $newline = true, $verbosity = self::NORMAL)
  15363. {
  15364. }
  15365. public function overwrite($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  15366. {
  15367. }
  15368. public function overwriteError($messages, $newline = true, $size = 80, $verbosity = self::NORMAL)
  15369. {
  15370. }
  15371. public function ask($question, $default = null)
  15372. {
  15373. return $default;
  15374. }
  15375. public function askConfirmation($question, $default = true)
  15376. {
  15377. return $default;
  15378. }
  15379. public function askAndValidate($question, $validator, $attempts = false, $default = null)
  15380. {
  15381. return $default;
  15382. }
  15383. public function askAndHideAnswer($question)
  15384. {
  15385. return null;
  15386. }
  15387. public function select($question, $choices, $default, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  15388. {
  15389. return $default;
  15390. }
  15391. }
  15392. <?php
  15393. namespace Composer;
  15394. use Composer\Autoload\ClassLoader;
  15395. use Composer\Semver\VersionParser;
  15396. class InstalledVersions
  15397. {
  15398. private static $installed;
  15399. private static $canGetVendors;
  15400. private static $installedByVendor = array();
  15401. public static function getInstalledPackages()
  15402. {
  15403. $packages = array();
  15404. foreach (self::getInstalled() as $installed) {
  15405. $packages[] = array_keys($installed['versions']);
  15406. }
  15407. if (1 === \count($packages)) {
  15408. return $packages[0];
  15409. }
  15410. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  15411. }
  15412. public static function isInstalled($packageName)
  15413. {
  15414. foreach (self::getInstalled() as $installed) {
  15415. if (isset($installed['versions'][$packageName])) {
  15416. return true;
  15417. }
  15418. }
  15419. return false;
  15420. }
  15421. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  15422. {
  15423. $constraint = $parser->parseConstraints($constraint);
  15424. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  15425. return $provided->matches($constraint);
  15426. }
  15427. public static function getVersionRanges($packageName)
  15428. {
  15429. foreach (self::getInstalled() as $installed) {
  15430. if (!isset($installed['versions'][$packageName])) {
  15431. continue;
  15432. }
  15433. $ranges = array();
  15434. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  15435. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  15436. }
  15437. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  15438. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  15439. }
  15440. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  15441. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  15442. }
  15443. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  15444. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  15445. }
  15446. return implode(' || ', $ranges);
  15447. }
  15448. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15449. }
  15450. public static function getVersion($packageName)
  15451. {
  15452. foreach (self::getInstalled() as $installed) {
  15453. if (!isset($installed['versions'][$packageName])) {
  15454. continue;
  15455. }
  15456. if (!isset($installed['versions'][$packageName]['version'])) {
  15457. return null;
  15458. }
  15459. return $installed['versions'][$packageName]['version'];
  15460. }
  15461. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15462. }
  15463. public static function getPrettyVersion($packageName)
  15464. {
  15465. foreach (self::getInstalled() as $installed) {
  15466. if (!isset($installed['versions'][$packageName])) {
  15467. continue;
  15468. }
  15469. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  15470. return null;
  15471. }
  15472. return $installed['versions'][$packageName]['pretty_version'];
  15473. }
  15474. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15475. }
  15476. public static function getReference($packageName)
  15477. {
  15478. foreach (self::getInstalled() as $installed) {
  15479. if (!isset($installed['versions'][$packageName])) {
  15480. continue;
  15481. }
  15482. if (!isset($installed['versions'][$packageName]['reference'])) {
  15483. return null;
  15484. }
  15485. return $installed['versions'][$packageName]['reference'];
  15486. }
  15487. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  15488. }
  15489. public static function getRootPackage()
  15490. {
  15491. $installed = self::getInstalled();
  15492. return $installed[0]['root'];
  15493. }
  15494. public static function getRawData()
  15495. {
  15496. return self::$installed;
  15497. }
  15498. public static function reload($data)
  15499. {
  15500. self::$installed = $data;
  15501. self::$installedByVendor = array();
  15502. }
  15503. private static function getInstalled()
  15504. {
  15505. if (null === self::$canGetVendors) {
  15506. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  15507. }
  15508. $installed = array();
  15509. if (self::$canGetVendors) {
  15510. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  15511. if (isset(self::$installedByVendor[$vendorDir])) {
  15512. $installed[] = self::$installedByVendor[$vendorDir];
  15513. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  15514. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  15515. }
  15516. }
  15517. }
  15518. $installed[] = self::$installed;
  15519. return $installed;
  15520. }
  15521. }
  15522. <?php
  15523. namespace Composer;
  15524. use Composer\Autoload\AutoloadGenerator;
  15525. use Composer\Console\GithubActionError;
  15526. use Composer\DependencyResolver\DefaultPolicy;
  15527. use Composer\DependencyResolver\LocalRepoTransaction;
  15528. use Composer\DependencyResolver\LockTransaction;
  15529. use Composer\DependencyResolver\Operation\UpdateOperation;
  15530. use Composer\DependencyResolver\Operation\InstallOperation;
  15531. use Composer\DependencyResolver\Operation\UninstallOperation;
  15532. use Composer\DependencyResolver\Pool;
  15533. use Composer\DependencyResolver\Request;
  15534. use Composer\DependencyResolver\Solver;
  15535. use Composer\DependencyResolver\SolverProblemsException;
  15536. use Composer\DependencyResolver\PolicyInterface;
  15537. use Composer\Downloader\DownloadManager;
  15538. use Composer\EventDispatcher\EventDispatcher;
  15539. use Composer\Installer\InstallationManager;
  15540. use Composer\Installer\InstallerEvents;
  15541. use Composer\Installer\SuggestedPackagesReporter;
  15542. use Composer\IO\IOInterface;
  15543. use Composer\Package\AliasPackage;
  15544. use Composer\Package\RootAliasPackage;
  15545. use Composer\Package\BasePackage;
  15546. use Composer\Package\CompletePackage;
  15547. use Composer\Package\CompletePackageInterface;
  15548. use Composer\Package\Link;
  15549. use Composer\Package\Loader\ArrayLoader;
  15550. use Composer\Package\Dumper\ArrayDumper;
  15551. use Composer\Package\Version\VersionParser;
  15552. use Composer\Package\Package;
  15553. use Composer\Repository\ArrayRepository;
  15554. use Composer\Repository\RepositorySet;
  15555. use Composer\Repository\CompositeRepository;
  15556. use Composer\Semver\Constraint\Constraint;
  15557. use Composer\Package\Locker;
  15558. use Composer\Package\RootPackageInterface;
  15559. use Composer\Repository\InstalledArrayRepository;
  15560. use Composer\Repository\InstalledRepositoryInterface;
  15561. use Composer\Repository\InstalledRepository;
  15562. use Composer\Repository\FilterRepository;
  15563. use Composer\Repository\RootPackageRepository;
  15564. use Composer\Repository\PlatformRepository;
  15565. use Composer\Repository\RepositoryInterface;
  15566. use Composer\Repository\RepositoryManager;
  15567. use Composer\Repository\LockArrayRepository;
  15568. use Composer\Script\ScriptEvents;
  15569. class Installer
  15570. {
  15571. protected $io;
  15572. protected $config;
  15573. protected $package;
  15574. protected $fixedRootPackage;
  15575. protected $downloadManager;
  15576. protected $repositoryManager;
  15577. protected $locker;
  15578. protected $installationManager;
  15579. protected $eventDispatcher;
  15580. protected $autoloadGenerator;
  15581. protected $preferSource = false;
  15582. protected $preferDist = false;
  15583. protected $optimizeAutoloader = false;
  15584. protected $classMapAuthoritative = false;
  15585. protected $apcuAutoloader = false;
  15586. protected $apcuAutoloaderPrefix;
  15587. protected $devMode = false;
  15588. protected $dryRun = false;
  15589. protected $verbose = false;
  15590. protected $update = false;
  15591. protected $install = true;
  15592. protected $dumpAutoloader = true;
  15593. protected $runScripts = true;
  15594. protected $ignorePlatformReqs = false;
  15595. protected $preferStable = false;
  15596. protected $preferLowest = false;
  15597. protected $writeLock;
  15598. protected $executeOperations = true;
  15599. protected $updateMirrors = false;
  15600. protected $updateAllowList;
  15601. protected $updateAllowTransitiveDependencies = Request::UPDATE_ONLY_LISTED;
  15602. protected $suggestedPackagesReporter;
  15603. protected $additionalFixedRepository;
  15604. public function __construct(IOInterface $io, Config $config, RootPackageInterface $package, DownloadManager $downloadManager, RepositoryManager $repositoryManager, Locker $locker, InstallationManager $installationManager, EventDispatcher $eventDispatcher, AutoloadGenerator $autoloadGenerator)
  15605. {
  15606. $this->io = $io;
  15607. $this->config = $config;
  15608. $this->package = $package;
  15609. $this->downloadManager = $downloadManager;
  15610. $this->repositoryManager = $repositoryManager;
  15611. $this->locker = $locker;
  15612. $this->installationManager = $installationManager;
  15613. $this->eventDispatcher = $eventDispatcher;
  15614. $this->autoloadGenerator = $autoloadGenerator;
  15615. $this->writeLock = $config->get('lock');
  15616. }
  15617. public function run()
  15618. {
  15619. gc_collect_cycles();
  15620. gc_disable();
  15621. if ($this->updateAllowList && $this->updateMirrors) {
  15622. throw new \RuntimeException("The installer options updateMirrors and updateAllowList are mutually exclusive.");
  15623. }
  15624. $isFreshInstall = $this->repositoryManager->getLocalRepository()->isFresh();
  15625. if (!$this->update && !$this->locker->isLocked()) {
  15626. $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>');
  15627. $this->update = true;
  15628. }
  15629. if ($this->dryRun) {
  15630. $this->verbose = true;
  15631. $this->runScripts = false;
  15632. $this->executeOperations = false;
  15633. $this->writeLock = false;
  15634. $this->dumpAutoloader = false;
  15635. $this->mockLocalRepositories($this->repositoryManager);
  15636. }
  15637. if ($this->update && !$this->install) {
  15638. $this->dumpAutoloader = false;
  15639. }
  15640. if ($this->runScripts) {
  15641. $_SERVER['COMPOSER_DEV_MODE'] = $this->devMode ? '1' : '0';
  15642. putenv('COMPOSER_DEV_MODE='.$_SERVER['COMPOSER_DEV_MODE']);
  15643. $eventName = $this->update ? ScriptEvents::PRE_UPDATE_CMD : ScriptEvents::PRE_INSTALL_CMD;
  15644. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  15645. }
  15646. $this->downloadManager->setPreferSource($this->preferSource);
  15647. $this->downloadManager->setPreferDist($this->preferDist);
  15648. $localRepo = $this->repositoryManager->getLocalRepository();
  15649. if (!$this->suggestedPackagesReporter) {
  15650. $this->suggestedPackagesReporter = new SuggestedPackagesReporter($this->io);
  15651. }
  15652. try {
  15653. if ($this->update) {
  15654. $res = $this->doUpdate($localRepo, $this->install);
  15655. } else {
  15656. $res = $this->doInstall($localRepo);
  15657. }
  15658. if ($res !== 0) {
  15659. return $res;
  15660. }
  15661. } catch (\Exception $e) {
  15662. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  15663. $this->installationManager->notifyInstalls($this->io);
  15664. }
  15665. throw $e;
  15666. }
  15667. if ($this->executeOperations && $this->install && $this->config->get('notify-on-install')) {
  15668. $this->installationManager->notifyInstalls($this->io);
  15669. }
  15670. if ($this->update) {
  15671. $installedRepo = new InstalledRepository(array(
  15672. $this->locker->getLockedRepository($this->devMode),
  15673. $this->createPlatformRepo(false),
  15674. new RootPackageRepository(clone $this->package),
  15675. ));
  15676. if ($isFreshInstall) {
  15677. $this->suggestedPackagesReporter->addSuggestionsFromPackage($this->package);
  15678. }
  15679. $this->suggestedPackagesReporter->outputMinimalistic($installedRepo);
  15680. }
  15681. $lockedRepository = $this->locker->getLockedRepository(true);
  15682. foreach ($lockedRepository->getPackages() as $package) {
  15683. if (!$package instanceof CompletePackage || !$package->isAbandoned()) {
  15684. continue;
  15685. }
  15686. $replacement = is_string($package->getReplacementPackage())
  15687. ? 'Use ' . $package->getReplacementPackage() . ' instead'
  15688. : 'No replacement was suggested';
  15689. $this->io->writeError(
  15690. sprintf(
  15691. "<warning>Package %s is abandoned, you should avoid using it. %s.</warning>",
  15692. $package->getPrettyName(),
  15693. $replacement
  15694. )
  15695. );
  15696. }
  15697. if ($this->dumpAutoloader) {
  15698. if ($this->optimizeAutoloader) {
  15699. $this->io->writeError('<info>Generating optimized autoload files</info>');
  15700. } else {
  15701. $this->io->writeError('<info>Generating autoload files</info>');
  15702. }
  15703. $this->autoloadGenerator->setDevMode($this->devMode);
  15704. $this->autoloadGenerator->setClassMapAuthoritative($this->classMapAuthoritative);
  15705. $this->autoloadGenerator->setApcu($this->apcuAutoloader, $this->apcuAutoloaderPrefix);
  15706. $this->autoloadGenerator->setRunScripts($this->runScripts);
  15707. $this->autoloadGenerator->setIgnorePlatformRequirements($this->ignorePlatformReqs);
  15708. $this->autoloadGenerator->dump($this->config, $localRepo, $this->package, $this->installationManager, 'composer', $this->optimizeAutoloader);
  15709. }
  15710. if ($this->install && $this->executeOperations) {
  15711. foreach ($localRepo->getPackages() as $package) {
  15712. $this->installationManager->ensureBinariesPresence($package);
  15713. }
  15714. }
  15715. $fundingCount = 0;
  15716. foreach ($localRepo->getPackages() as $package) {
  15717. if ($package instanceof CompletePackageInterface && !$package instanceof AliasPackage && $package->getFunding()) {
  15718. $fundingCount++;
  15719. }
  15720. }
  15721. if ($fundingCount) {
  15722. $this->io->writeError(array(
  15723. sprintf(
  15724. "<info>%d package%s you are using %s looking for funding.</info>",
  15725. $fundingCount,
  15726. 1 === $fundingCount ? '' : 's',
  15727. 1 === $fundingCount ? 'is' : 'are'
  15728. ),
  15729. '<info>Use the `composer fund` command to find out more!</info>',
  15730. ));
  15731. }
  15732. if ($this->runScripts) {
  15733. $eventName = $this->update ? ScriptEvents::POST_UPDATE_CMD : ScriptEvents::POST_INSTALL_CMD;
  15734. $this->eventDispatcher->dispatchScript($eventName, $this->devMode);
  15735. }
  15736. if (!defined('HHVM_VERSION')) {
  15737. gc_enable();
  15738. }
  15739. return 0;
  15740. }
  15741. protected function doUpdate(InstalledRepositoryInterface $localRepo, $doInstall)
  15742. {
  15743. $platformRepo = $this->createPlatformRepo(true);
  15744. $aliases = $this->getRootAliases(true);
  15745. $lockedRepository = null;
  15746. try {
  15747. if ($this->locker->isLocked()) {
  15748. $lockedRepository = $this->locker->getLockedRepository(true);
  15749. }
  15750. } catch (\Seld\JsonLint\ParsingException $e) {
  15751. if ($this->updateAllowList || $this->updateMirrors) {
  15752. throw $e;
  15753. }
  15754. }
  15755. if (($this->updateAllowList || $this->updateMirrors) && !$lockedRepository) {
  15756. $this->io->writeError('<error>Cannot update ' . ($this->updateMirrors ? 'lock file information' : 'only a partial set of packages') . ' without a lock file present. Run `composer update` to generate a lock file.</error>', true, IOInterface::QUIET);
  15757. return 1;
  15758. }
  15759. $this->io->writeError('<info>Loading composer repositories with package information</info>');
  15760. $policy = $this->createPolicy(true);
  15761. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  15762. $repositories = $this->repositoryManager->getRepositories();
  15763. foreach ($repositories as $repository) {
  15764. $repositorySet->addRepository($repository);
  15765. }
  15766. if ($lockedRepository) {
  15767. $repositorySet->addRepository($lockedRepository);
  15768. }
  15769. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  15770. $this->requirePackagesForUpdate($request, $lockedRepository, true);
  15771. if ($this->updateAllowList) {
  15772. $request->setUpdateAllowList($this->updateAllowList, $this->updateAllowTransitiveDependencies);
  15773. }
  15774. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  15775. $this->io->writeError('<info>Updating dependencies</info>');
  15776. $solver = new Solver($policy, $pool, $this->io);
  15777. try {
  15778. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15779. $ruleSetSize = $solver->getRuleSetSize();
  15780. $solver = null;
  15781. } catch (SolverProblemsException $e) {
  15782. $err = 'Your requirements could not be resolved to an installable set of packages.';
  15783. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  15784. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15785. $this->io->writeError($prettyProblem);
  15786. if (!$this->devMode) {
  15787. $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);
  15788. }
  15789. $ghe = new GithubActionError($this->io);
  15790. $ghe->emit($err."\n".$prettyProblem);
  15791. return max(1, $e->getCode());
  15792. }
  15793. $this->io->writeError("Analyzed ".count($pool)." packages to resolve dependencies", true, IOInterface::VERBOSE);
  15794. $this->io->writeError("Analyzed ".$ruleSetSize." rules to resolve dependencies", true, IOInterface::VERBOSE);
  15795. if (!$lockTransaction->getOperations()) {
  15796. $this->io->writeError('Nothing to modify in lock file');
  15797. }
  15798. $exitCode = $this->extractDevPackages($lockTransaction, $platformRepo, $aliases, $policy, $lockedRepository);
  15799. if ($exitCode !== 0) {
  15800. return $exitCode;
  15801. }
  15802. $platformReqs = $this->extractPlatformRequirements($this->package->getRequires());
  15803. $platformDevReqs = $this->extractPlatformRequirements($this->package->getDevRequires());
  15804. $installsUpdates = $uninstalls = array();
  15805. if ($lockTransaction->getOperations()) {
  15806. $installNames = $updateNames = $uninstallNames = array();
  15807. foreach ($lockTransaction->getOperations() as $operation) {
  15808. if ($operation instanceof InstallOperation) {
  15809. $installsUpdates[] = $operation;
  15810. $installNames[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  15811. } elseif ($operation instanceof UpdateOperation) {
  15812. $installsUpdates[] = $operation;
  15813. $updateNames[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  15814. } elseif ($operation instanceof UninstallOperation) {
  15815. $uninstalls[] = $operation;
  15816. $uninstallNames[] = $operation->getPackage()->getPrettyName();
  15817. }
  15818. }
  15819. $this->io->writeError(sprintf(
  15820. "<info>Lock file operations: %d install%s, %d update%s, %d removal%s</info>",
  15821. count($installNames),
  15822. 1 === count($installNames) ? '' : 's',
  15823. count($updateNames),
  15824. 1 === count($updateNames) ? '' : 's',
  15825. count($uninstalls),
  15826. 1 === count($uninstalls) ? '' : 's'
  15827. ));
  15828. if ($installNames) {
  15829. $this->io->writeError("Installs: ".implode(', ', $installNames), true, IOInterface::VERBOSE);
  15830. }
  15831. if ($updateNames) {
  15832. $this->io->writeError("Updates: ".implode(', ', $updateNames), true, IOInterface::VERBOSE);
  15833. }
  15834. if ($uninstalls) {
  15835. $this->io->writeError("Removals: ".implode(', ', $uninstallNames), true, IOInterface::VERBOSE);
  15836. }
  15837. }
  15838. $sortByName = function ($a, $b) {
  15839. if ($a instanceof UpdateOperation) {
  15840. $a = $a->getTargetPackage()->getName();
  15841. } else {
  15842. $a = $a->getPackage()->getName();
  15843. }
  15844. if ($b instanceof UpdateOperation) {
  15845. $b = $b->getTargetPackage()->getName();
  15846. } else {
  15847. $b = $b->getPackage()->getName();
  15848. }
  15849. return strcmp($a, $b);
  15850. };
  15851. usort($uninstalls, $sortByName);
  15852. usort($installsUpdates, $sortByName);
  15853. foreach (array_merge($uninstalls, $installsUpdates) as $operation) {
  15854. if ($operation instanceof InstallOperation) {
  15855. $this->suggestedPackagesReporter->addSuggestionsFromPackage($operation->getPackage());
  15856. }
  15857. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  15858. $this->io->writeError(' - ' . $operation->show(true));
  15859. }
  15860. }
  15861. $updatedLock = $this->locker->setLockData(
  15862. $lockTransaction->getNewLockPackages(false, $this->updateMirrors),
  15863. $lockTransaction->getNewLockPackages(true, $this->updateMirrors),
  15864. $platformReqs,
  15865. $platformDevReqs,
  15866. $lockTransaction->getAliases($aliases),
  15867. $this->package->getMinimumStability(),
  15868. $this->package->getStabilityFlags(),
  15869. $this->preferStable || $this->package->getPreferStable(),
  15870. $this->preferLowest,
  15871. $this->config->get('platform') ?: array(),
  15872. $this->writeLock && $this->executeOperations
  15873. );
  15874. if ($updatedLock && $this->writeLock && $this->executeOperations) {
  15875. $this->io->writeError('<info>Writing lock file</info>');
  15876. }
  15877. if ($this->executeOperations && count($lockTransaction->getOperations()) > 0) {
  15878. $vendorDir = $this->config->get('vendor-dir');
  15879. if (is_dir($vendorDir)) {
  15880. @touch($vendorDir);
  15881. }
  15882. }
  15883. if ($doInstall) {
  15884. return $this->doInstall($localRepo, true);
  15885. }
  15886. return 0;
  15887. }
  15888. protected function extractDevPackages(LockTransaction $lockTransaction, PlatformRepository $platformRepo, array $aliases, PolicyInterface $policy, LockArrayRepository $lockedRepository = null)
  15889. {
  15890. if (!$this->package->getDevRequires()) {
  15891. return 0;
  15892. }
  15893. $resultRepo = new ArrayRepository(array());
  15894. $loader = new ArrayLoader(null, true);
  15895. $dumper = new ArrayDumper();
  15896. foreach ($lockTransaction->getNewLockPackages(false) as $pkg) {
  15897. $resultRepo->addPackage($loader->load($dumper->dump($pkg)));
  15898. }
  15899. $repositorySet = $this->createRepositorySet(true, $platformRepo, $aliases);
  15900. $repositorySet->addRepository($resultRepo);
  15901. $request = $this->createRequest($this->fixedRootPackage, $platformRepo);
  15902. $this->requirePackagesForUpdate($request, $lockedRepository, false);
  15903. $pool = $repositorySet->createPoolWithAllPackages();
  15904. $solver = new Solver($policy, $pool, $this->io);
  15905. try {
  15906. $nonDevLockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15907. $solver = null;
  15908. } catch (SolverProblemsException $e) {
  15909. $err = 'Unable to find a compatible set of packages based on your non-dev requirements alone.';
  15910. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose(), true);
  15911. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15912. $this->io->writeError('Your requirements can be resolved successfully when require-dev packages are present.');
  15913. $this->io->writeError('You may need to move packages from require-dev or some of their dependencies to require.');
  15914. $this->io->writeError($prettyProblem);
  15915. $ghe = new GithubActionError($this->io);
  15916. $ghe->emit($err."\n".$prettyProblem);
  15917. return max(1, $e->getCode());
  15918. }
  15919. $lockTransaction->setNonDevPackages($nonDevLockTransaction);
  15920. return 0;
  15921. }
  15922. protected function doInstall(InstalledRepositoryInterface $localRepo, $alreadySolved = false)
  15923. {
  15924. $this->io->writeError('<info>Installing dependencies from lock file'.($this->devMode ? ' (including require-dev)' : '').'</info>');
  15925. $lockedRepository = $this->locker->getLockedRepository($this->devMode);
  15926. if (!$alreadySolved) {
  15927. $this->io->writeError('<info>Verifying lock file contents can be installed on current platform.</info>');
  15928. $platformRepo = $this->createPlatformRepo(false);
  15929. $policy = $this->createPolicy(false);
  15930. $repositorySet = $this->createRepositorySet(false, $platformRepo, array(), $lockedRepository);
  15931. $repositorySet->addRepository($lockedRepository);
  15932. $request = $this->createRequest($this->fixedRootPackage, $platformRepo, $lockedRepository);
  15933. if (!$this->locker->isFresh()) {
  15934. $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);
  15935. }
  15936. foreach ($lockedRepository->getPackages() as $package) {
  15937. $request->fixLockedPackage($package);
  15938. }
  15939. foreach ($this->locker->getPlatformRequirements($this->devMode) as $link) {
  15940. $request->requireName($link->getTarget(), $link->getConstraint());
  15941. }
  15942. $pool = $repositorySet->createPool($request, $this->io, $this->eventDispatcher);
  15943. $solver = new Solver($policy, $pool, $this->io);
  15944. try {
  15945. $lockTransaction = $solver->solve($request, $this->ignorePlatformReqs);
  15946. $solver = null;
  15947. if (0 !== count($lockTransaction->getOperations())) {
  15948. $this->io->writeError('<error>Your lock file cannot be installed on this system without changes. Please run composer update.</error>', true, IOInterface::QUIET);
  15949. return 1;
  15950. }
  15951. } catch (SolverProblemsException $e) {
  15952. $err = 'Your lock file does not contain a compatible set of packages. Please run composer update.';
  15953. $prettyProblem = $e->getPrettyString($repositorySet, $request, $pool, $this->io->isVerbose());
  15954. $this->io->writeError('<error>'. $err .'</error>', true, IOInterface::QUIET);
  15955. $this->io->writeError($prettyProblem);
  15956. $ghe = new GithubActionError($this->io);
  15957. $ghe->emit($err."\n".$prettyProblem);
  15958. return max(1, $e->getCode());
  15959. }
  15960. }
  15961. $localRepoTransaction = new LocalRepoTransaction($lockedRepository, $localRepo);
  15962. $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_OPERATIONS_EXEC, $this->devMode, $this->executeOperations, $localRepoTransaction);
  15963. if (!$localRepoTransaction->getOperations()) {
  15964. $this->io->writeError('Nothing to install, update or remove');
  15965. }
  15966. if ($localRepoTransaction->getOperations()) {
  15967. $installs = $updates = $uninstalls = array();
  15968. foreach ($localRepoTransaction->getOperations() as $operation) {
  15969. if ($operation instanceof InstallOperation) {
  15970. $installs[] = $operation->getPackage()->getPrettyName().':'.$operation->getPackage()->getFullPrettyVersion();
  15971. } elseif ($operation instanceof UpdateOperation) {
  15972. $updates[] = $operation->getTargetPackage()->getPrettyName().':'.$operation->getTargetPackage()->getFullPrettyVersion();
  15973. } elseif ($operation instanceof UninstallOperation) {
  15974. $uninstalls[] = $operation->getPackage()->getPrettyName();
  15975. }
  15976. }
  15977. $this->io->writeError(sprintf(
  15978. "<info>Package operations: %d install%s, %d update%s, %d removal%s</info>",
  15979. count($installs),
  15980. 1 === count($installs) ? '' : 's',
  15981. count($updates),
  15982. 1 === count($updates) ? '' : 's',
  15983. count($uninstalls),
  15984. 1 === count($uninstalls) ? '' : 's'
  15985. ));
  15986. if ($installs) {
  15987. $this->io->writeError("Installs: ".implode(', ', $installs), true, IOInterface::VERBOSE);
  15988. }
  15989. if ($updates) {
  15990. $this->io->writeError("Updates: ".implode(', ', $updates), true, IOInterface::VERBOSE);
  15991. }
  15992. if ($uninstalls) {
  15993. $this->io->writeError("Removals: ".implode(', ', $uninstalls), true, IOInterface::VERBOSE);
  15994. }
  15995. }
  15996. if ($this->executeOperations) {
  15997. $localRepo->setDevPackageNames($this->locker->getDevPackageNames());
  15998. $this->installationManager->execute($localRepo, $localRepoTransaction->getOperations(), $this->devMode, $this->runScripts);
  15999. } else {
  16000. foreach ($localRepoTransaction->getOperations() as $operation) {
  16001. if (false === strpos($operation->getOperationType(), 'Alias') || $this->io->isDebug()) {
  16002. $this->io->writeError(' - ' . $operation->show(false));
  16003. }
  16004. }
  16005. }
  16006. return 0;
  16007. }
  16008. private function createPlatformRepo($forUpdate)
  16009. {
  16010. if ($forUpdate) {
  16011. $platformOverrides = $this->config->get('platform') ?: array();
  16012. } else {
  16013. $platformOverrides = $this->locker->getPlatformOverrides();
  16014. }
  16015. return new PlatformRepository(array(), $platformOverrides);
  16016. }
  16017. private function createRepositorySet($forUpdate, PlatformRepository $platformRepo, array $rootAliases = array(), $lockedRepository = null)
  16018. {
  16019. if ($forUpdate) {
  16020. $minimumStability = $this->package->getMinimumStability();
  16021. $stabilityFlags = $this->package->getStabilityFlags();
  16022. $requires = array_merge($this->package->getRequires(), $this->package->getDevRequires());
  16023. } else {
  16024. $minimumStability = $this->locker->getMinimumStability();
  16025. $stabilityFlags = $this->locker->getStabilityFlags();
  16026. $requires = array();
  16027. foreach ($lockedRepository->getPackages() as $package) {
  16028. $constraint = new Constraint('=', $package->getVersion());
  16029. $constraint->setPrettyString($package->getPrettyVersion());
  16030. $requires[$package->getName()] = $constraint;
  16031. }
  16032. }
  16033. $rootRequires = array();
  16034. foreach ($requires as $req => $constraint) {
  16035. if ((true === $this->ignorePlatformReqs || (is_array($this->ignorePlatformReqs) && in_array($req, $this->ignorePlatformReqs, true))) && PlatformRepository::isPlatformPackage($req)) {
  16036. continue;
  16037. }
  16038. if ($constraint instanceof Link) {
  16039. $rootRequires[$req] = $constraint->getConstraint();
  16040. } else {
  16041. $rootRequires[$req] = $constraint;
  16042. }
  16043. }
  16044. $this->fixedRootPackage = clone $this->package;
  16045. $this->fixedRootPackage->setRequires(array());
  16046. $this->fixedRootPackage->setDevRequires(array());
  16047. $stabilityFlags[$this->package->getName()] = BasePackage::$stabilities[VersionParser::parseStability($this->package->getVersion())];
  16048. $repositorySet = new RepositorySet($minimumStability, $stabilityFlags, $rootAliases, $this->package->getReferences(), $rootRequires);
  16049. $repositorySet->addRepository(new RootPackageRepository($this->fixedRootPackage));
  16050. $repositorySet->addRepository($platformRepo);
  16051. if ($this->additionalFixedRepository) {
  16052. $additionalFixedRepositories = $this->additionalFixedRepository;
  16053. if ($additionalFixedRepositories instanceof CompositeRepository) {
  16054. $additionalFixedRepositories = $additionalFixedRepositories->getRepositories();
  16055. } else {
  16056. $additionalFixedRepositories = array($additionalFixedRepositories);
  16057. }
  16058. foreach ($additionalFixedRepositories as $additionalFixedRepository) {
  16059. if ($additionalFixedRepository instanceof InstalledRepository || $additionalFixedRepository instanceof InstalledRepositoryInterface) {
  16060. $repositorySet->allowInstalledRepositories();
  16061. break;
  16062. }
  16063. }
  16064. $repositorySet->addRepository($this->additionalFixedRepository);
  16065. }
  16066. return $repositorySet;
  16067. }
  16068. private function createPolicy($forUpdate)
  16069. {
  16070. $preferStable = null;
  16071. $preferLowest = null;
  16072. if (!$forUpdate) {
  16073. $preferStable = $this->locker->getPreferStable();
  16074. $preferLowest = $this->locker->getPreferLowest();
  16075. }
  16076. if (null === $preferStable) {
  16077. $preferStable = $this->preferStable || $this->package->getPreferStable();
  16078. }
  16079. if (null === $preferLowest) {
  16080. $preferLowest = $this->preferLowest;
  16081. }
  16082. return new DefaultPolicy($preferStable, $preferLowest);
  16083. }
  16084. private function createRequest(RootPackageInterface $rootPackage, PlatformRepository $platformRepo, LockArrayRepository $lockedRepository = null)
  16085. {
  16086. $request = new Request($lockedRepository);
  16087. $request->fixPackage($rootPackage);
  16088. if ($rootPackage instanceof RootAliasPackage) {
  16089. $request->fixPackage($rootPackage->getAliasOf());
  16090. }
  16091. $fixedPackages = $platformRepo->getPackages();
  16092. if ($this->additionalFixedRepository) {
  16093. $fixedPackages = array_merge($fixedPackages, $this->additionalFixedRepository->getPackages());
  16094. }
  16095. $provided = $rootPackage->getProvides();
  16096. foreach ($fixedPackages as $package) {
  16097. if ($package->getRepository() !== $platformRepo
  16098. || !isset($provided[$package->getName()])
  16099. || !$provided[$package->getName()]->getConstraint()->matches(new Constraint('=', $package->getVersion()))
  16100. ) {
  16101. $request->fixPackage($package);
  16102. }
  16103. }
  16104. return $request;
  16105. }
  16106. private function requirePackagesForUpdate(Request $request, LockArrayRepository $lockedRepository = null, $includeDevRequires = true)
  16107. {
  16108. if ($this->updateMirrors) {
  16109. $excludedPackages = array();
  16110. if (!$includeDevRequires) {
  16111. $excludedPackages = array_flip($this->locker->getDevPackageNames());
  16112. }
  16113. foreach ($lockedRepository->getPackages() as $lockedPackage) {
  16114. if (!$lockedPackage instanceof AliasPackage && !isset($excludedPackages[$lockedPackage->getName()])) {
  16115. $request->requireName($lockedPackage->getName(), new Constraint('==', $lockedPackage->getVersion()));
  16116. }
  16117. }
  16118. } else {
  16119. $links = $this->package->getRequires();
  16120. if ($includeDevRequires) {
  16121. $links = array_merge($links, $this->package->getDevRequires());
  16122. }
  16123. foreach ($links as $link) {
  16124. $request->requireName($link->getTarget(), $link->getConstraint());
  16125. }
  16126. }
  16127. }
  16128. private function getRootAliases($forUpdate)
  16129. {
  16130. if ($forUpdate) {
  16131. $aliases = $this->package->getAliases();
  16132. } else {
  16133. $aliases = $this->locker->getAliases();
  16134. }
  16135. return $aliases;
  16136. }
  16137. private function extractPlatformRequirements(array $links)
  16138. {
  16139. $platformReqs = array();
  16140. foreach ($links as $link) {
  16141. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  16142. $platformReqs[$link->getTarget()] = $link->getPrettyConstraint();
  16143. }
  16144. }
  16145. return $platformReqs;
  16146. }
  16147. private function mockLocalRepositories(RepositoryManager $rm)
  16148. {
  16149. $packages = array();
  16150. foreach ($rm->getLocalRepository()->getPackages() as $package) {
  16151. $packages[(string) $package] = clone $package;
  16152. }
  16153. foreach ($packages as $key => $package) {
  16154. if ($package instanceof AliasPackage) {
  16155. $alias = (string) $package->getAliasOf();
  16156. $packages[$key] = new AliasPackage($packages[$alias], $package->getVersion(), $package->getPrettyVersion());
  16157. }
  16158. }
  16159. $rm->setLocalRepository(
  16160. new InstalledArrayRepository($packages)
  16161. );
  16162. }
  16163. public static function create(IOInterface $io, Composer $composer)
  16164. {
  16165. return new static(
  16166. $io,
  16167. $composer->getConfig(),
  16168. $composer->getPackage(),
  16169. $composer->getDownloadManager(),
  16170. $composer->getRepositoryManager(),
  16171. $composer->getLocker(),
  16172. $composer->getInstallationManager(),
  16173. $composer->getEventDispatcher(),
  16174. $composer->getAutoloadGenerator()
  16175. );
  16176. }
  16177. public function setAdditionalFixedRepository(RepositoryInterface $additionalFixedRepository)
  16178. {
  16179. $this->additionalFixedRepository = $additionalFixedRepository;
  16180. return $this;
  16181. }
  16182. public function setDryRun($dryRun = true)
  16183. {
  16184. $this->dryRun = (bool) $dryRun;
  16185. return $this;
  16186. }
  16187. public function isDryRun()
  16188. {
  16189. return $this->dryRun;
  16190. }
  16191. public function setPreferSource($preferSource = true)
  16192. {
  16193. $this->preferSource = (bool) $preferSource;
  16194. return $this;
  16195. }
  16196. public function setPreferDist($preferDist = true)
  16197. {
  16198. $this->preferDist = (bool) $preferDist;
  16199. return $this;
  16200. }
  16201. public function setOptimizeAutoloader($optimizeAutoloader)
  16202. {
  16203. $this->optimizeAutoloader = (bool) $optimizeAutoloader;
  16204. if (!$this->optimizeAutoloader) {
  16205. $this->setClassMapAuthoritative(false);
  16206. }
  16207. return $this;
  16208. }
  16209. public function setClassMapAuthoritative($classMapAuthoritative)
  16210. {
  16211. $this->classMapAuthoritative = (bool) $classMapAuthoritative;
  16212. if ($this->classMapAuthoritative) {
  16213. $this->setOptimizeAutoloader(true);
  16214. }
  16215. return $this;
  16216. }
  16217. public function setApcuAutoloader($apcuAutoloader, $apcuAutoloaderPrefix = null)
  16218. {
  16219. $this->apcuAutoloader = $apcuAutoloader;
  16220. $this->apcuAutoloaderPrefix = $apcuAutoloaderPrefix;
  16221. return $this;
  16222. }
  16223. public function setUpdate($update)
  16224. {
  16225. $this->update = (bool) $update;
  16226. return $this;
  16227. }
  16228. public function setInstall($install)
  16229. {
  16230. $this->install = (bool) $install;
  16231. return $this;
  16232. }
  16233. public function setDevMode($devMode = true)
  16234. {
  16235. $this->devMode = (bool) $devMode;
  16236. return $this;
  16237. }
  16238. public function setDumpAutoloader($dumpAutoloader = true)
  16239. {
  16240. $this->dumpAutoloader = (bool) $dumpAutoloader;
  16241. return $this;
  16242. }
  16243. public function setRunScripts($runScripts = true)
  16244. {
  16245. $this->runScripts = (bool) $runScripts;
  16246. return $this;
  16247. }
  16248. public function setConfig(Config $config)
  16249. {
  16250. $this->config = $config;
  16251. return $this;
  16252. }
  16253. public function setVerbose($verbose = true)
  16254. {
  16255. $this->verbose = (bool) $verbose;
  16256. return $this;
  16257. }
  16258. public function isVerbose()
  16259. {
  16260. return $this->verbose;
  16261. }
  16262. public function setIgnorePlatformRequirements($ignorePlatformReqs)
  16263. {
  16264. if (is_array($ignorePlatformReqs)) {
  16265. $this->ignorePlatformReqs = array_filter($ignorePlatformReqs, function ($req) {
  16266. return PlatformRepository::isPlatformPackage($req);
  16267. });
  16268. } else {
  16269. $this->ignorePlatformReqs = (bool) $ignorePlatformReqs;
  16270. }
  16271. return $this;
  16272. }
  16273. public function setUpdateMirrors($updateMirrors)
  16274. {
  16275. $this->updateMirrors = $updateMirrors;
  16276. return $this;
  16277. }
  16278. public function setUpdateAllowList(array $packages)
  16279. {
  16280. $this->updateAllowList = array_flip(array_map('strtolower', $packages));
  16281. return $this;
  16282. }
  16283. public function setUpdateAllowTransitiveDependencies($updateAllowTransitiveDependencies)
  16284. {
  16285. 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)) {
  16286. throw new \RuntimeException("Invalid value for updateAllowTransitiveDependencies supplied");
  16287. }
  16288. $this->updateAllowTransitiveDependencies = $updateAllowTransitiveDependencies;
  16289. return $this;
  16290. }
  16291. public function setPreferStable($preferStable = true)
  16292. {
  16293. $this->preferStable = (bool) $preferStable;
  16294. return $this;
  16295. }
  16296. public function setPreferLowest($preferLowest = true)
  16297. {
  16298. $this->preferLowest = (bool) $preferLowest;
  16299. return $this;
  16300. }
  16301. public function setWriteLock($writeLock = true)
  16302. {
  16303. $this->writeLock = (bool) $writeLock;
  16304. return $this;
  16305. }
  16306. public function setExecuteOperations($executeOperations = true)
  16307. {
  16308. $this->executeOperations = (bool) $executeOperations;
  16309. return $this;
  16310. }
  16311. public function disablePlugins()
  16312. {
  16313. $this->installationManager->disablePlugins();
  16314. return $this;
  16315. }
  16316. public function setSuggestedPackagesReporter(SuggestedPackagesReporter $suggestedPackagesReporter)
  16317. {
  16318. $this->suggestedPackagesReporter = $suggestedPackagesReporter;
  16319. return $this;
  16320. }
  16321. }
  16322. <?php
  16323. namespace Composer\Installer;
  16324. use Composer\IO\IOInterface;
  16325. use Composer\Package\PackageInterface;
  16326. use Composer\Util\Filesystem;
  16327. use Composer\Util\Platform;
  16328. use Composer\Util\ProcessExecutor;
  16329. use Composer\Util\Silencer;
  16330. class BinaryInstaller
  16331. {
  16332. protected $binDir;
  16333. protected $binCompat;
  16334. protected $io;
  16335. protected $filesystem;
  16336. public function __construct(IOInterface $io, $binDir, $binCompat, Filesystem $filesystem = null)
  16337. {
  16338. $this->binDir = $binDir;
  16339. $this->binCompat = $binCompat;
  16340. $this->io = $io;
  16341. $this->filesystem = $filesystem ?: new Filesystem();
  16342. }
  16343. public function installBinaries(PackageInterface $package, $installPath, $warnOnOverwrite = true)
  16344. {
  16345. $binaries = $this->getBinaries($package);
  16346. if (!$binaries) {
  16347. return;
  16348. }
  16349. foreach ($binaries as $bin) {
  16350. $binPath = $installPath.'/'.$bin;
  16351. if (!file_exists($binPath)) {
  16352. $this->io->writeError(' <warning>Skipped installation of bin '.$bin.' for package '.$package->getName().': file not found in package</warning>');
  16353. continue;
  16354. }
  16355. $binPath = realpath($binPath);
  16356. $this->initializeBinDir();
  16357. $link = $this->binDir.'/'.basename($bin);
  16358. if (file_exists($link)) {
  16359. if (is_link($link)) {
  16360. Silencer::call('chmod', $link, 0777 & ~umask());
  16361. }
  16362. if ($warnOnOverwrite) {
  16363. $this->io->writeError(' Skipped installation of bin '.$bin.' for package '.$package->getName().': name conflicts with an existing file');
  16364. }
  16365. continue;
  16366. }
  16367. if ($this->binCompat === "auto") {
  16368. if (Platform::isWindows()) {
  16369. $this->installFullBinaries($binPath, $link, $bin, $package);
  16370. } else {
  16371. $this->installSymlinkBinaries($binPath, $link);
  16372. }
  16373. } elseif ($this->binCompat === "full") {
  16374. $this->installFullBinaries($binPath, $link, $bin, $package);
  16375. }
  16376. Silencer::call('chmod', $link, 0777 & ~umask());
  16377. }
  16378. }
  16379. public function removeBinaries(PackageInterface $package)
  16380. {
  16381. $this->initializeBinDir();
  16382. $binaries = $this->getBinaries($package);
  16383. if (!$binaries) {
  16384. return;
  16385. }
  16386. foreach ($binaries as $bin) {
  16387. $link = $this->binDir.'/'.basename($bin);
  16388. if (is_link($link) || file_exists($link)) {
  16389. $this->filesystem->unlink($link);
  16390. }
  16391. if (file_exists($link.'.bat')) {
  16392. $this->filesystem->unlink($link.'.bat');
  16393. }
  16394. }
  16395. if (is_dir($this->binDir) && $this->filesystem->isDirEmpty($this->binDir)) {
  16396. Silencer::call('rmdir', $this->binDir);
  16397. }
  16398. }
  16399. public static function determineBinaryCaller($bin)
  16400. {
  16401. if ('.bat' === substr($bin, -4) || '.exe' === substr($bin, -4)) {
  16402. return 'call';
  16403. }
  16404. $handle = fopen($bin, 'r');
  16405. $line = fgets($handle);
  16406. fclose($handle);
  16407. if (preg_match('{^#!/(?:usr/bin/env )?(?:[^/]+/)*(.+)$}m', $line, $match)) {
  16408. return trim($match[1]);
  16409. }
  16410. return 'php';
  16411. }
  16412. protected function getBinaries(PackageInterface $package)
  16413. {
  16414. return $package->getBinaries();
  16415. }
  16416. protected function installFullBinaries($binPath, $link, $bin, PackageInterface $package)
  16417. {
  16418. if ('.bat' !== substr($binPath, -4)) {
  16419. $this->installUnixyProxyBinaries($binPath, $link);
  16420. @chmod($link, 0777 & ~umask());
  16421. $link .= '.bat';
  16422. if (file_exists($link)) {
  16423. $this->io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$package->getName().': a .bat proxy was already installed');
  16424. }
  16425. }
  16426. if (!file_exists($link)) {
  16427. file_put_contents($link, $this->generateWindowsProxyCode($binPath, $link));
  16428. }
  16429. }
  16430. protected function installSymlinkBinaries($binPath, $link)
  16431. {
  16432. if (!$this->filesystem->relativeSymlink($binPath, $link)) {
  16433. $this->installUnixyProxyBinaries($binPath, $link);
  16434. }
  16435. }
  16436. protected function installUnixyProxyBinaries($binPath, $link)
  16437. {
  16438. file_put_contents($link, $this->generateUnixyProxyCode($binPath, $link));
  16439. }
  16440. protected function initializeBinDir()
  16441. {
  16442. $this->filesystem->ensureDirectoryExists($this->binDir);
  16443. $this->binDir = realpath($this->binDir);
  16444. }
  16445. protected function generateWindowsProxyCode($bin, $link)
  16446. {
  16447. $binPath = $this->filesystem->findShortestPath($link, $bin);
  16448. $caller = self::determineBinaryCaller($bin);
  16449. return "@ECHO OFF\r\n".
  16450. "setlocal DISABLEDELAYEDEXPANSION\r\n".
  16451. "SET BIN_TARGET=%~dp0/".trim(ProcessExecutor::escape($binPath), '"\'')."\r\n".
  16452. "{$caller} \"%BIN_TARGET%\" %*\r\n";
  16453. }
  16454. protected function generateUnixyProxyCode($bin, $link)
  16455. {
  16456. $binPath = $this->filesystem->findShortestPath($link, $bin);
  16457. $binDir = ProcessExecutor::escape(dirname($binPath));
  16458. $binFile = basename($binPath);
  16459. $proxyCode = <<<PROXY
  16460. #!/usr/bin/env sh
  16461. dir=\$(cd "\${0%[/\\\\]*}" > /dev/null; cd $binDir && pwd)
  16462. if [ -d /proc/cygdrive ]; then
  16463. case \$(which php) in
  16464. \$(readlink -n /proc/cygdrive)/*)
  16465. # We are in Cygwin using Windows php, so the path must be translated
  16466. dir=\$(cygpath -m "\$dir");
  16467. ;;
  16468. esac
  16469. fi
  16470. "\${dir}/$binFile" "\$@"
  16471. PROXY;
  16472. return $proxyCode;
  16473. }
  16474. }
  16475. <?php
  16476. namespace Composer\Installer;
  16477. use Composer\Package\PackageInterface;
  16478. interface BinaryPresenceInterface
  16479. {
  16480. public function ensureBinariesPresence(PackageInterface $package);
  16481. }
  16482. <?php
  16483. namespace Composer\Installer;
  16484. use Composer\IO\IOInterface;
  16485. use Composer\IO\ConsoleIO;
  16486. use Composer\Package\PackageInterface;
  16487. use Composer\Package\AliasPackage;
  16488. use Composer\Repository\RepositoryInterface;
  16489. use Composer\Repository\InstalledRepositoryInterface;
  16490. use Composer\DependencyResolver\Operation\OperationInterface;
  16491. use Composer\DependencyResolver\Operation\InstallOperation;
  16492. use Composer\DependencyResolver\Operation\UpdateOperation;
  16493. use Composer\DependencyResolver\Operation\UninstallOperation;
  16494. use Composer\DependencyResolver\Operation\MarkAliasInstalledOperation;
  16495. use Composer\DependencyResolver\Operation\MarkAliasUninstalledOperation;
  16496. use Composer\EventDispatcher\EventDispatcher;
  16497. use Composer\Util\Loop;
  16498. use React\Promise\PromiseInterface;
  16499. class InstallationManager
  16500. {
  16501. private $installers = array();
  16502. private $cache = array();
  16503. private $notifiablePackages = array();
  16504. private $loop;
  16505. private $io;
  16506. private $eventDispatcher;
  16507. private $outputProgress;
  16508. public function __construct(Loop $loop, IOInterface $io, EventDispatcher $eventDispatcher = null)
  16509. {
  16510. $this->loop = $loop;
  16511. $this->io = $io;
  16512. $this->eventDispatcher = $eventDispatcher;
  16513. }
  16514. public function reset()
  16515. {
  16516. $this->notifiablePackages = array();
  16517. }
  16518. public function addInstaller(InstallerInterface $installer)
  16519. {
  16520. array_unshift($this->installers, $installer);
  16521. $this->cache = array();
  16522. }
  16523. public function removeInstaller(InstallerInterface $installer)
  16524. {
  16525. if (false !== ($key = array_search($installer, $this->installers, true))) {
  16526. array_splice($this->installers, $key, 1);
  16527. $this->cache = array();
  16528. }
  16529. }
  16530. public function disablePlugins()
  16531. {
  16532. foreach ($this->installers as $i => $installer) {
  16533. if (!$installer instanceof PluginInstaller) {
  16534. continue;
  16535. }
  16536. unset($this->installers[$i]);
  16537. }
  16538. }
  16539. public function getInstaller($type)
  16540. {
  16541. $type = strtolower($type);
  16542. if (isset($this->cache[$type])) {
  16543. return $this->cache[$type];
  16544. }
  16545. foreach ($this->installers as $installer) {
  16546. if ($installer->supports($type)) {
  16547. return $this->cache[$type] = $installer;
  16548. }
  16549. }
  16550. throw new \InvalidArgumentException('Unknown installer type: '.$type);
  16551. }
  16552. public function isPackageInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  16553. {
  16554. if ($package instanceof AliasPackage) {
  16555. return $repo->hasPackage($package) && $this->isPackageInstalled($repo, $package->getAliasOf());
  16556. }
  16557. return $this->getInstaller($package->getType())->isInstalled($repo, $package);
  16558. }
  16559. public function ensureBinariesPresence(PackageInterface $package)
  16560. {
  16561. try {
  16562. $installer = $this->getInstaller($package->getType());
  16563. } catch (\InvalidArgumentException $e) {
  16564. return;
  16565. }
  16566. if ($installer instanceof BinaryPresenceInterface) {
  16567. $installer->ensureBinariesPresence($package);
  16568. }
  16569. }
  16570. public function execute(RepositoryInterface $repo, array $operations, $devMode = true, $runScripts = true)
  16571. {
  16572. $cleanupPromises = array();
  16573. $loop = $this->loop;
  16574. $io = $this->io;
  16575. $runCleanup = function () use (&$cleanupPromises, $loop) {
  16576. $promises = array();
  16577. $loop->abortJobs();
  16578. foreach ($cleanupPromises as $cleanup) {
  16579. $promises[] = new \React\Promise\Promise(function ($resolve, $reject) use ($cleanup) {
  16580. $promise = $cleanup();
  16581. if (!$promise instanceof PromiseInterface) {
  16582. $resolve();
  16583. } else {
  16584. $promise->then(function () use ($resolve) {
  16585. $resolve();
  16586. });
  16587. }
  16588. });
  16589. }
  16590. if (!empty($promises)) {
  16591. $loop->wait($promises);
  16592. }
  16593. };
  16594. $handleInterruptsUnix = function_exists('pcntl_async_signals') && function_exists('pcntl_signal');
  16595. $handleInterruptsWindows = function_exists('sapi_windows_set_ctrl_handler');
  16596. $prevHandler = null;
  16597. $windowsHandler = null;
  16598. if ($handleInterruptsUnix) {
  16599. pcntl_async_signals(true);
  16600. $prevHandler = pcntl_signal_get_handler(SIGINT);
  16601. pcntl_signal(SIGINT, function ($sig) use ($runCleanup, $prevHandler, $io) {
  16602. $io->writeError('Received SIGINT, aborting', true, IOInterface::DEBUG);
  16603. $runCleanup();
  16604. if (!in_array($prevHandler, array(SIG_DFL, SIG_IGN), true)) {
  16605. call_user_func($prevHandler, $sig);
  16606. }
  16607. exit(130);
  16608. });
  16609. }
  16610. if ($handleInterruptsWindows) {
  16611. $windowsHandler = function ($event) use ($runCleanup, $io) {
  16612. if ($event !== PHP_WINDOWS_EVENT_CTRL_C) {
  16613. return;
  16614. }
  16615. $io->writeError('Received CTRL+C, aborting', true, IOInterface::DEBUG);
  16616. $runCleanup();
  16617. exit(130);
  16618. };
  16619. sapi_windows_set_ctrl_handler($windowsHandler);
  16620. }
  16621. try {
  16622. $batches = array();
  16623. $batch = array();
  16624. foreach ($operations as $index => $operation) {
  16625. if (in_array($operation->getOperationType(), array('update', 'install'), true)) {
  16626. $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
  16627. if ($package->getType() === 'composer-plugin' && ($extra = $package->getExtra()) && isset($extra['plugin-modifies-downloads']) && $extra['plugin-modifies-downloads'] === true) {
  16628. if ($batch) {
  16629. $batches[] = $batch;
  16630. }
  16631. $batches[] = array($index => $operation);
  16632. $batch = array();
  16633. continue;
  16634. }
  16635. }
  16636. $batch[$index] = $operation;
  16637. }
  16638. if ($batch) {
  16639. $batches[] = $batch;
  16640. }
  16641. foreach ($batches as $batch) {
  16642. $this->downloadAndExecuteBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $operations);
  16643. }
  16644. } catch (\Exception $e) {
  16645. $runCleanup();
  16646. if ($handleInterruptsUnix) {
  16647. pcntl_signal(SIGINT, $prevHandler);
  16648. }
  16649. if ($handleInterruptsWindows) {
  16650. sapi_windows_set_ctrl_handler($prevHandler, false);
  16651. }
  16652. throw $e;
  16653. }
  16654. if ($handleInterruptsUnix) {
  16655. pcntl_signal(SIGINT, $prevHandler);
  16656. }
  16657. if ($handleInterruptsWindows) {
  16658. sapi_windows_set_ctrl_handler($prevHandler, false);
  16659. }
  16660. $repo->write($devMode, $this);
  16661. }
  16662. private function downloadAndExecuteBatch(RepositoryInterface $repo, array $operations, array &$cleanupPromises, $devMode, $runScripts, array $allOperations)
  16663. {
  16664. $promises = array();
  16665. foreach ($operations as $index => $operation) {
  16666. $opType = $operation->getOperationType();
  16667. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  16668. continue;
  16669. }
  16670. if ($opType === 'update') {
  16671. $package = $operation->getTargetPackage();
  16672. $initialPackage = $operation->getInitialPackage();
  16673. } else {
  16674. $package = $operation->getPackage();
  16675. $initialPackage = null;
  16676. }
  16677. $installer = $this->getInstaller($package->getType());
  16678. $cleanupPromises[$index] = function () use ($opType, $installer, $package, $initialPackage) {
  16679. if (!$package->getInstallationSource()) {
  16680. return;
  16681. }
  16682. return $installer->cleanup($opType, $package, $initialPackage);
  16683. };
  16684. if ($opType !== 'uninstall') {
  16685. $promise = $installer->download($package, $initialPackage);
  16686. if ($promise) {
  16687. $promises[] = $promise;
  16688. }
  16689. }
  16690. }
  16691. if (count($promises)) {
  16692. $this->waitOnPromises($promises);
  16693. }
  16694. $batches = array();
  16695. $batch = array();
  16696. foreach ($operations as $index => $operation) {
  16697. if (in_array($operation->getOperationType(), array('update', 'install'), true)) {
  16698. $package = $operation->getOperationType() === 'update' ? $operation->getTargetPackage() : $operation->getPackage();
  16699. if ($package->getType() === 'composer-plugin' || $package->getType() === 'composer-installer') {
  16700. if ($batch) {
  16701. $batches[] = $batch;
  16702. }
  16703. $batches[] = array($index => $operation);
  16704. $batch = array();
  16705. continue;
  16706. }
  16707. }
  16708. $batch[$index] = $operation;
  16709. }
  16710. if ($batch) {
  16711. $batches[] = $batch;
  16712. }
  16713. foreach ($batches as $batch) {
  16714. $this->executeBatch($repo, $batch, $cleanupPromises, $devMode, $runScripts, $allOperations);
  16715. }
  16716. }
  16717. private function executeBatch(RepositoryInterface $repo, array $operations, array $cleanupPromises, $devMode, $runScripts, array $allOperations)
  16718. {
  16719. $promises = array();
  16720. $postExecCallbacks = array();
  16721. foreach ($operations as $index => $operation) {
  16722. $opType = $operation->getOperationType();
  16723. if (!in_array($opType, array('update', 'install', 'uninstall'))) {
  16724. if ($this->io->isDebug()) {
  16725. $this->io->writeError(' - ' . $operation->show(false));
  16726. }
  16727. $this->$opType($repo, $operation);
  16728. continue;
  16729. }
  16730. if ($opType === 'update') {
  16731. $package = $operation->getTargetPackage();
  16732. $initialPackage = $operation->getInitialPackage();
  16733. } else {
  16734. $package = $operation->getPackage();
  16735. $initialPackage = null;
  16736. }
  16737. $installer = $this->getInstaller($package->getType());
  16738. $event = 'Composer\Installer\PackageEvents::PRE_PACKAGE_'.strtoupper($opType);
  16739. if (defined($event) && $runScripts && $this->eventDispatcher) {
  16740. $this->eventDispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  16741. }
  16742. $dispatcher = $this->eventDispatcher;
  16743. $installManager = $this;
  16744. $io = $this->io;
  16745. $promise = $installer->prepare($opType, $package, $initialPackage);
  16746. if (!$promise instanceof PromiseInterface) {
  16747. $promise = \React\Promise\resolve();
  16748. }
  16749. $promise = $promise->then(function () use ($opType, $installManager, $repo, $operation) {
  16750. return $installManager->$opType($repo, $operation);
  16751. })->then($cleanupPromises[$index])
  16752. ->then(function () use ($installManager, $devMode, $repo) {
  16753. $repo->write($devMode, $installManager);
  16754. }, function ($e) use ($opType, $package, $io) {
  16755. $io->writeError(' <error>' . ucfirst($opType) .' of '.$package->getPrettyName().' failed</error>');
  16756. throw $e;
  16757. });
  16758. $postExecCallbacks[] = function () use ($opType, $runScripts, $dispatcher, $devMode, $repo, $allOperations, $operation) {
  16759. $event = 'Composer\Installer\PackageEvents::POST_PACKAGE_'.strtoupper($opType);
  16760. if (defined($event) && $runScripts && $dispatcher) {
  16761. $dispatcher->dispatchPackageEvent(constant($event), $devMode, $repo, $allOperations, $operation);
  16762. }
  16763. };
  16764. $promises[] = $promise;
  16765. }
  16766. if (count($promises)) {
  16767. $this->waitOnPromises($promises);
  16768. }
  16769. foreach ($postExecCallbacks as $cb) {
  16770. $cb();
  16771. }
  16772. }
  16773. private function waitOnPromises(array $promises)
  16774. {
  16775. $progress = null;
  16776. if ($this->outputProgress && $this->io instanceof ConsoleIO && !$this->io->isDebug() && count($promises) > 1) {
  16777. $progress = $this->io->getProgressBar();
  16778. }
  16779. $this->loop->wait($promises, $progress);
  16780. if ($progress) {
  16781. $progress->clear();
  16782. }
  16783. }
  16784. public function install(RepositoryInterface $repo, InstallOperation $operation)
  16785. {
  16786. $package = $operation->getPackage();
  16787. $installer = $this->getInstaller($package->getType());
  16788. $promise = $installer->install($repo, $package);
  16789. $this->markForNotification($package);
  16790. return $promise;
  16791. }
  16792. public function update(RepositoryInterface $repo, UpdateOperation $operation)
  16793. {
  16794. $initial = $operation->getInitialPackage();
  16795. $target = $operation->getTargetPackage();
  16796. $initialType = $initial->getType();
  16797. $targetType = $target->getType();
  16798. if ($initialType === $targetType) {
  16799. $installer = $this->getInstaller($initialType);
  16800. $promise = $installer->update($repo, $initial, $target);
  16801. $this->markForNotification($target);
  16802. } else {
  16803. $this->getInstaller($initialType)->uninstall($repo, $initial);
  16804. $installer = $this->getInstaller($targetType);
  16805. $promise = $installer->install($repo, $target);
  16806. }
  16807. return $promise;
  16808. }
  16809. public function uninstall(RepositoryInterface $repo, UninstallOperation $operation)
  16810. {
  16811. $package = $operation->getPackage();
  16812. $installer = $this->getInstaller($package->getType());
  16813. return $installer->uninstall($repo, $package);
  16814. }
  16815. public function markAliasInstalled(RepositoryInterface $repo, MarkAliasInstalledOperation $operation)
  16816. {
  16817. $package = $operation->getPackage();
  16818. if (!$repo->hasPackage($package)) {
  16819. $repo->addPackage(clone $package);
  16820. }
  16821. }
  16822. public function markAliasUninstalled(RepositoryInterface $repo, MarkAliasUninstalledOperation $operation)
  16823. {
  16824. $package = $operation->getPackage();
  16825. $repo->removePackage($package);
  16826. }
  16827. public function getInstallPath(PackageInterface $package)
  16828. {
  16829. $installer = $this->getInstaller($package->getType());
  16830. return $installer->getInstallPath($package);
  16831. }
  16832. public function setOutputProgress($outputProgress)
  16833. {
  16834. $this->outputProgress = $outputProgress;
  16835. }
  16836. public function notifyInstalls(IOInterface $io)
  16837. {
  16838. $promises = array();
  16839. try {
  16840. foreach ($this->notifiablePackages as $repoUrl => $packages) {
  16841. if (strpos($repoUrl, '%package%')) {
  16842. foreach ($packages as $package) {
  16843. $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
  16844. $params = array(
  16845. 'version' => $package->getPrettyVersion(),
  16846. 'version_normalized' => $package->getVersion(),
  16847. );
  16848. $opts = array(
  16849. 'retry-auth-failure' => false,
  16850. 'http' => array(
  16851. 'method' => 'POST',
  16852. 'header' => array('Content-type: application/x-www-form-urlencoded'),
  16853. 'content' => http_build_query($params, '', '&'),
  16854. 'timeout' => 3,
  16855. ),
  16856. );
  16857. $promises[] = $this->loop->getHttpDownloader()->add($url, $opts);
  16858. }
  16859. continue;
  16860. }
  16861. $postData = array('downloads' => array());
  16862. foreach ($packages as $package) {
  16863. $postData['downloads'][] = array(
  16864. 'name' => $package->getPrettyName(),
  16865. 'version' => $package->getVersion(),
  16866. );
  16867. }
  16868. $opts = array(
  16869. 'retry-auth-failure' => false,
  16870. 'http' => array(
  16871. 'method' => 'POST',
  16872. 'header' => array('Content-Type: application/json'),
  16873. 'content' => json_encode($postData),
  16874. 'timeout' => 6,
  16875. ),
  16876. );
  16877. $promises[] = $this->loop->getHttpDownloader()->add($repoUrl, $opts);
  16878. }
  16879. $this->loop->wait($promises);
  16880. } catch (\Exception $e) {
  16881. }
  16882. $this->reset();
  16883. }
  16884. private function markForNotification(PackageInterface $package)
  16885. {
  16886. if ($package->getNotificationUrl()) {
  16887. $this->notifiablePackages[$package->getNotificationUrl()][$package->getName()] = $package;
  16888. }
  16889. }
  16890. }
  16891. <?php
  16892. namespace Composer\Installer;
  16893. use Composer\Composer;
  16894. use Composer\DependencyResolver\Transaction;
  16895. use Composer\EventDispatcher\Event;
  16896. use Composer\IO\IOInterface;
  16897. class InstallerEvent extends Event
  16898. {
  16899. private $composer;
  16900. private $io;
  16901. private $devMode;
  16902. private $executeOperations;
  16903. private $transaction;
  16904. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, $executeOperations, Transaction $transaction)
  16905. {
  16906. parent::__construct($eventName);
  16907. $this->composer = $composer;
  16908. $this->io = $io;
  16909. $this->devMode = $devMode;
  16910. $this->executeOperations = $executeOperations;
  16911. $this->transaction = $transaction;
  16912. }
  16913. public function getComposer()
  16914. {
  16915. return $this->composer;
  16916. }
  16917. public function getIO()
  16918. {
  16919. return $this->io;
  16920. }
  16921. public function isDevMode()
  16922. {
  16923. return $this->devMode;
  16924. }
  16925. public function isExecutingOperations()
  16926. {
  16927. return $this->executeOperations;
  16928. }
  16929. public function getTransaction()
  16930. {
  16931. return $this->transaction;
  16932. }
  16933. }
  16934. <?php
  16935. namespace Composer\Installer;
  16936. class InstallerEvents
  16937. {
  16938. const PRE_OPERATIONS_EXEC = 'pre-operations-exec';
  16939. }
  16940. <?php
  16941. namespace Composer\Installer;
  16942. use Composer\Package\PackageInterface;
  16943. use Composer\Repository\InstalledRepositoryInterface;
  16944. use InvalidArgumentException;
  16945. use React\Promise\PromiseInterface;
  16946. interface InstallerInterface
  16947. {
  16948. public function supports($packageType);
  16949. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package);
  16950. public function download(PackageInterface $package, PackageInterface $prevPackage = null);
  16951. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null);
  16952. public function install(InstalledRepositoryInterface $repo, PackageInterface $package);
  16953. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target);
  16954. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package);
  16955. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null);
  16956. public function getInstallPath(PackageInterface $package);
  16957. }
  16958. <?php
  16959. namespace Composer\Installer;
  16960. use Composer\Composer;
  16961. use Composer\IO\IOInterface;
  16962. use Composer\Repository\InstalledRepositoryInterface;
  16963. use Composer\Package\PackageInterface;
  16964. use Composer\Util\Filesystem;
  16965. use Composer\Util\Silencer;
  16966. use Composer\Util\Platform;
  16967. use React\Promise\PromiseInterface;
  16968. class LibraryInstaller implements InstallerInterface, BinaryPresenceInterface
  16969. {
  16970. protected $composer;
  16971. protected $vendorDir;
  16972. protected $binDir;
  16973. protected $downloadManager;
  16974. protected $io;
  16975. protected $type;
  16976. protected $filesystem;
  16977. protected $binCompat;
  16978. protected $binaryInstaller;
  16979. public function __construct(IOInterface $io, Composer $composer, $type = 'library', Filesystem $filesystem = null, BinaryInstaller $binaryInstaller = null)
  16980. {
  16981. $this->composer = $composer;
  16982. $this->downloadManager = $composer->getDownloadManager();
  16983. $this->io = $io;
  16984. $this->type = $type;
  16985. $this->filesystem = $filesystem ?: new Filesystem();
  16986. $this->vendorDir = rtrim($composer->getConfig()->get('vendor-dir'), '/');
  16987. $this->binaryInstaller = $binaryInstaller ?: new BinaryInstaller($this->io, rtrim($composer->getConfig()->get('bin-dir'), '/'), $composer->getConfig()->get('bin-compat'), $this->filesystem);
  16988. }
  16989. public function supports($packageType)
  16990. {
  16991. return $packageType === $this->type || null === $this->type;
  16992. }
  16993. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  16994. {
  16995. if (!$repo->hasPackage($package)) {
  16996. return false;
  16997. }
  16998. $installPath = $this->getInstallPath($package);
  16999. if (is_readable($installPath)) {
  17000. return true;
  17001. }
  17002. return (Platform::isWindows() && $this->filesystem->isJunction($installPath)) || is_link($installPath);
  17003. }
  17004. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17005. {
  17006. $this->initializeVendorDir();
  17007. $downloadPath = $this->getInstallPath($package);
  17008. return $this->downloadManager->download($package, $downloadPath, $prevPackage);
  17009. }
  17010. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17011. {
  17012. $this->initializeVendorDir();
  17013. $downloadPath = $this->getInstallPath($package);
  17014. return $this->downloadManager->prepare($type, $package, $downloadPath, $prevPackage);
  17015. }
  17016. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17017. {
  17018. $this->initializeVendorDir();
  17019. $downloadPath = $this->getInstallPath($package);
  17020. return $this->downloadManager->cleanup($type, $package, $downloadPath, $prevPackage);
  17021. }
  17022. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17023. {
  17024. $this->initializeVendorDir();
  17025. $downloadPath = $this->getInstallPath($package);
  17026. if (!is_readable($downloadPath) && $repo->hasPackage($package)) {
  17027. $this->binaryInstaller->removeBinaries($package);
  17028. }
  17029. $promise = $this->installCode($package);
  17030. if (!$promise instanceof PromiseInterface) {
  17031. $promise = \React\Promise\resolve();
  17032. }
  17033. $binaryInstaller = $this->binaryInstaller;
  17034. $installPath = $this->getInstallPath($package);
  17035. return $promise->then(function () use ($binaryInstaller, $installPath, $package, $repo) {
  17036. $binaryInstaller->installBinaries($package, $installPath);
  17037. if (!$repo->hasPackage($package)) {
  17038. $repo->addPackage(clone $package);
  17039. }
  17040. });
  17041. }
  17042. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17043. {
  17044. if (!$repo->hasPackage($initial)) {
  17045. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  17046. }
  17047. $this->initializeVendorDir();
  17048. $this->binaryInstaller->removeBinaries($initial);
  17049. $promise = $this->updateCode($initial, $target);
  17050. if (!$promise instanceof PromiseInterface) {
  17051. $promise = \React\Promise\resolve();
  17052. }
  17053. $binaryInstaller = $this->binaryInstaller;
  17054. $installPath = $this->getInstallPath($target);
  17055. return $promise->then(function () use ($binaryInstaller, $installPath, $target, $initial, $repo) {
  17056. $binaryInstaller->installBinaries($target, $installPath);
  17057. $repo->removePackage($initial);
  17058. if (!$repo->hasPackage($target)) {
  17059. $repo->addPackage(clone $target);
  17060. }
  17061. });
  17062. }
  17063. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17064. {
  17065. if (!$repo->hasPackage($package)) {
  17066. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17067. }
  17068. $promise = $this->removeCode($package);
  17069. if (!$promise instanceof PromiseInterface) {
  17070. $promise = \React\Promise\resolve();
  17071. }
  17072. $binaryInstaller = $this->binaryInstaller;
  17073. $downloadPath = $this->getPackageBasePath($package);
  17074. $filesystem = $this->filesystem;
  17075. return $promise->then(function () use ($binaryInstaller, $filesystem, $downloadPath, $package, $repo) {
  17076. $binaryInstaller->removeBinaries($package);
  17077. $repo->removePackage($package);
  17078. if (strpos($package->getName(), '/')) {
  17079. $packageVendorDir = dirname($downloadPath);
  17080. if (is_dir($packageVendorDir) && $filesystem->isDirEmpty($packageVendorDir)) {
  17081. Silencer::call('rmdir', $packageVendorDir);
  17082. }
  17083. }
  17084. });
  17085. }
  17086. public function getInstallPath(PackageInterface $package)
  17087. {
  17088. $this->initializeVendorDir();
  17089. $basePath = ($this->vendorDir ? $this->vendorDir.'/' : '') . $package->getPrettyName();
  17090. $targetDir = $package->getTargetDir();
  17091. return $basePath . ($targetDir ? '/'.$targetDir : '');
  17092. }
  17093. public function ensureBinariesPresence(PackageInterface $package)
  17094. {
  17095. $this->binaryInstaller->installBinaries($package, $this->getInstallPath($package), false);
  17096. }
  17097. protected function getPackageBasePath(PackageInterface $package)
  17098. {
  17099. $installPath = $this->getInstallPath($package);
  17100. $targetDir = $package->getTargetDir();
  17101. if ($targetDir) {
  17102. return preg_replace('{/*'.str_replace('/', '/+', preg_quote($targetDir)).'/?$}', '', $installPath);
  17103. }
  17104. return $installPath;
  17105. }
  17106. protected function installCode(PackageInterface $package)
  17107. {
  17108. $downloadPath = $this->getInstallPath($package);
  17109. return $this->downloadManager->install($package, $downloadPath);
  17110. }
  17111. protected function updateCode(PackageInterface $initial, PackageInterface $target)
  17112. {
  17113. $initialDownloadPath = $this->getInstallPath($initial);
  17114. $targetDownloadPath = $this->getInstallPath($target);
  17115. if ($targetDownloadPath !== $initialDownloadPath) {
  17116. if (strpos($initialDownloadPath, $targetDownloadPath) === 0
  17117. || strpos($targetDownloadPath, $initialDownloadPath) === 0
  17118. ) {
  17119. $promise = $this->removeCode($initial);
  17120. if (!$promise instanceof PromiseInterface) {
  17121. $promise = \React\Promise\resolve();
  17122. }
  17123. $self = $this;
  17124. return $promise->then(function () use ($self, $target) {
  17125. $reflMethod = new \ReflectionMethod($self, 'installCode');
  17126. $reflMethod->setAccessible(true);
  17127. return $reflMethod->invoke($self, $target);
  17128. });
  17129. }
  17130. $this->filesystem->rename($initialDownloadPath, $targetDownloadPath);
  17131. }
  17132. return $this->downloadManager->update($initial, $target, $targetDownloadPath);
  17133. }
  17134. protected function removeCode(PackageInterface $package)
  17135. {
  17136. $downloadPath = $this->getPackageBasePath($package);
  17137. return $this->downloadManager->remove($package, $downloadPath);
  17138. }
  17139. protected function initializeVendorDir()
  17140. {
  17141. $this->filesystem->ensureDirectoryExists($this->vendorDir);
  17142. $this->vendorDir = realpath($this->vendorDir);
  17143. }
  17144. }
  17145. <?php
  17146. namespace Composer\Installer;
  17147. use Composer\Repository\InstalledRepositoryInterface;
  17148. use Composer\Package\PackageInterface;
  17149. use Composer\IO\IOInterface;
  17150. use Composer\DependencyResolver\Operation\UpdateOperation;
  17151. use Composer\DependencyResolver\Operation\InstallOperation;
  17152. use Composer\DependencyResolver\Operation\UninstallOperation;
  17153. class MetapackageInstaller implements InstallerInterface
  17154. {
  17155. private $io;
  17156. public function __construct(IOInterface $io)
  17157. {
  17158. $this->io = $io;
  17159. }
  17160. public function supports($packageType)
  17161. {
  17162. return $packageType === 'metapackage';
  17163. }
  17164. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17165. {
  17166. return $repo->hasPackage($package);
  17167. }
  17168. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17169. {
  17170. }
  17171. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17172. {
  17173. }
  17174. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17175. {
  17176. }
  17177. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17178. {
  17179. $this->io->writeError(" - " . InstallOperation::format($package));
  17180. $repo->addPackage(clone $package);
  17181. }
  17182. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17183. {
  17184. if (!$repo->hasPackage($initial)) {
  17185. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  17186. }
  17187. $this->io->writeError(" - " . UpdateOperation::format($initial, $target));
  17188. $repo->removePackage($initial);
  17189. $repo->addPackage(clone $target);
  17190. }
  17191. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17192. {
  17193. if (!$repo->hasPackage($package)) {
  17194. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17195. }
  17196. $this->io->writeError(" - " . UninstallOperation::format($package));
  17197. $repo->removePackage($package);
  17198. }
  17199. public function getInstallPath(PackageInterface $package)
  17200. {
  17201. return '';
  17202. }
  17203. }
  17204. <?php
  17205. namespace Composer\Installer;
  17206. use Composer\Repository\InstalledRepositoryInterface;
  17207. use Composer\Package\PackageInterface;
  17208. class NoopInstaller implements InstallerInterface
  17209. {
  17210. public function supports($packageType)
  17211. {
  17212. return true;
  17213. }
  17214. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17215. {
  17216. return $repo->hasPackage($package);
  17217. }
  17218. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17219. {
  17220. }
  17221. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17222. {
  17223. }
  17224. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17225. {
  17226. }
  17227. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17228. {
  17229. if (!$repo->hasPackage($package)) {
  17230. $repo->addPackage(clone $package);
  17231. }
  17232. }
  17233. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17234. {
  17235. if (!$repo->hasPackage($initial)) {
  17236. throw new \InvalidArgumentException('Package is not installed: '.$initial);
  17237. }
  17238. $repo->removePackage($initial);
  17239. if (!$repo->hasPackage($target)) {
  17240. $repo->addPackage(clone $target);
  17241. }
  17242. }
  17243. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17244. {
  17245. if (!$repo->hasPackage($package)) {
  17246. throw new \InvalidArgumentException('Package is not installed: '.$package);
  17247. }
  17248. $repo->removePackage($package);
  17249. }
  17250. public function getInstallPath(PackageInterface $package)
  17251. {
  17252. $targetDir = $package->getTargetDir();
  17253. return $package->getPrettyName() . ($targetDir ? '/'.$targetDir : '');
  17254. }
  17255. }
  17256. <?php
  17257. namespace Composer\Installer;
  17258. use Composer\Composer;
  17259. use Composer\IO\IOInterface;
  17260. use Composer\DependencyResolver\Operation\OperationInterface;
  17261. use Composer\Repository\RepositoryInterface;
  17262. use Composer\EventDispatcher\Event;
  17263. class PackageEvent extends Event
  17264. {
  17265. private $composer;
  17266. private $io;
  17267. private $devMode;
  17268. private $localRepo;
  17269. private $operations;
  17270. private $operation;
  17271. public function __construct($eventName, Composer $composer, IOInterface $io, $devMode, RepositoryInterface $localRepo, array $operations, OperationInterface $operation)
  17272. {
  17273. parent::__construct($eventName);
  17274. $this->composer = $composer;
  17275. $this->io = $io;
  17276. $this->devMode = $devMode;
  17277. $this->localRepo = $localRepo;
  17278. $this->operations = $operations;
  17279. $this->operation = $operation;
  17280. }
  17281. public function getComposer()
  17282. {
  17283. return $this->composer;
  17284. }
  17285. public function getIO()
  17286. {
  17287. return $this->io;
  17288. }
  17289. public function isDevMode()
  17290. {
  17291. return $this->devMode;
  17292. }
  17293. public function getLocalRepo()
  17294. {
  17295. return $this->localRepo;
  17296. }
  17297. public function getOperations()
  17298. {
  17299. return $this->operations;
  17300. }
  17301. public function getOperation()
  17302. {
  17303. return $this->operation;
  17304. }
  17305. }
  17306. <?php
  17307. namespace Composer\Installer;
  17308. class PackageEvents
  17309. {
  17310. const PRE_PACKAGE_INSTALL = 'pre-package-install';
  17311. const POST_PACKAGE_INSTALL = 'post-package-install';
  17312. const PRE_PACKAGE_UPDATE = 'pre-package-update';
  17313. const POST_PACKAGE_UPDATE = 'post-package-update';
  17314. const PRE_PACKAGE_UNINSTALL = 'pre-package-uninstall';
  17315. const POST_PACKAGE_UNINSTALL = 'post-package-uninstall';
  17316. }
  17317. <?php
  17318. namespace Composer\Installer;
  17319. use Composer\Composer;
  17320. use Composer\IO\IOInterface;
  17321. use Composer\Repository\InstalledRepositoryInterface;
  17322. use Composer\Package\PackageInterface;
  17323. use Composer\Util\Filesystem;
  17324. use React\Promise\PromiseInterface;
  17325. class PluginInstaller extends LibraryInstaller
  17326. {
  17327. public function __construct(IOInterface $io, Composer $composer, Filesystem $fs = null, BinaryInstaller $binaryInstaller = null)
  17328. {
  17329. parent::__construct($io, $composer, 'composer-plugin', $fs, $binaryInstaller);
  17330. }
  17331. public function supports($packageType)
  17332. {
  17333. return $packageType === 'composer-plugin' || $packageType === 'composer-installer';
  17334. }
  17335. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17336. {
  17337. $extra = $package->getExtra();
  17338. if (empty($extra['class'])) {
  17339. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  17340. }
  17341. return parent::download($package, $prevPackage);
  17342. }
  17343. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17344. {
  17345. $promise = parent::install($repo, $package);
  17346. if (!$promise instanceof PromiseInterface) {
  17347. $promise = \React\Promise\resolve();
  17348. }
  17349. $pluginManager = $this->composer->getPluginManager();
  17350. $self = $this;
  17351. return $promise->then(function () use ($self, $pluginManager, $package, $repo) {
  17352. try {
  17353. $pluginManager->registerPackage($package, true);
  17354. } catch (\Exception $e) {
  17355. $self->rollbackInstall($e, $repo, $package);
  17356. }
  17357. });
  17358. }
  17359. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17360. {
  17361. $promise = parent::update($repo, $initial, $target);
  17362. if (!$promise instanceof PromiseInterface) {
  17363. $promise = \React\Promise\resolve();
  17364. }
  17365. $pluginManager = $this->composer->getPluginManager();
  17366. $self = $this;
  17367. return $promise->then(function () use ($self, $pluginManager, $initial, $target, $repo) {
  17368. try {
  17369. $pluginManager->deactivatePackage($initial, true);
  17370. $pluginManager->registerPackage($target, true);
  17371. } catch (\Exception $e) {
  17372. $self->rollbackInstall($e, $repo, $target);
  17373. }
  17374. });
  17375. }
  17376. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17377. {
  17378. $this->composer->getPluginManager()->uninstallPackage($package, true);
  17379. return parent::uninstall($repo, $package);
  17380. }
  17381. public function rollbackInstall(\Exception $e, InstalledRepositoryInterface $repo, PackageInterface $package)
  17382. {
  17383. $this->io->writeError('Plugin initialization failed ('.$e->getMessage().'), uninstalling plugin');
  17384. parent::uninstall($repo, $package);
  17385. throw $e;
  17386. }
  17387. }
  17388. <?php
  17389. namespace Composer\Installer;
  17390. use Composer\Package\PackageInterface;
  17391. use Composer\Downloader\DownloadManager;
  17392. use Composer\Repository\InstalledRepositoryInterface;
  17393. use Composer\Util\Filesystem;
  17394. class ProjectInstaller implements InstallerInterface
  17395. {
  17396. private $installPath;
  17397. private $downloadManager;
  17398. private $filesystem;
  17399. public function __construct($installPath, DownloadManager $dm, Filesystem $fs)
  17400. {
  17401. $this->installPath = rtrim(strtr($installPath, '\\', '/'), '/').'/';
  17402. $this->downloadManager = $dm;
  17403. $this->filesystem = $fs;
  17404. }
  17405. public function supports($packageType)
  17406. {
  17407. return true;
  17408. }
  17409. public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package)
  17410. {
  17411. return false;
  17412. }
  17413. public function download(PackageInterface $package, PackageInterface $prevPackage = null)
  17414. {
  17415. $installPath = $this->installPath;
  17416. if (file_exists($installPath) && !$this->filesystem->isDirEmpty($installPath)) {
  17417. throw new \InvalidArgumentException("Project directory $installPath is not empty.");
  17418. }
  17419. if (!is_dir($installPath)) {
  17420. mkdir($installPath, 0777, true);
  17421. }
  17422. return $this->downloadManager->download($package, $installPath, $prevPackage);
  17423. }
  17424. public function prepare($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17425. {
  17426. return $this->downloadManager->prepare($type, $package, $this->installPath, $prevPackage);
  17427. }
  17428. public function cleanup($type, PackageInterface $package, PackageInterface $prevPackage = null)
  17429. {
  17430. return $this->downloadManager->cleanup($type, $package, $this->installPath, $prevPackage);
  17431. }
  17432. public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
  17433. {
  17434. return $this->downloadManager->install($package, $this->installPath);
  17435. }
  17436. public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
  17437. {
  17438. throw new \InvalidArgumentException("not supported");
  17439. }
  17440. public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
  17441. {
  17442. throw new \InvalidArgumentException("not supported");
  17443. }
  17444. public function getInstallPath(PackageInterface $package)
  17445. {
  17446. return $this->installPath;
  17447. }
  17448. }
  17449. <?php
  17450. namespace Composer\Installer;
  17451. use Composer\IO\IOInterface;
  17452. use Composer\Package\PackageInterface;
  17453. use Composer\Repository\InstalledRepository;
  17454. use Symfony\Component\Console\Formatter\OutputFormatter;
  17455. class SuggestedPackagesReporter
  17456. {
  17457. const MODE_LIST = 1;
  17458. const MODE_BY_PACKAGE = 2;
  17459. const MODE_BY_SUGGESTION = 4;
  17460. protected $suggestedPackages = array();
  17461. private $io;
  17462. public function __construct(IOInterface $io)
  17463. {
  17464. $this->io = $io;
  17465. }
  17466. public function getPackages()
  17467. {
  17468. return $this->suggestedPackages;
  17469. }
  17470. public function addPackage($source, $target, $reason)
  17471. {
  17472. $this->suggestedPackages[] = array(
  17473. 'source' => $source,
  17474. 'target' => $target,
  17475. 'reason' => $reason,
  17476. );
  17477. return $this;
  17478. }
  17479. public function addSuggestionsFromPackage(PackageInterface $package)
  17480. {
  17481. $source = $package->getPrettyName();
  17482. foreach ($package->getSuggests() as $target => $reason) {
  17483. $this->addPackage(
  17484. $source,
  17485. $target,
  17486. $reason
  17487. );
  17488. }
  17489. return $this;
  17490. }
  17491. public function output($mode, InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17492. {
  17493. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  17494. $suggesters = array();
  17495. $suggested = array();
  17496. foreach ($suggestedPackages as $suggestion) {
  17497. $suggesters[$suggestion['source']][$suggestion['target']] = $suggestion['reason'];
  17498. $suggested[$suggestion['target']][$suggestion['source']] = $suggestion['reason'];
  17499. }
  17500. ksort($suggesters);
  17501. ksort($suggested);
  17502. if ($mode & self::MODE_LIST) {
  17503. foreach (array_keys($suggested) as $name) {
  17504. $this->io->write(sprintf('<info>%s</info>', $name));
  17505. }
  17506. return 0;
  17507. }
  17508. if ($mode & self::MODE_BY_PACKAGE) {
  17509. foreach ($suggesters as $suggester => $suggestions) {
  17510. $this->io->write(sprintf('<comment>%s</comment> suggests:', $suggester));
  17511. foreach ($suggestions as $suggestion => $reason) {
  17512. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggestion, $this->escapeOutput($reason)));
  17513. }
  17514. $this->io->write('');
  17515. }
  17516. }
  17517. if ($mode & self::MODE_BY_SUGGESTION) {
  17518. if ($mode & self::MODE_BY_PACKAGE) {
  17519. $this->io->write(str_repeat('-', 78));
  17520. }
  17521. foreach ($suggested as $suggestion => $suggesters) {
  17522. $this->io->write(sprintf('<comment>%s</comment> is suggested by:', $suggestion));
  17523. foreach ($suggesters as $suggester => $reason) {
  17524. $this->io->write(sprintf(' - <info>%s</info>' . ($reason ? ': %s' : ''), $suggester, $this->escapeOutput($reason)));
  17525. }
  17526. $this->io->write('');
  17527. }
  17528. }
  17529. if ($onlyDependentsOf) {
  17530. $allSuggestedPackages = $this->getFilteredSuggestions($installedRepo);
  17531. $diff = count($allSuggestedPackages) - count($suggestedPackages);
  17532. if ($diff) {
  17533. $this->io->write('<info>'.$diff.' additional suggestions</info> by transitive dependencies can be shown with <info>--all</info>');
  17534. }
  17535. }
  17536. return $this;
  17537. }
  17538. public function outputMinimalistic(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17539. {
  17540. $suggestedPackages = $this->getFilteredSuggestions($installedRepo, $onlyDependentsOf);
  17541. if ($suggestedPackages) {
  17542. $this->io->writeError('<info>'.count($suggestedPackages).' package suggestions were added by new dependencies, use `composer suggest` to see details.</info>');
  17543. }
  17544. return $this;
  17545. }
  17546. private function getFilteredSuggestions(InstalledRepository $installedRepo = null, PackageInterface $onlyDependentsOf = null)
  17547. {
  17548. $suggestedPackages = $this->getPackages();
  17549. $installedNames = array();
  17550. if (null !== $installedRepo && !empty($suggestedPackages)) {
  17551. foreach ($installedRepo->getPackages() as $package) {
  17552. $installedNames = array_merge(
  17553. $installedNames,
  17554. $package->getNames()
  17555. );
  17556. }
  17557. }
  17558. $sourceFilter = array();
  17559. if ($onlyDependentsOf) {
  17560. $sourceFilter = array_map(function ($link) {
  17561. return $link->getTarget();
  17562. }, array_merge($onlyDependentsOf->getRequires(), $onlyDependentsOf->getDevRequires()));
  17563. $sourceFilter[] = $onlyDependentsOf->getName();
  17564. }
  17565. $suggestions = array();
  17566. foreach ($suggestedPackages as $suggestion) {
  17567. if (in_array($suggestion['target'], $installedNames) || ($sourceFilter && !in_array($suggestion['source'], $sourceFilter))) {
  17568. continue;
  17569. }
  17570. $suggestions[] = $suggestion;
  17571. }
  17572. return $suggestions;
  17573. }
  17574. private function escapeOutput($string)
  17575. {
  17576. return OutputFormatter::escape(
  17577. $this->removeControlCharacters($string)
  17578. );
  17579. }
  17580. private function removeControlCharacters($string)
  17581. {
  17582. return preg_replace(
  17583. '/[[:cntrl:]]/',
  17584. '',
  17585. str_replace("\n", ' ', $string)
  17586. );
  17587. }
  17588. }
  17589. <?php
  17590. namespace Composer\Json;
  17591. use JsonSchema\Validator;
  17592. use Seld\JsonLint\JsonParser;
  17593. use Seld\JsonLint\ParsingException;
  17594. use Composer\Util\HttpDownloader;
  17595. use Composer\IO\IOInterface;
  17596. use Composer\Downloader\TransportException;
  17597. class JsonFile
  17598. {
  17599. const LAX_SCHEMA = 1;
  17600. const STRICT_SCHEMA = 2;
  17601. const JSON_UNESCAPED_SLASHES = 64;
  17602. const JSON_PRETTY_PRINT = 128;
  17603. const JSON_UNESCAPED_UNICODE = 256;
  17604. const COMPOSER_SCHEMA_PATH = '/../../../res/composer-schema.json';
  17605. private $path;
  17606. private $httpDownloader;
  17607. private $io;
  17608. public function __construct($path, HttpDownloader $httpDownloader = null, IOInterface $io = null)
  17609. {
  17610. $this->path = $path;
  17611. if (null === $httpDownloader && preg_match('{^https?://}i', $path)) {
  17612. throw new \InvalidArgumentException('http urls require a HttpDownloader instance to be passed');
  17613. }
  17614. $this->httpDownloader = $httpDownloader;
  17615. $this->io = $io;
  17616. }
  17617. public function getPath()
  17618. {
  17619. return $this->path;
  17620. }
  17621. public function exists()
  17622. {
  17623. return is_file($this->path);
  17624. }
  17625. public function read()
  17626. {
  17627. try {
  17628. if ($this->httpDownloader) {
  17629. $json = $this->httpDownloader->get($this->path)->getBody();
  17630. } else {
  17631. if ($this->io && $this->io->isDebug()) {
  17632. $realpathInfo = '';
  17633. $realpath = realpath($this->path);
  17634. if (false !== $realpath && $realpath !== $this->path) {
  17635. $realpathInfo = ' (' . $realpath . ')';
  17636. }
  17637. $this->io->writeError('Reading ' . $this->path . $realpathInfo);
  17638. }
  17639. $json = file_get_contents($this->path);
  17640. }
  17641. } catch (TransportException $e) {
  17642. throw new \RuntimeException($e->getMessage(), 0, $e);
  17643. } catch (\Exception $e) {
  17644. throw new \RuntimeException('Could not read '.$this->path."\n\n".$e->getMessage());
  17645. }
  17646. return static::parseJson($json, $this->path);
  17647. }
  17648. public function write(array $hash, $options = 448)
  17649. {
  17650. if ($this->path === 'php://memory') {
  17651. file_put_contents($this->path, static::encode($hash, $options));
  17652. return;
  17653. }
  17654. $dir = dirname($this->path);
  17655. if (!is_dir($dir)) {
  17656. if (file_exists($dir)) {
  17657. throw new \UnexpectedValueException(
  17658. realpath($dir).' exists and is not a directory.'
  17659. );
  17660. }
  17661. if (!@mkdir($dir, 0777, true)) {
  17662. throw new \UnexpectedValueException(
  17663. $dir.' does not exist and could not be created.'
  17664. );
  17665. }
  17666. }
  17667. $retries = 3;
  17668. while ($retries--) {
  17669. try {
  17670. $this->filePutContentsIfModified($this->path, static::encode($hash, $options). ($options & self::JSON_PRETTY_PRINT ? "\n" : ''));
  17671. break;
  17672. } catch (\Exception $e) {
  17673. if ($retries) {
  17674. usleep(500000);
  17675. continue;
  17676. }
  17677. throw $e;
  17678. }
  17679. }
  17680. }
  17681. private function filePutContentsIfModified($path, $content)
  17682. {
  17683. $currentContent = @file_get_contents($path);
  17684. if (!$currentContent || ($currentContent != $content)) {
  17685. return file_put_contents($path, $content);
  17686. }
  17687. return 0;
  17688. }
  17689. public function validateSchema($schema = self::STRICT_SCHEMA, $schemaFile = null)
  17690. {
  17691. $content = file_get_contents($this->path);
  17692. $data = json_decode($content);
  17693. if (null === $data && 'null' !== $content) {
  17694. self::validateSyntax($content, $this->path);
  17695. }
  17696. if (null === $schemaFile) {
  17697. $schemaFile = __DIR__ . self::COMPOSER_SCHEMA_PATH;
  17698. }
  17699. if (false === strpos($schemaFile, '://')) {
  17700. $schemaFile = 'file://' . $schemaFile;
  17701. }
  17702. $schemaData = (object) array('$ref' => $schemaFile);
  17703. if ($schema === self::LAX_SCHEMA) {
  17704. $schemaData->additionalProperties = true;
  17705. $schemaData->required = array();
  17706. }
  17707. $validator = new Validator();
  17708. $validator->check($data, $schemaData);
  17709. if (!$validator->isValid()) {
  17710. $errors = array();
  17711. foreach ((array) $validator->getErrors() as $error) {
  17712. $errors[] = ($error['property'] ? $error['property'].' : ' : '').$error['message'];
  17713. }
  17714. throw new JsonValidationException('"'.$this->path.'" does not match the expected JSON schema', $errors);
  17715. }
  17716. return true;
  17717. }
  17718. public static function encode($data, $options = 448)
  17719. {
  17720. if (PHP_VERSION_ID >= 50400) {
  17721. $json = json_encode($data, $options);
  17722. if (false === $json) {
  17723. self::throwEncodeError(json_last_error());
  17724. }
  17725. if (PHP_VERSION_ID < 50428 || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50512) || (defined('JSON_C_VERSION') && version_compare(phpversion('json'), '1.3.6', '<'))) {
  17726. $json = preg_replace('/\[\s+\]/', '[]', $json);
  17727. $json = preg_replace('/\{\s+\}/', '{}', $json);
  17728. }
  17729. return $json;
  17730. }
  17731. $json = json_encode($data);
  17732. if (false === $json) {
  17733. self::throwEncodeError(json_last_error());
  17734. }
  17735. $prettyPrint = (bool) ($options & self::JSON_PRETTY_PRINT);
  17736. $unescapeUnicode = (bool) ($options & self::JSON_UNESCAPED_UNICODE);
  17737. $unescapeSlashes = (bool) ($options & self::JSON_UNESCAPED_SLASHES);
  17738. if (!$prettyPrint && !$unescapeUnicode && !$unescapeSlashes) {
  17739. return $json;
  17740. }
  17741. return JsonFormatter::format($json, $unescapeUnicode, $unescapeSlashes);
  17742. }
  17743. private static function throwEncodeError($code)
  17744. {
  17745. switch ($code) {
  17746. case JSON_ERROR_DEPTH:
  17747. $msg = 'Maximum stack depth exceeded';
  17748. break;
  17749. case JSON_ERROR_STATE_MISMATCH:
  17750. $msg = 'Underflow or the modes mismatch';
  17751. break;
  17752. case JSON_ERROR_CTRL_CHAR:
  17753. $msg = 'Unexpected control character found';
  17754. break;
  17755. case JSON_ERROR_UTF8:
  17756. $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  17757. break;
  17758. default:
  17759. $msg = 'Unknown error';
  17760. }
  17761. throw new \RuntimeException('JSON encoding failed: '.$msg);
  17762. }
  17763. public static function parseJson($json, $file = null)
  17764. {
  17765. if (null === $json) {
  17766. return;
  17767. }
  17768. $data = json_decode($json, true);
  17769. if (null === $data && JSON_ERROR_NONE !== json_last_error()) {
  17770. self::validateSyntax($json, $file);
  17771. }
  17772. return $data;
  17773. }
  17774. protected static function validateSyntax($json, $file = null)
  17775. {
  17776. $parser = new JsonParser();
  17777. $result = $parser->lint($json);
  17778. if (null === $result) {
  17779. if (defined('JSON_ERROR_UTF8') && JSON_ERROR_UTF8 === json_last_error()) {
  17780. throw new \UnexpectedValueException('"'.$file.'" is not UTF-8, could not parse as JSON');
  17781. }
  17782. return true;
  17783. }
  17784. throw new ParsingException('"'.$file.'" does not contain valid JSON'."\n".$result->getMessage(), $result->getDetails());
  17785. }
  17786. }
  17787. <?php
  17788. namespace Composer\Json;
  17789. class JsonFormatter
  17790. {
  17791. public static function format($json, $unescapeUnicode, $unescapeSlashes)
  17792. {
  17793. $result = '';
  17794. $pos = 0;
  17795. $strLen = strlen($json);
  17796. $indentStr = ' ';
  17797. $newLine = "\n";
  17798. $outOfQuotes = true;
  17799. $buffer = '';
  17800. $noescape = true;
  17801. for ($i = 0; $i < $strLen; $i++) {
  17802. $char = substr($json, $i, 1);
  17803. if ('"' === $char && $noescape) {
  17804. $outOfQuotes = !$outOfQuotes;
  17805. }
  17806. if (!$outOfQuotes) {
  17807. $buffer .= $char;
  17808. $noescape = '\\' === $char ? !$noescape : true;
  17809. continue;
  17810. }
  17811. if ('' !== $buffer) {
  17812. if ($unescapeSlashes) {
  17813. $buffer = str_replace('\\/', '/', $buffer);
  17814. }
  17815. if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
  17816. $buffer = preg_replace_callback('/(\\\\+)u([0-9a-f]{4})/i', function ($match) {
  17817. $l = strlen($match[1]);
  17818. if ($l % 2) {
  17819. $code = hexdec($match[2]);
  17820. if (0xD800 <= $code && 0xDFFF >= $code) {
  17821. return $match[0];
  17822. }
  17823. return str_repeat('\\', $l - 1) . mb_convert_encoding(
  17824. pack('H*', $match[2]),
  17825. 'UTF-8',
  17826. 'UCS-2BE'
  17827. );
  17828. }
  17829. return $match[0];
  17830. }, $buffer);
  17831. }
  17832. $result .= $buffer.$char;
  17833. $buffer = '';
  17834. continue;
  17835. }
  17836. if (':' === $char) {
  17837. $char .= ' ';
  17838. } elseif ('}' === $char || ']' === $char) {
  17839. $pos--;
  17840. $prevChar = substr($json, $i - 1, 1);
  17841. if ('{' !== $prevChar && '[' !== $prevChar) {
  17842. $result .= $newLine;
  17843. for ($j = 0; $j < $pos; $j++) {
  17844. $result .= $indentStr;
  17845. }
  17846. } else {
  17847. $result = rtrim($result);
  17848. }
  17849. }
  17850. $result .= $char;
  17851. if (',' === $char || '{' === $char || '[' === $char) {
  17852. $result .= $newLine;
  17853. if ('{' === $char || '[' === $char) {
  17854. $pos++;
  17855. }
  17856. for ($j = 0; $j < $pos; $j++) {
  17857. $result .= $indentStr;
  17858. }
  17859. }
  17860. }
  17861. return $result;
  17862. }
  17863. }
  17864. <?php
  17865. namespace Composer\Json;
  17866. use Composer\Repository\PlatformRepository;
  17867. class JsonManipulator
  17868. {
  17869. private static $DEFINES = '(?(DEFINE)
  17870. (?<number> -? (?= [1-9]|0(?!\d) ) \d++ (\.\d++)? ([eE] [+-]?+ \d++)? )
  17871. (?<boolean> true | false | null )
  17872. (?<string> " ([^"\\\\]*+ | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9A-Fa-f]{4} )* " )
  17873. (?<array> \[ (?: (?&json) \s*+ (?: , (?&json) \s*+ )*+ )?+ \s*+ \] )
  17874. (?<pair> \s*+ (?&string) \s*+ : (?&json) \s*+ )
  17875. (?<object> \{ (?: (?&pair) (?: , (?&pair) )*+ )?+ \s*+ \} )
  17876. (?<json> \s*+ (?: (?&number) | (?&boolean) | (?&string) | (?&array) | (?&object) ) )
  17877. )';
  17878. private $contents;
  17879. private $newline;
  17880. private $indent;
  17881. public function __construct($contents)
  17882. {
  17883. $contents = trim($contents);
  17884. if ($contents === '') {
  17885. $contents = '{}';
  17886. }
  17887. if (!$this->pregMatch('#^\{(.*)\}$#s', $contents)) {
  17888. throw new \InvalidArgumentException('The json file must be an object ({})');
  17889. }
  17890. $this->newline = false !== strpos($contents, "\r\n") ? "\r\n" : "\n";
  17891. $this->contents = $contents === '{}' ? '{' . $this->newline . '}' : $contents;
  17892. $this->detectIndenting();
  17893. }
  17894. public function getContents()
  17895. {
  17896. return $this->contents . $this->newline;
  17897. }
  17898. public function addLink($type, $package, $constraint, $sortPackages = false)
  17899. {
  17900. $decoded = JsonFile::parseJson($this->contents);
  17901. if (!isset($decoded[$type])) {
  17902. return $this->addMainKey($type, array($package => $constraint));
  17903. }
  17904. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  17905. '(?P<property>'.preg_quote(JsonFile::encode($type)).'\s*:\s*)(?P<value>(?&json))(?P<end>.*)}sx';
  17906. if (!$this->pregMatch($regex, $this->contents, $matches)) {
  17907. return false;
  17908. }
  17909. $links = $matches['value'];
  17910. $packageRegex = str_replace('/', '\\\\?/', preg_quote($package));
  17911. $regex = '{'.self::$DEFINES.'"(?P<package>'.$packageRegex.')"(\s*:\s*)(?&string)}ix';
  17912. if ($this->pregMatch($regex, $links, $packageMatches)) {
  17913. $existingPackage = $packageMatches['package'];
  17914. $packageRegex = str_replace('/', '\\\\?/', preg_quote($existingPackage));
  17915. $links = preg_replace_callback('{'.self::$DEFINES.'"'.$packageRegex.'"(?P<separator>\s*:\s*)(?&string)}ix', function ($m) use ($existingPackage, $constraint) {
  17916. return JsonFile::encode(str_replace('\\/', '/', $existingPackage)) . $m['separator'] . '"' . $constraint . '"';
  17917. }, $links);
  17918. } else {
  17919. if ($this->pregMatch('#^\s*\{\s*\S+.*?(\s*\}\s*)$#s', $links, $match)) {
  17920. $links = preg_replace(
  17921. '{'.preg_quote($match[1]).'$}',
  17922. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $match[1], '\\$'),
  17923. $links
  17924. );
  17925. } else {
  17926. $links = '{' . $this->newline .
  17927. $this->indent . $this->indent . JsonFile::encode($package).': '.JsonFile::encode($constraint) . $this->newline .
  17928. $this->indent . '}';
  17929. }
  17930. }
  17931. if (true === $sortPackages) {
  17932. $requirements = json_decode($links, true);
  17933. $this->sortPackages($requirements);
  17934. $links = $this->format($requirements);
  17935. }
  17936. $this->contents = $matches['start'] . $matches['property'] . $links . $matches['end'];
  17937. return true;
  17938. }
  17939. private function sortPackages(array &$packages = array())
  17940. {
  17941. $prefix = function ($requirement) {
  17942. if (PlatformRepository::isPlatformPackage($requirement)) {
  17943. return preg_replace(
  17944. array(
  17945. '/^php/',
  17946. '/^hhvm/',
  17947. '/^ext/',
  17948. '/^lib/',
  17949. '/^\D/',
  17950. ),
  17951. array(
  17952. '0-$0',
  17953. '1-$0',
  17954. '2-$0',
  17955. '3-$0',
  17956. '4-$0',
  17957. ),
  17958. $requirement
  17959. );
  17960. }
  17961. return '5-'.$requirement;
  17962. };
  17963. uksort($packages, function ($a, $b) use ($prefix) {
  17964. return strnatcmp($prefix($a), $prefix($b));
  17965. });
  17966. }
  17967. public function addRepository($name, $config, $append = true)
  17968. {
  17969. return $this->addSubNode('repositories', $name, $config, $append);
  17970. }
  17971. public function removeRepository($name)
  17972. {
  17973. return $this->removeSubNode('repositories', $name);
  17974. }
  17975. public function addConfigSetting($name, $value)
  17976. {
  17977. return $this->addSubNode('config', $name, $value);
  17978. }
  17979. public function removeConfigSetting($name)
  17980. {
  17981. return $this->removeSubNode('config', $name);
  17982. }
  17983. public function addProperty($name, $value)
  17984. {
  17985. if (strpos($name, 'suggest.') === 0) {
  17986. return $this->addSubNode('suggest', substr($name, 8), $value);
  17987. }
  17988. if (strpos($name, 'extra.') === 0) {
  17989. return $this->addSubNode('extra', substr($name, 6), $value);
  17990. }
  17991. if (strpos($name, 'scripts.') === 0) {
  17992. return $this->addSubNode('scripts', substr($name, 8), $value);
  17993. }
  17994. return $this->addMainKey($name, $value);
  17995. }
  17996. public function removeProperty($name)
  17997. {
  17998. if (strpos($name, 'suggest.') === 0) {
  17999. return $this->removeSubNode('suggest', substr($name, 8));
  18000. }
  18001. if (strpos($name, 'extra.') === 0) {
  18002. return $this->removeSubNode('extra', substr($name, 6));
  18003. }
  18004. if (strpos($name, 'scripts.') === 0) {
  18005. return $this->removeSubNode('scripts', substr($name, 8));
  18006. }
  18007. return $this->removeMainKey($name);
  18008. }
  18009. public function addSubNode($mainNode, $name, $value, $append = true)
  18010. {
  18011. $decoded = JsonFile::parseJson($this->contents);
  18012. $subName = null;
  18013. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  18014. list($name, $subName) = explode('.', $name, 2);
  18015. }
  18016. if (!isset($decoded[$mainNode])) {
  18017. if ($subName !== null) {
  18018. $this->addMainKey($mainNode, array($name => array($subName => $value)));
  18019. } else {
  18020. $this->addMainKey($mainNode, array($name => $value));
  18021. }
  18022. return true;
  18023. }
  18024. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  18025. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  18026. try {
  18027. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  18028. return false;
  18029. }
  18030. } catch (\RuntimeException $e) {
  18031. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  18032. return false;
  18033. }
  18034. throw $e;
  18035. }
  18036. $children = $match['content'];
  18037. if (!@json_decode($children)) {
  18038. return false;
  18039. }
  18040. $that = $this;
  18041. $childRegex = '{'.self::$DEFINES.'(?P<start>"'.preg_quote($name).'"\s*:\s*)(?P<content>(?&json))(?P<end>,?)}x';
  18042. if ($this->pregMatch($childRegex, $children, $matches)) {
  18043. $children = preg_replace_callback($childRegex, function ($matches) use ($subName, $value, $that) {
  18044. if ($subName !== null) {
  18045. $curVal = json_decode($matches['content'], true);
  18046. if (!is_array($curVal)) {
  18047. $curVal = array();
  18048. }
  18049. $curVal[$subName] = $value;
  18050. $value = $curVal;
  18051. }
  18052. return $matches['start'] . $that->format($value, 1) . $matches['end'];
  18053. }, $children);
  18054. } else {
  18055. $this->pregMatch('#^{ (?P<leadingspace>\s*?) (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $children, $match);
  18056. $whitespace = '';
  18057. if (!empty($match['trailingspace'])) {
  18058. $whitespace = $match['trailingspace'];
  18059. }
  18060. if (!empty($match['content'])) {
  18061. if ($subName !== null) {
  18062. $value = array($subName => $value);
  18063. }
  18064. if ($append) {
  18065. $children = preg_replace(
  18066. '#'.$whitespace.'}$#',
  18067. addcslashes(',' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}', '\\$'),
  18068. $children
  18069. );
  18070. } else {
  18071. $whitespace = '';
  18072. if (!empty($match['leadingspace'])) {
  18073. $whitespace = $match['leadingspace'];
  18074. }
  18075. $children = preg_replace(
  18076. '#^{'.$whitespace.'#',
  18077. addcslashes('{' . $whitespace . JsonFile::encode($name).': '.$this->format($value, 1) . ',' . $this->newline . $this->indent . $this->indent, '\\$'),
  18078. $children
  18079. );
  18080. }
  18081. } else {
  18082. if ($subName !== null) {
  18083. $value = array($subName => $value);
  18084. }
  18085. $children = '{' . $this->newline . $this->indent . $this->indent . JsonFile::encode($name).': '.$this->format($value, 1) . $whitespace . '}';
  18086. }
  18087. }
  18088. $this->contents = preg_replace_callback($nodeRegex, function ($m) use ($children) {
  18089. return $m['start'] . $children . $m['end'];
  18090. }, $this->contents);
  18091. return true;
  18092. }
  18093. public function removeSubNode($mainNode, $name)
  18094. {
  18095. $decoded = JsonFile::parseJson($this->contents);
  18096. if (empty($decoded[$mainNode])) {
  18097. return true;
  18098. }
  18099. $nodeRegex = '{'.self::$DEFINES.'^(?P<start> \s* \{ \s* (?: (?&string) \s* : (?&json) \s* , \s* )*?'.
  18100. preg_quote(JsonFile::encode($mainNode)).'\s*:\s*)(?P<content>(?&object))(?P<end>.*)}sx';
  18101. try {
  18102. if (!$this->pregMatch($nodeRegex, $this->contents, $match)) {
  18103. return false;
  18104. }
  18105. } catch (\RuntimeException $e) {
  18106. if ($e->getCode() === PREG_BACKTRACK_LIMIT_ERROR) {
  18107. return false;
  18108. }
  18109. throw $e;
  18110. }
  18111. $children = $match['content'];
  18112. if (!@json_decode($children, true)) {
  18113. return false;
  18114. }
  18115. $subName = null;
  18116. if (in_array($mainNode, array('config', 'extra', 'scripts')) && false !== strpos($name, '.')) {
  18117. list($name, $subName) = explode('.', $name, 2);
  18118. }
  18119. if (!isset($decoded[$mainNode][$name]) || ($subName && !isset($decoded[$mainNode][$name][$subName]))) {
  18120. return true;
  18121. }
  18122. $keyRegex = str_replace('/', '\\\\?/', preg_quote($name));
  18123. if ($this->pregMatch('{"'.$keyRegex.'"\s*:}i', $children)) {
  18124. if (preg_match_all('{'.self::$DEFINES.'"'.$keyRegex.'"\s*:\s*(?:(?&json))}x', $children, $matches)) {
  18125. $bestMatch = '';
  18126. foreach ($matches[0] as $match) {
  18127. if (strlen($bestMatch) < strlen($match)) {
  18128. $bestMatch = $match;
  18129. }
  18130. }
  18131. $childrenClean = preg_replace('{,\s*'.preg_quote($bestMatch).'}i', '', $children, -1, $count);
  18132. if (1 !== $count) {
  18133. $childrenClean = preg_replace('{'.preg_quote($bestMatch).'\s*,?\s*}i', '', $childrenClean, -1, $count);
  18134. if (1 !== $count) {
  18135. return false;
  18136. }
  18137. }
  18138. }
  18139. } else {
  18140. $childrenClean = $children;
  18141. }
  18142. if (!isset($childrenClean)) {
  18143. throw new \InvalidArgumentException("JsonManipulator: \$childrenClean is not defined. Please report at https://github.com/composer/composer/issues/new.");
  18144. }
  18145. $this->pregMatch('#^{ \s*? (?P<content>\S+.*?)? (?P<trailingspace>\s*) }$#sx', $childrenClean, $match);
  18146. if (empty($match['content'])) {
  18147. $newline = $this->newline;
  18148. $indent = $this->indent;
  18149. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($indent, $newline) {
  18150. return $matches['start'] . '{' . $newline . $indent . '}' . $matches['end'];
  18151. }, $this->contents);
  18152. if ($subName !== null) {
  18153. $curVal = json_decode($children, true);
  18154. unset($curVal[$name][$subName]);
  18155. $this->addSubNode($mainNode, $name, $curVal[$name]);
  18156. }
  18157. return true;
  18158. }
  18159. $that = $this;
  18160. $this->contents = preg_replace_callback($nodeRegex, function ($matches) use ($that, $name, $subName, $childrenClean) {
  18161. if ($subName !== null) {
  18162. $curVal = json_decode($matches['content'], true);
  18163. unset($curVal[$name][$subName]);
  18164. $childrenClean = $that->format($curVal);
  18165. }
  18166. return $matches['start'] . $childrenClean . $matches['end'];
  18167. }, $this->contents);
  18168. return true;
  18169. }
  18170. public function addMainKey($key, $content)
  18171. {
  18172. $decoded = JsonFile::parseJson($this->contents);
  18173. $content = $this->format($content);
  18174. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  18175. '(?P<key>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))(?P<end>.*)}sx';
  18176. if (isset($decoded[$key]) && $this->pregMatch($regex, $this->contents, $matches)) {
  18177. if (!@json_decode('{'.$matches['key'].'}')) {
  18178. return false;
  18179. }
  18180. $this->contents = $matches['start'] . JsonFile::encode($key).': '.$content . $matches['end'];
  18181. return true;
  18182. }
  18183. if ($this->pregMatch('#[^{\s](\s*)\}$#', $this->contents, $match)) {
  18184. $this->contents = preg_replace(
  18185. '#'.$match[1].'\}$#',
  18186. addcslashes(',' . $this->newline . $this->indent . JsonFile::encode($key). ': '. $content . $this->newline . '}', '\\$'),
  18187. $this->contents
  18188. );
  18189. return true;
  18190. }
  18191. $this->contents = preg_replace(
  18192. '#\}$#',
  18193. addcslashes($this->indent . JsonFile::encode($key). ': '.$content . $this->newline . '}', '\\$'),
  18194. $this->contents
  18195. );
  18196. return true;
  18197. }
  18198. public function removeMainKey($key)
  18199. {
  18200. $decoded = JsonFile::parseJson($this->contents);
  18201. if (!array_key_exists($key, $decoded)) {
  18202. return true;
  18203. }
  18204. $regex = '{'.self::$DEFINES.'^(?P<start>\s*\{\s*(?:(?&string)\s*:\s*(?&json)\s*,\s*)*?)'.
  18205. '(?P<removal>'.preg_quote(JsonFile::encode($key)).'\s*:\s*(?&json))\s*,?\s*(?P<end>.*)}sx';
  18206. if ($this->pregMatch($regex, $this->contents, $matches)) {
  18207. if (!@json_decode('{'.$matches['removal'].'}')) {
  18208. return false;
  18209. }
  18210. if (preg_match('#,\s*$#', $matches['start']) && preg_match('#^\}$#', $matches['end'])) {
  18211. $matches['start'] = rtrim(preg_replace('#,(\s*)$#', '$1', $matches['start']), $this->indent);
  18212. }
  18213. $this->contents = $matches['start'] . $matches['end'];
  18214. if (preg_match('#^\{\s*\}\s*$#', $this->contents)) {
  18215. $this->contents = "{\n}";
  18216. }
  18217. return true;
  18218. }
  18219. return false;
  18220. }
  18221. public function removeMainKeyIfEmpty($key)
  18222. {
  18223. $decoded = JsonFile::parseJson($this->contents);
  18224. if (!array_key_exists($key, $decoded)) {
  18225. return true;
  18226. }
  18227. if (is_array($decoded[$key]) && count($decoded[$key]) === 0) {
  18228. return $this->removeMainKey($key);
  18229. }
  18230. return true;
  18231. }
  18232. public function format($data, $depth = 0)
  18233. {
  18234. if (is_array($data)) {
  18235. reset($data);
  18236. if (is_numeric(key($data))) {
  18237. foreach ($data as $key => $val) {
  18238. $data[$key] = $this->format($val, $depth + 1);
  18239. }
  18240. return '['.implode(', ', $data).']';
  18241. }
  18242. $out = '{' . $this->newline;
  18243. $elems = array();
  18244. foreach ($data as $key => $val) {
  18245. $elems[] = str_repeat($this->indent, $depth + 2) . JsonFile::encode($key). ': '.$this->format($val, $depth + 1);
  18246. }
  18247. return $out . implode(','.$this->newline, $elems) . $this->newline . str_repeat($this->indent, $depth + 1) . '}';
  18248. }
  18249. return JsonFile::encode($data);
  18250. }
  18251. protected function detectIndenting()
  18252. {
  18253. if ($this->pregMatch('{^([ \t]+)"}m', $this->contents, $match)) {
  18254. $this->indent = $match[1];
  18255. } else {
  18256. $this->indent = ' ';
  18257. }
  18258. }
  18259. protected function pregMatch($re, $str, &$matches = array())
  18260. {
  18261. $count = preg_match($re, $str, $matches);
  18262. if ($count === false) {
  18263. switch (preg_last_error()) {
  18264. case PREG_NO_ERROR:
  18265. throw new \RuntimeException('Failed to execute regex: PREG_NO_ERROR', PREG_NO_ERROR);
  18266. case PREG_INTERNAL_ERROR:
  18267. throw new \RuntimeException('Failed to execute regex: PREG_INTERNAL_ERROR', PREG_INTERNAL_ERROR);
  18268. case PREG_BACKTRACK_LIMIT_ERROR:
  18269. throw new \RuntimeException('Failed to execute regex: PREG_BACKTRACK_LIMIT_ERROR', PREG_BACKTRACK_LIMIT_ERROR);
  18270. case PREG_RECURSION_LIMIT_ERROR:
  18271. throw new \RuntimeException('Failed to execute regex: PREG_RECURSION_LIMIT_ERROR', PREG_RECURSION_LIMIT_ERROR);
  18272. case PREG_BAD_UTF8_ERROR:
  18273. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_ERROR', PREG_BAD_UTF8_ERROR);
  18274. case PREG_BAD_UTF8_OFFSET_ERROR:
  18275. throw new \RuntimeException('Failed to execute regex: PREG_BAD_UTF8_OFFSET_ERROR', PREG_BAD_UTF8_OFFSET_ERROR);
  18276. case 6:
  18277. if (PHP_VERSION_ID > 70000) {
  18278. throw new \RuntimeException('Failed to execute regex: PREG_JIT_STACKLIMIT_ERROR', 6);
  18279. }
  18280. default:
  18281. throw new \RuntimeException('Failed to execute regex: Unknown error');
  18282. }
  18283. }
  18284. return $count;
  18285. }
  18286. }
  18287. <?php
  18288. namespace Composer\Json;
  18289. use Exception;
  18290. class JsonValidationException extends Exception
  18291. {
  18292. protected $errors;
  18293. public function __construct($message, $errors = array(), Exception $previous = null)
  18294. {
  18295. $this->errors = $errors;
  18296. parent::__construct($message, 0, $previous);
  18297. }
  18298. public function getErrors()
  18299. {
  18300. return $this->errors;
  18301. }
  18302. }
  18303. <?php
  18304. namespace Composer\Package;
  18305. use Composer\Semver\Constraint\Constraint;
  18306. use Composer\Package\Version\VersionParser;
  18307. class AliasPackage extends BasePackage implements CompletePackageInterface
  18308. {
  18309. protected $version;
  18310. protected $prettyVersion;
  18311. protected $dev;
  18312. protected $rootPackageAlias = false;
  18313. protected $stability;
  18314. protected $hasSelfVersionRequires = false;
  18315. protected $aliasOf;
  18316. protected $requires;
  18317. protected $devRequires;
  18318. protected $conflicts;
  18319. protected $provides;
  18320. protected $replaces;
  18321. public function __construct(PackageInterface $aliasOf, $version, $prettyVersion)
  18322. {
  18323. parent::__construct($aliasOf->getName());
  18324. $this->version = $version;
  18325. $this->prettyVersion = $prettyVersion;
  18326. $this->aliasOf = $aliasOf;
  18327. $this->stability = VersionParser::parseStability($version);
  18328. $this->dev = $this->stability === 'dev';
  18329. foreach (Link::$TYPES as $type) {
  18330. $links = $aliasOf->{'get' . ucfirst($type)}();
  18331. $this->$type = $this->replaceSelfVersionDependencies($links, $type);
  18332. }
  18333. }
  18334. public function getAliasOf()
  18335. {
  18336. return $this->aliasOf;
  18337. }
  18338. public function getVersion()
  18339. {
  18340. return $this->version;
  18341. }
  18342. public function getStability()
  18343. {
  18344. return $this->stability;
  18345. }
  18346. public function getPrettyVersion()
  18347. {
  18348. return $this->prettyVersion;
  18349. }
  18350. public function isDev()
  18351. {
  18352. return $this->dev;
  18353. }
  18354. public function getRequires()
  18355. {
  18356. return $this->requires;
  18357. }
  18358. public function getConflicts()
  18359. {
  18360. return $this->conflicts;
  18361. }
  18362. public function getProvides()
  18363. {
  18364. return $this->provides;
  18365. }
  18366. public function getReplaces()
  18367. {
  18368. return $this->replaces;
  18369. }
  18370. public function getDevRequires()
  18371. {
  18372. return $this->devRequires;
  18373. }
  18374. public function setRootPackageAlias($value)
  18375. {
  18376. return $this->rootPackageAlias = $value;
  18377. }
  18378. public function isRootPackageAlias()
  18379. {
  18380. return $this->rootPackageAlias;
  18381. }
  18382. protected function replaceSelfVersionDependencies(array $links, $linkType)
  18383. {
  18384. $prettyVersion = $this->prettyVersion;
  18385. if ($prettyVersion === VersionParser::DEFAULT_BRANCH_ALIAS) {
  18386. $prettyVersion = $this->aliasOf->getPrettyVersion();
  18387. }
  18388. if (\in_array($linkType, array(Link::TYPE_CONFLICT, Link::TYPE_PROVIDE, Link::TYPE_REPLACE), true)) {
  18389. $newLinks = array();
  18390. foreach ($links as $link) {
  18391. if ('self.version' === $link->getPrettyConstraint()) {
  18392. $newLinks[] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  18393. $constraint->setPrettyString($prettyVersion);
  18394. }
  18395. }
  18396. $links = array_merge($links, $newLinks);
  18397. } else {
  18398. foreach ($links as $index => $link) {
  18399. if ('self.version' === $link->getPrettyConstraint()) {
  18400. if ($linkType === Link::TYPE_REQUIRE) {
  18401. $this->hasSelfVersionRequires = true;
  18402. }
  18403. $links[$index] = new Link($link->getSource(), $link->getTarget(), $constraint = new Constraint('=', $this->version), $linkType, $prettyVersion);
  18404. $constraint->setPrettyString($prettyVersion);
  18405. }
  18406. }
  18407. }
  18408. return $links;
  18409. }
  18410. public function hasSelfVersionRequires()
  18411. {
  18412. return $this->hasSelfVersionRequires;
  18413. }
  18414. public function getType()
  18415. {
  18416. return $this->aliasOf->getType();
  18417. }
  18418. public function getTargetDir()
  18419. {
  18420. return $this->aliasOf->getTargetDir();
  18421. }
  18422. public function getExtra()
  18423. {
  18424. return $this->aliasOf->getExtra();
  18425. }
  18426. public function setInstallationSource($type)
  18427. {
  18428. $this->aliasOf->setInstallationSource($type);
  18429. }
  18430. public function getInstallationSource()
  18431. {
  18432. return $this->aliasOf->getInstallationSource();
  18433. }
  18434. public function getSourceType()
  18435. {
  18436. return $this->aliasOf->getSourceType();
  18437. }
  18438. public function getSourceUrl()
  18439. {
  18440. return $this->aliasOf->getSourceUrl();
  18441. }
  18442. public function getSourceUrls()
  18443. {
  18444. return $this->aliasOf->getSourceUrls();
  18445. }
  18446. public function getSourceReference()
  18447. {
  18448. return $this->aliasOf->getSourceReference();
  18449. }
  18450. public function setSourceReference($reference)
  18451. {
  18452. return $this->aliasOf->setSourceReference($reference);
  18453. }
  18454. public function setSourceMirrors($mirrors)
  18455. {
  18456. return $this->aliasOf->setSourceMirrors($mirrors);
  18457. }
  18458. public function getSourceMirrors()
  18459. {
  18460. return $this->aliasOf->getSourceMirrors();
  18461. }
  18462. public function getDistType()
  18463. {
  18464. return $this->aliasOf->getDistType();
  18465. }
  18466. public function getDistUrl()
  18467. {
  18468. return $this->aliasOf->getDistUrl();
  18469. }
  18470. public function getDistUrls()
  18471. {
  18472. return $this->aliasOf->getDistUrls();
  18473. }
  18474. public function getDistReference()
  18475. {
  18476. return $this->aliasOf->getDistReference();
  18477. }
  18478. public function setDistReference($reference)
  18479. {
  18480. return $this->aliasOf->setDistReference($reference);
  18481. }
  18482. public function getDistSha1Checksum()
  18483. {
  18484. return $this->aliasOf->getDistSha1Checksum();
  18485. }
  18486. public function setTransportOptions(array $options)
  18487. {
  18488. return $this->aliasOf->setTransportOptions($options);
  18489. }
  18490. public function getTransportOptions()
  18491. {
  18492. return $this->aliasOf->getTransportOptions();
  18493. }
  18494. public function setDistMirrors($mirrors)
  18495. {
  18496. return $this->aliasOf->setDistMirrors($mirrors);
  18497. }
  18498. public function getDistMirrors()
  18499. {
  18500. return $this->aliasOf->getDistMirrors();
  18501. }
  18502. public function getScripts()
  18503. {
  18504. return $this->aliasOf->getScripts();
  18505. }
  18506. public function getLicense()
  18507. {
  18508. return $this->aliasOf->getLicense();
  18509. }
  18510. public function getAutoload()
  18511. {
  18512. return $this->aliasOf->getAutoload();
  18513. }
  18514. public function getDevAutoload()
  18515. {
  18516. return $this->aliasOf->getDevAutoload();
  18517. }
  18518. public function getIncludePaths()
  18519. {
  18520. return $this->aliasOf->getIncludePaths();
  18521. }
  18522. public function getRepositories()
  18523. {
  18524. return $this->aliasOf->getRepositories();
  18525. }
  18526. public function getReleaseDate()
  18527. {
  18528. return $this->aliasOf->getReleaseDate();
  18529. }
  18530. public function getBinaries()
  18531. {
  18532. return $this->aliasOf->getBinaries();
  18533. }
  18534. public function getKeywords()
  18535. {
  18536. return $this->aliasOf->getKeywords();
  18537. }
  18538. public function getDescription()
  18539. {
  18540. return $this->aliasOf->getDescription();
  18541. }
  18542. public function getHomepage()
  18543. {
  18544. return $this->aliasOf->getHomepage();
  18545. }
  18546. public function getSuggests()
  18547. {
  18548. return $this->aliasOf->getSuggests();
  18549. }
  18550. public function getAuthors()
  18551. {
  18552. return $this->aliasOf->getAuthors();
  18553. }
  18554. public function getSupport()
  18555. {
  18556. return $this->aliasOf->getSupport();
  18557. }
  18558. public function getFunding()
  18559. {
  18560. return $this->aliasOf->getFunding();
  18561. }
  18562. public function getNotificationUrl()
  18563. {
  18564. return $this->aliasOf->getNotificationUrl();
  18565. }
  18566. public function getArchiveName()
  18567. {
  18568. return $this->aliasOf->getArchiveName();
  18569. }
  18570. public function getArchiveExcludes()
  18571. {
  18572. return $this->aliasOf->getArchiveExcludes();
  18573. }
  18574. public function isDefaultBranch()
  18575. {
  18576. return $this->aliasOf->isDefaultBranch();
  18577. }
  18578. public function isAbandoned()
  18579. {
  18580. return $this->aliasOf->isAbandoned();
  18581. }
  18582. public function getReplacementPackage()
  18583. {
  18584. return $this->aliasOf->getReplacementPackage();
  18585. }
  18586. public function __toString()
  18587. {
  18588. return parent::__toString().' ('.($this->rootPackageAlias ? 'root ' : ''). 'alias of '.$this->aliasOf->getVersion().')';
  18589. }
  18590. public function setDistUrl($url)
  18591. {
  18592. return $this->aliasOf->setDistUrl($url);
  18593. }
  18594. public function setDistType($type)
  18595. {
  18596. return $this->aliasOf->setDistType($type);
  18597. }
  18598. public function setSourceDistReferences($reference)
  18599. {
  18600. return $this->aliasOf->setSourceDistReferences($reference);
  18601. }
  18602. }
  18603. <?php
  18604. namespace Composer\Package\Archiver;
  18605. use FilterIterator;
  18606. use PharData;
  18607. class ArchivableFilesFilter extends FilterIterator
  18608. {
  18609. private $dirs = array();
  18610. public function accept()
  18611. {
  18612. $file = $this->getInnerIterator()->current();
  18613. if ($file->isDir()) {
  18614. $this->dirs[] = (string) $file;
  18615. return false;
  18616. }
  18617. return true;
  18618. }
  18619. public function addEmptyDir(PharData $phar, $sources)
  18620. {
  18621. foreach ($this->dirs as $filepath) {
  18622. $localname = str_replace($sources . "/", '', $filepath);
  18623. $phar->addEmptyDir($localname);
  18624. }
  18625. }
  18626. }
  18627. <?php
  18628. namespace Composer\Package\Archiver;
  18629. use Composer\Util\Filesystem;
  18630. use FilesystemIterator;
  18631. use Symfony\Component\Finder\Finder;
  18632. use Symfony\Component\Finder\SplFileInfo;
  18633. class ArchivableFilesFinder extends \FilterIterator
  18634. {
  18635. protected $finder;
  18636. public function __construct($sources, array $excludes, $ignoreFilters = false)
  18637. {
  18638. $fs = new Filesystem();
  18639. $sources = $fs->normalizePath(realpath($sources));
  18640. if ($ignoreFilters) {
  18641. $filters = array();
  18642. } else {
  18643. $filters = array(
  18644. new HgExcludeFilter($sources),
  18645. new GitExcludeFilter($sources),
  18646. new ComposerExcludeFilter($sources, $excludes),
  18647. );
  18648. }
  18649. $this->finder = new Finder();
  18650. $filter = function (\SplFileInfo $file) use ($sources, $filters, $fs) {
  18651. if ($file->isLink() && strpos($file->getRealPath(), $sources) !== 0) {
  18652. return false;
  18653. }
  18654. $relativePath = preg_replace(
  18655. '#^'.preg_quote($sources, '#').'#',
  18656. '',
  18657. $fs->normalizePath($file->getRealPath())
  18658. );
  18659. $exclude = false;
  18660. foreach ($filters as $filter) {
  18661. $exclude = $filter->filter($relativePath, $exclude);
  18662. }
  18663. return !$exclude;
  18664. };
  18665. if (method_exists($filter, 'bindTo')) {
  18666. $filter = $filter->bindTo(null);
  18667. }
  18668. $this->finder
  18669. ->in($sources)
  18670. ->filter($filter)
  18671. ->ignoreVCS(true)
  18672. ->ignoreDotFiles(false);
  18673. parent::__construct($this->finder->getIterator());
  18674. }
  18675. public function accept()
  18676. {
  18677. $current = $this->getInnerIterator()->current();
  18678. if (!$current->isDir()) {
  18679. return true;
  18680. }
  18681. $iterator = new FilesystemIterator($current, FilesystemIterator::SKIP_DOTS);
  18682. return !$iterator->valid();
  18683. }
  18684. }
  18685. <?php
  18686. namespace Composer\Package\Archiver;
  18687. use Composer\Downloader\DownloadManager;
  18688. use Composer\Package\PackageInterface;
  18689. use Composer\Package\RootPackageInterface;
  18690. use Composer\Util\Filesystem;
  18691. use Composer\Util\Loop;
  18692. use Composer\Json\JsonFile;
  18693. class ArchiveManager
  18694. {
  18695. protected $downloadManager;
  18696. protected $loop;
  18697. protected $archivers = array();
  18698. protected $overwriteFiles = true;
  18699. public function __construct(DownloadManager $downloadManager, Loop $loop)
  18700. {
  18701. $this->downloadManager = $downloadManager;
  18702. $this->loop = $loop;
  18703. }
  18704. public function addArchiver(ArchiverInterface $archiver)
  18705. {
  18706. $this->archivers[] = $archiver;
  18707. }
  18708. public function setOverwriteFiles($overwriteFiles)
  18709. {
  18710. $this->overwriteFiles = $overwriteFiles;
  18711. return $this;
  18712. }
  18713. public function getPackageFilename(PackageInterface $package)
  18714. {
  18715. if ($package->getArchiveName()) {
  18716. $baseName = $package->getArchiveName();
  18717. } else {
  18718. $baseName = preg_replace('#[^a-z0-9-_]#i', '-', $package->getName());
  18719. }
  18720. $nameParts = array($baseName);
  18721. if (preg_match('{^[a-f0-9]{40}$}', $package->getDistReference())) {
  18722. array_push($nameParts, $package->getDistReference(), $package->getDistType());
  18723. } else {
  18724. array_push($nameParts, $package->getPrettyVersion(), $package->getDistReference());
  18725. }
  18726. if ($package->getSourceReference()) {
  18727. $nameParts[] = substr(sha1($package->getSourceReference()), 0, 6);
  18728. }
  18729. $name = implode('-', array_filter($nameParts, function ($p) {
  18730. return !empty($p);
  18731. }));
  18732. return str_replace('/', '-', $name);
  18733. }
  18734. public function archive(PackageInterface $package, $format, $targetDir, $fileName = null, $ignoreFilters = false)
  18735. {
  18736. if (empty($format)) {
  18737. throw new \InvalidArgumentException('Format must be specified');
  18738. }
  18739. $usableArchiver = null;
  18740. foreach ($this->archivers as $archiver) {
  18741. if ($archiver->supports($format, $package->getSourceType())) {
  18742. $usableArchiver = $archiver;
  18743. break;
  18744. }
  18745. }
  18746. if (null === $usableArchiver) {
  18747. throw new \RuntimeException(sprintf('No archiver found to support %s format', $format));
  18748. }
  18749. $filesystem = new Filesystem();
  18750. if ($package instanceof RootPackageInterface) {
  18751. $sourcePath = realpath('.');
  18752. } else {
  18753. $sourcePath = sys_get_temp_dir().'/composer_archive'.uniqid();
  18754. $filesystem->ensureDirectoryExists($sourcePath);
  18755. try {
  18756. $promise = $this->downloadManager->download($package, $sourcePath);
  18757. $this->loop->wait(array($promise));
  18758. $this->downloadManager->install($package, $sourcePath);
  18759. } catch (\Exception $e) {
  18760. $filesystem->removeDirectory($sourcePath);
  18761. throw $e;
  18762. }
  18763. if (file_exists($composerJsonPath = $sourcePath.'/composer.json')) {
  18764. $jsonFile = new JsonFile($composerJsonPath);
  18765. $jsonData = $jsonFile->read();
  18766. if (!empty($jsonData['archive']['name'])) {
  18767. $package->setArchiveName($jsonData['archive']['name']);
  18768. }
  18769. if (!empty($jsonData['archive']['exclude'])) {
  18770. $package->setArchiveExcludes($jsonData['archive']['exclude']);
  18771. }
  18772. }
  18773. }
  18774. if (null === $fileName) {
  18775. $packageName = $this->getPackageFilename($package);
  18776. } else {
  18777. $packageName = $fileName;
  18778. }
  18779. $filesystem->ensureDirectoryExists($targetDir);
  18780. $target = realpath($targetDir).'/'.$packageName.'.'.$format;
  18781. $filesystem->ensureDirectoryExists(dirname($target));
  18782. if (!$this->overwriteFiles && file_exists($target)) {
  18783. return $target;
  18784. }
  18785. $tempTarget = sys_get_temp_dir().'/composer_archive'.uniqid().'.'.$format;
  18786. $filesystem->ensureDirectoryExists(dirname($tempTarget));
  18787. $archivePath = $usableArchiver->archive($sourcePath, $tempTarget, $format, $package->getArchiveExcludes(), $ignoreFilters);
  18788. $filesystem->rename($archivePath, $target);
  18789. if (!$package instanceof RootPackageInterface) {
  18790. $filesystem->removeDirectory($sourcePath);
  18791. }
  18792. $filesystem->remove($tempTarget);
  18793. return $target;
  18794. }
  18795. }
  18796. <?php
  18797. namespace Composer\Package\Archiver;
  18798. interface ArchiverInterface
  18799. {
  18800. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false);
  18801. public function supports($format, $sourceType);
  18802. }
  18803. <?php
  18804. namespace Composer\Package\Archiver;
  18805. use Symfony\Component\Finder;
  18806. abstract class BaseExcludeFilter
  18807. {
  18808. protected $sourcePath;
  18809. protected $excludePatterns;
  18810. public function __construct($sourcePath)
  18811. {
  18812. $this->sourcePath = $sourcePath;
  18813. $this->excludePatterns = array();
  18814. }
  18815. public function filter($relativePath, $exclude)
  18816. {
  18817. foreach ($this->excludePatterns as $patternData) {
  18818. list($pattern, $negate, $stripLeadingSlash) = $patternData;
  18819. if ($stripLeadingSlash) {
  18820. $path = substr($relativePath, 1);
  18821. } else {
  18822. $path = $relativePath;
  18823. }
  18824. if (@preg_match($pattern, $path)) {
  18825. $exclude = !$negate;
  18826. }
  18827. }
  18828. return $exclude;
  18829. }
  18830. protected function parseLines(array $lines, $lineParser)
  18831. {
  18832. return array_filter(
  18833. array_map(
  18834. function ($line) use ($lineParser) {
  18835. $line = trim($line);
  18836. if (!$line || 0 === strpos($line, '#')) {
  18837. return null;
  18838. }
  18839. return call_user_func($lineParser, $line);
  18840. },
  18841. $lines
  18842. ),
  18843. function ($pattern) {
  18844. return $pattern !== null;
  18845. }
  18846. );
  18847. }
  18848. protected function generatePatterns($rules)
  18849. {
  18850. $patterns = array();
  18851. foreach ($rules as $rule) {
  18852. $patterns[] = $this->generatePattern($rule);
  18853. }
  18854. return $patterns;
  18855. }
  18856. protected function generatePattern($rule)
  18857. {
  18858. $negate = false;
  18859. $pattern = '';
  18860. if ($rule !== '' && $rule[0] === '!') {
  18861. $negate = true;
  18862. $rule = ltrim($rule, '!');
  18863. }
  18864. $firstSlashPosition = strpos($rule, '/');
  18865. if (0 === $firstSlashPosition) {
  18866. $pattern = '^/';
  18867. } elseif (false === $firstSlashPosition || strlen($rule) - 1 === $firstSlashPosition) {
  18868. $pattern = '/';
  18869. }
  18870. $rule = trim($rule, '/');
  18871. $rule = substr(Finder\Glob::toRegex($rule), 2, -2);
  18872. return array('{'.$pattern.$rule.'(?=$|/)}', $negate, false);
  18873. }
  18874. }
  18875. <?php
  18876. namespace Composer\Package\Archiver;
  18877. class ComposerExcludeFilter extends BaseExcludeFilter
  18878. {
  18879. public function __construct($sourcePath, array $excludeRules)
  18880. {
  18881. parent::__construct($sourcePath);
  18882. $this->excludePatterns = $this->generatePatterns($excludeRules);
  18883. }
  18884. }
  18885. <?php
  18886. namespace Composer\Package\Archiver;
  18887. class GitExcludeFilter extends BaseExcludeFilter
  18888. {
  18889. public function __construct($sourcePath)
  18890. {
  18891. parent::__construct($sourcePath);
  18892. if (file_exists($sourcePath.'/.gitignore')) {
  18893. $this->excludePatterns = $this->parseLines(
  18894. file($sourcePath.'/.gitignore'),
  18895. array($this, 'parseGitIgnoreLine')
  18896. );
  18897. }
  18898. if (file_exists($sourcePath.'/.gitattributes')) {
  18899. $this->excludePatterns = array_merge(
  18900. $this->excludePatterns,
  18901. $this->parseLines(
  18902. file($sourcePath.'/.gitattributes'),
  18903. array($this, 'parseGitAttributesLine')
  18904. )
  18905. );
  18906. }
  18907. }
  18908. public function parseGitIgnoreLine($line)
  18909. {
  18910. return $this->generatePattern($line);
  18911. }
  18912. public function parseGitAttributesLine($line)
  18913. {
  18914. $parts = preg_split('#\s+#', $line);
  18915. if (count($parts) == 2 && $parts[1] === 'export-ignore') {
  18916. return $this->generatePattern($parts[0]);
  18917. }
  18918. return null;
  18919. }
  18920. }
  18921. <?php
  18922. namespace Composer\Package\Archiver;
  18923. use Symfony\Component\Finder;
  18924. class HgExcludeFilter extends BaseExcludeFilter
  18925. {
  18926. const HG_IGNORE_REGEX = 1;
  18927. const HG_IGNORE_GLOB = 2;
  18928. protected $patternMode;
  18929. public function __construct($sourcePath)
  18930. {
  18931. parent::__construct($sourcePath);
  18932. $this->patternMode = self::HG_IGNORE_REGEX;
  18933. if (file_exists($sourcePath.'/.hgignore')) {
  18934. $this->excludePatterns = $this->parseLines(
  18935. file($sourcePath.'/.hgignore'),
  18936. array($this, 'parseHgIgnoreLine')
  18937. );
  18938. }
  18939. }
  18940. public function parseHgIgnoreLine($line)
  18941. {
  18942. if (preg_match('#^syntax\s*:\s*(glob|regexp)$#', $line, $matches)) {
  18943. if ($matches[1] === 'glob') {
  18944. $this->patternMode = self::HG_IGNORE_GLOB;
  18945. } else {
  18946. $this->patternMode = self::HG_IGNORE_REGEX;
  18947. }
  18948. return null;
  18949. }
  18950. if ($this->patternMode == self::HG_IGNORE_GLOB) {
  18951. return $this->patternFromGlob($line);
  18952. }
  18953. return $this->patternFromRegex($line);
  18954. }
  18955. protected function patternFromGlob($line)
  18956. {
  18957. $pattern = '#'.substr(Finder\Glob::toRegex($line), 2, -1).'#';
  18958. $pattern = str_replace('[^/]*', '.*', $pattern);
  18959. return array($pattern, false, true);
  18960. }
  18961. public function patternFromRegex($line)
  18962. {
  18963. $pattern = '#'.preg_replace('/((?:\\\\\\\\)*)(\\\\?)#/', '\1\2\2\\#', $line).'#';
  18964. return array($pattern, false, true);
  18965. }
  18966. }
  18967. <?php
  18968. namespace Composer\Package\Archiver;
  18969. class PharArchiver implements ArchiverInterface
  18970. {
  18971. protected static $formats = array(
  18972. 'zip' => \Phar::ZIP,
  18973. 'tar' => \Phar::TAR,
  18974. 'tar.gz' => \Phar::TAR,
  18975. 'tar.bz2' => \Phar::TAR,
  18976. );
  18977. protected static $compressFormats = array(
  18978. 'tar.gz' => \Phar::GZ,
  18979. 'tar.bz2' => \Phar::BZ2,
  18980. );
  18981. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  18982. {
  18983. $sources = realpath($sources);
  18984. if (file_exists($target)) {
  18985. unlink($target);
  18986. }
  18987. try {
  18988. $filename = substr($target, 0, strrpos($target, $format) - 1);
  18989. if (isset(static::$compressFormats[$format])) {
  18990. $target = $filename . '.tar';
  18991. }
  18992. $phar = new \PharData($target, null, null, static::$formats[$format]);
  18993. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  18994. $filesOnly = new ArchivableFilesFilter($files);
  18995. $phar->buildFromIterator($filesOnly, $sources);
  18996. $filesOnly->addEmptyDir($phar, $sources);
  18997. if (isset(static::$compressFormats[$format])) {
  18998. if (!$phar->canCompress(static::$compressFormats[$format])) {
  18999. throw new \RuntimeException(sprintf('Can not compress to %s format', $format));
  19000. }
  19001. unlink($target);
  19002. $phar->compress(static::$compressFormats[$format]);
  19003. $target = $filename . '.' . $format;
  19004. }
  19005. return $target;
  19006. } catch (\UnexpectedValueException $e) {
  19007. $message = sprintf(
  19008. "Could not create archive '%s' from '%s': %s",
  19009. $target,
  19010. $sources,
  19011. $e->getMessage()
  19012. );
  19013. throw new \RuntimeException($message, $e->getCode(), $e);
  19014. }
  19015. }
  19016. public function supports($format, $sourceType)
  19017. {
  19018. return isset(static::$formats[$format]);
  19019. }
  19020. }
  19021. <?php
  19022. namespace Composer\Package\Archiver;
  19023. use ZipArchive;
  19024. use Composer\Util\Filesystem;
  19025. class ZipArchiver implements ArchiverInterface
  19026. {
  19027. protected static $formats = array(
  19028. 'zip' => 1,
  19029. );
  19030. public function archive($sources, $target, $format, array $excludes = array(), $ignoreFilters = false)
  19031. {
  19032. $fs = new Filesystem();
  19033. $sources = $fs->normalizePath($sources);
  19034. $zip = new ZipArchive();
  19035. $res = $zip->open($target, ZipArchive::CREATE);
  19036. if ($res === true) {
  19037. $files = new ArchivableFilesFinder($sources, $excludes, $ignoreFilters);
  19038. foreach ($files as $file) {
  19039. $filepath = strtr($file->getPath()."/".$file->getFilename(), '\\', '/');
  19040. $localname = $filepath;
  19041. if (strpos($localname, $sources . '/') === 0) {
  19042. $localname = substr($localname, strlen($sources . '/'));
  19043. }
  19044. if ($file->isDir()) {
  19045. $zip->addEmptyDir($localname);
  19046. } else {
  19047. $zip->addFile($filepath, $localname);
  19048. }
  19049. if (PHP_VERSION_ID >= 50600) {
  19050. $perms = fileperms($filepath);
  19051. $zip->setExternalAttributesName($localname, ZipArchive::OPSYS_UNIX, $perms << 16);
  19052. }
  19053. }
  19054. if ($zip->close()) {
  19055. return $target;
  19056. }
  19057. }
  19058. $message = sprintf(
  19059. "Could not create archive '%s' from '%s': %s",
  19060. $target,
  19061. $sources,
  19062. $zip->getStatusString()
  19063. );
  19064. throw new \RuntimeException($message);
  19065. }
  19066. public function supports($format, $sourceType)
  19067. {
  19068. return isset(static::$formats[$format]) && $this->compressionAvailable();
  19069. }
  19070. private function compressionAvailable()
  19071. {
  19072. return class_exists('ZipArchive');
  19073. }
  19074. }
  19075. <?php
  19076. namespace Composer\Package;
  19077. use Composer\Repository\RepositoryInterface;
  19078. use Composer\Repository\PlatformRepository;
  19079. abstract class BasePackage implements PackageInterface
  19080. {
  19081. public static $supportedLinkTypes = array(
  19082. 'require' => array('description' => 'requires', 'method' => Link::TYPE_REQUIRE),
  19083. 'conflict' => array('description' => 'conflicts', 'method' => Link::TYPE_CONFLICT),
  19084. 'provide' => array('description' => 'provides', 'method' => Link::TYPE_PROVIDE),
  19085. 'replace' => array('description' => 'replaces', 'method' => Link::TYPE_REPLACE),
  19086. 'require-dev' => array('description' => 'requires (for development)', 'method' => Link::TYPE_DEV_REQUIRE),
  19087. );
  19088. const STABILITY_STABLE = 0;
  19089. const STABILITY_RC = 5;
  19090. const STABILITY_BETA = 10;
  19091. const STABILITY_ALPHA = 15;
  19092. const STABILITY_DEV = 20;
  19093. public static $stabilities = array(
  19094. 'stable' => self::STABILITY_STABLE,
  19095. 'RC' => self::STABILITY_RC,
  19096. 'beta' => self::STABILITY_BETA,
  19097. 'alpha' => self::STABILITY_ALPHA,
  19098. 'dev' => self::STABILITY_DEV,
  19099. );
  19100. public $id;
  19101. protected $name;
  19102. protected $prettyName;
  19103. protected $repository;
  19104. protected $transportOptions = array();
  19105. public function __construct($name)
  19106. {
  19107. $this->prettyName = $name;
  19108. $this->name = strtolower($name);
  19109. $this->id = -1;
  19110. }
  19111. public function getName()
  19112. {
  19113. return $this->name;
  19114. }
  19115. public function getPrettyName()
  19116. {
  19117. return $this->prettyName;
  19118. }
  19119. public function getNames($provides = true)
  19120. {
  19121. $names = array(
  19122. $this->getName() => true,
  19123. );
  19124. if ($provides) {
  19125. foreach ($this->getProvides() as $link) {
  19126. $names[$link->getTarget()] = true;
  19127. }
  19128. }
  19129. foreach ($this->getReplaces() as $link) {
  19130. $names[$link->getTarget()] = true;
  19131. }
  19132. return array_keys($names);
  19133. }
  19134. public function setId($id)
  19135. {
  19136. $this->id = $id;
  19137. }
  19138. public function getId()
  19139. {
  19140. return $this->id;
  19141. }
  19142. public function setRepository(RepositoryInterface $repository)
  19143. {
  19144. if ($this->repository && $repository !== $this->repository) {
  19145. throw new \LogicException('A package can only be added to one repository');
  19146. }
  19147. $this->repository = $repository;
  19148. }
  19149. public function getRepository()
  19150. {
  19151. return $this->repository;
  19152. }
  19153. public function getTransportOptions()
  19154. {
  19155. return $this->transportOptions;
  19156. }
  19157. public function setTransportOptions(array $options)
  19158. {
  19159. $this->transportOptions = $options;
  19160. }
  19161. public function isPlatform()
  19162. {
  19163. return $this->getRepository() instanceof PlatformRepository;
  19164. }
  19165. public function getUniqueName()
  19166. {
  19167. return $this->getName().'-'.$this->getVersion();
  19168. }
  19169. public function equals(PackageInterface $package)
  19170. {
  19171. $self = $this;
  19172. if ($this instanceof AliasPackage) {
  19173. $self = $this->getAliasOf();
  19174. }
  19175. if ($package instanceof AliasPackage) {
  19176. $package = $package->getAliasOf();
  19177. }
  19178. return $package === $self;
  19179. }
  19180. public function __toString()
  19181. {
  19182. return $this->getUniqueName();
  19183. }
  19184. public function getPrettyString()
  19185. {
  19186. return $this->getPrettyName().' '.$this->getPrettyVersion();
  19187. }
  19188. public function getFullPrettyVersion($truncate = true, $displayMode = PackageInterface::DISPLAY_SOURCE_REF_IF_DEV)
  19189. {
  19190. if ($displayMode === PackageInterface::DISPLAY_SOURCE_REF_IF_DEV &&
  19191. (!$this->isDev() || !\in_array($this->getSourceType(), array('hg', 'git')))
  19192. ) {
  19193. return $this->getPrettyVersion();
  19194. }
  19195. switch ($displayMode) {
  19196. case PackageInterface::DISPLAY_SOURCE_REF_IF_DEV:
  19197. case PackageInterface::DISPLAY_SOURCE_REF:
  19198. $reference = $this->getSourceReference();
  19199. break;
  19200. case PackageInterface::DISPLAY_DIST_REF:
  19201. $reference = $this->getDistReference();
  19202. break;
  19203. default:
  19204. throw new \UnexpectedValueException('Display mode '.$displayMode.' is not supported');
  19205. }
  19206. if ($truncate && \strlen($reference) === 40 && $this->getSourceType() !== 'svn') {
  19207. return $this->getPrettyVersion() . ' ' . substr($reference, 0, 7);
  19208. }
  19209. return $this->getPrettyVersion() . ' ' . $reference;
  19210. }
  19211. public function getStabilityPriority()
  19212. {
  19213. return self::$stabilities[$this->getStability()];
  19214. }
  19215. public function __clone()
  19216. {
  19217. $this->repository = null;
  19218. $this->id = -1;
  19219. }
  19220. public static function packageNameToRegexp($allowPattern, $wrap = '{^%s$}i')
  19221. {
  19222. $cleanedAllowPattern = str_replace('\\*', '.*', preg_quote($allowPattern));
  19223. return sprintf($wrap, $cleanedAllowPattern);
  19224. }
  19225. }
  19226. <?php
  19227. namespace Composer\Package\Comparer;
  19228. class Comparer
  19229. {
  19230. private $source;
  19231. private $update;
  19232. private $changed;
  19233. public function setSource($source)
  19234. {
  19235. $this->source = $source;
  19236. }
  19237. public function setUpdate($update)
  19238. {
  19239. $this->update = $update;
  19240. }
  19241. public function getChanged($toString = false, $explicated = false)
  19242. {
  19243. $changed = $this->changed;
  19244. if (!count($changed)) {
  19245. return false;
  19246. }
  19247. if ($explicated) {
  19248. foreach ($changed as $sectionKey => $itemSection) {
  19249. foreach ($itemSection as $itemKey => $item) {
  19250. $changed[$sectionKey][$itemKey] = $item.' ('.$sectionKey.')';
  19251. }
  19252. }
  19253. }
  19254. if ($toString) {
  19255. foreach ($changed as $sectionKey => $itemSection) {
  19256. foreach ($itemSection as $itemKey => $item) {
  19257. $changed['string'][] = $item."\r\n";
  19258. }
  19259. }
  19260. $changed = implode("\r\n", $changed['string']);
  19261. }
  19262. return $changed;
  19263. }
  19264. public function doCompare()
  19265. {
  19266. $source = array();
  19267. $destination = array();
  19268. $this->changed = array();
  19269. $currentDirectory = getcwd();
  19270. chdir($this->source);
  19271. $source = $this->doTree('.', $source);
  19272. if (!is_array($source)) {
  19273. return;
  19274. }
  19275. chdir($currentDirectory);
  19276. chdir($this->update);
  19277. $destination = $this->doTree('.', $destination);
  19278. if (!is_array($destination)) {
  19279. exit;
  19280. }
  19281. chdir($currentDirectory);
  19282. foreach ($source as $dir => $value) {
  19283. foreach ($value as $file => $hash) {
  19284. if (isset($destination[$dir][$file])) {
  19285. if ($hash !== $destination[$dir][$file]) {
  19286. $this->changed['changed'][] = $dir.'/'.$file;
  19287. }
  19288. } else {
  19289. $this->changed['removed'][] = $dir.'/'.$file;
  19290. }
  19291. }
  19292. }
  19293. foreach ($destination as $dir => $value) {
  19294. foreach ($value as $file => $hash) {
  19295. if (!isset($source[$dir][$file])) {
  19296. $this->changed['added'][] = $dir.'/'.$file;
  19297. }
  19298. }
  19299. }
  19300. }
  19301. private function doTree($dir, &$array)
  19302. {
  19303. if ($dh = opendir($dir)) {
  19304. while ($file = readdir($dh)) {
  19305. if ($file !== '.' && $file !== '..') {
  19306. if (is_link($dir.'/'.$file)) {
  19307. $array[$dir][$file] = readlink($dir.'/'.$file);
  19308. } elseif (is_dir($dir.'/'.$file)) {
  19309. if (!count($array)) {
  19310. $array[0] = 'Temp';
  19311. }
  19312. if (!$this->doTree($dir.'/'.$file, $array)) {
  19313. return false;
  19314. }
  19315. } elseif (is_file($dir.'/'.$file) && filesize($dir.'/'.$file)) {
  19316. $array[$dir][$file] = md5_file($dir.'/'.$file);
  19317. }
  19318. }
  19319. }
  19320. if (count($array) > 1 && isset($array['0'])) {
  19321. unset($array['0']);
  19322. }
  19323. return $array;
  19324. }
  19325. return false;
  19326. }
  19327. }
  19328. <?php
  19329. namespace Composer\Package;
  19330. class CompletePackage extends Package implements CompletePackageInterface
  19331. {
  19332. protected $repositories;
  19333. protected $license = array();
  19334. protected $keywords;
  19335. protected $authors;
  19336. protected $description;
  19337. protected $homepage;
  19338. protected $scripts = array();
  19339. protected $support = array();
  19340. protected $funding = array();
  19341. protected $abandoned = false;
  19342. public function setScripts(array $scripts)
  19343. {
  19344. $this->scripts = $scripts;
  19345. }
  19346. public function getScripts()
  19347. {
  19348. return $this->scripts;
  19349. }
  19350. public function setRepositories($repositories)
  19351. {
  19352. $this->repositories = $repositories;
  19353. }
  19354. public function getRepositories()
  19355. {
  19356. return $this->repositories;
  19357. }
  19358. public function setLicense(array $license)
  19359. {
  19360. $this->license = $license;
  19361. }
  19362. public function getLicense()
  19363. {
  19364. return $this->license;
  19365. }
  19366. public function setKeywords(array $keywords)
  19367. {
  19368. $this->keywords = $keywords;
  19369. }
  19370. public function getKeywords()
  19371. {
  19372. return $this->keywords;
  19373. }
  19374. public function setAuthors(array $authors)
  19375. {
  19376. $this->authors = $authors;
  19377. }
  19378. public function getAuthors()
  19379. {
  19380. return $this->authors;
  19381. }
  19382. public function setDescription($description)
  19383. {
  19384. $this->description = $description;
  19385. }
  19386. public function getDescription()
  19387. {
  19388. return $this->description;
  19389. }
  19390. public function setHomepage($homepage)
  19391. {
  19392. $this->homepage = $homepage;
  19393. }
  19394. public function getHomepage()
  19395. {
  19396. return $this->homepage;
  19397. }
  19398. public function setSupport(array $support)
  19399. {
  19400. $this->support = $support;
  19401. }
  19402. public function getSupport()
  19403. {
  19404. return $this->support;
  19405. }
  19406. public function setFunding(array $funding)
  19407. {
  19408. $this->funding = $funding;
  19409. }
  19410. public function getFunding()
  19411. {
  19412. return $this->funding;
  19413. }
  19414. public function isAbandoned()
  19415. {
  19416. return (bool) $this->abandoned;
  19417. }
  19418. public function setAbandoned($abandoned)
  19419. {
  19420. $this->abandoned = $abandoned;
  19421. }
  19422. public function getReplacementPackage()
  19423. {
  19424. return \is_string($this->abandoned) ? $this->abandoned : null;
  19425. }
  19426. }
  19427. <?php
  19428. namespace Composer\Package;
  19429. interface CompletePackageInterface extends PackageInterface
  19430. {
  19431. public function getScripts();
  19432. public function getRepositories();
  19433. public function getLicense();
  19434. public function getKeywords();
  19435. public function getDescription();
  19436. public function getHomepage();
  19437. public function getAuthors();
  19438. public function getSupport();
  19439. public function getFunding();
  19440. public function isAbandoned();
  19441. public function getReplacementPackage();
  19442. }
  19443. <?php
  19444. namespace Composer\Package\Dumper;
  19445. use Composer\Package\BasePackage;
  19446. use Composer\Package\PackageInterface;
  19447. use Composer\Package\CompletePackageInterface;
  19448. use Composer\Package\RootPackageInterface;
  19449. class ArrayDumper
  19450. {
  19451. public function dump(PackageInterface $package)
  19452. {
  19453. $keys = array(
  19454. 'binaries' => 'bin',
  19455. 'type',
  19456. 'extra',
  19457. 'installationSource' => 'installation-source',
  19458. 'autoload',
  19459. 'devAutoload' => 'autoload-dev',
  19460. 'notificationUrl' => 'notification-url',
  19461. 'includePaths' => 'include-path',
  19462. );
  19463. $data = array();
  19464. $data['name'] = $package->getPrettyName();
  19465. $data['version'] = $package->getPrettyVersion();
  19466. $data['version_normalized'] = $package->getVersion();
  19467. if ($package->getTargetDir()) {
  19468. $data['target-dir'] = $package->getTargetDir();
  19469. }
  19470. if ($package->getSourceType()) {
  19471. $data['source']['type'] = $package->getSourceType();
  19472. $data['source']['url'] = $package->getSourceUrl();
  19473. if (null !== ($value = $package->getSourceReference())) {
  19474. $data['source']['reference'] = $value;
  19475. }
  19476. if ($mirrors = $package->getSourceMirrors()) {
  19477. $data['source']['mirrors'] = $mirrors;
  19478. }
  19479. }
  19480. if ($package->getDistType()) {
  19481. $data['dist']['type'] = $package->getDistType();
  19482. $data['dist']['url'] = $package->getDistUrl();
  19483. if (null !== ($value = $package->getDistReference())) {
  19484. $data['dist']['reference'] = $value;
  19485. }
  19486. if (null !== ($value = $package->getDistSha1Checksum())) {
  19487. $data['dist']['shasum'] = $value;
  19488. }
  19489. if ($mirrors = $package->getDistMirrors()) {
  19490. $data['dist']['mirrors'] = $mirrors;
  19491. }
  19492. }
  19493. if ($package->getArchiveName()) {
  19494. $data['archive']['name'] = $package->getArchiveName();
  19495. }
  19496. if ($package->getArchiveExcludes()) {
  19497. $data['archive']['exclude'] = $package->getArchiveExcludes();
  19498. }
  19499. foreach (BasePackage::$supportedLinkTypes as $type => $opts) {
  19500. if ($links = $package->{'get'.ucfirst($opts['method'])}()) {
  19501. foreach ($links as $link) {
  19502. $data[$type][$link->getTarget()] = $link->getPrettyConstraint();
  19503. }
  19504. ksort($data[$type]);
  19505. }
  19506. }
  19507. if ($packages = $package->getSuggests()) {
  19508. ksort($packages);
  19509. $data['suggest'] = $packages;
  19510. }
  19511. if ($package->getReleaseDate()) {
  19512. $data['time'] = $package->getReleaseDate()->format(DATE_RFC3339);
  19513. }
  19514. if ($package->isDefaultBranch()) {
  19515. $data['default-branch'] = true;
  19516. }
  19517. $data = $this->dumpValues($package, $keys, $data);
  19518. if ($package instanceof CompletePackageInterface) {
  19519. $keys = array(
  19520. 'scripts',
  19521. 'license',
  19522. 'authors',
  19523. 'description',
  19524. 'homepage',
  19525. 'keywords',
  19526. 'repositories',
  19527. 'support',
  19528. 'funding',
  19529. );
  19530. $data = $this->dumpValues($package, $keys, $data);
  19531. if (isset($data['keywords']) && \is_array($data['keywords'])) {
  19532. sort($data['keywords']);
  19533. }
  19534. if ($package->isAbandoned()) {
  19535. $data['abandoned'] = $package->getReplacementPackage() ?: true;
  19536. }
  19537. }
  19538. if ($package instanceof RootPackageInterface) {
  19539. $minimumStability = $package->getMinimumStability();
  19540. if ($minimumStability) {
  19541. $data['minimum-stability'] = $minimumStability;
  19542. }
  19543. }
  19544. if (\count($package->getTransportOptions()) > 0) {
  19545. $data['transport-options'] = $package->getTransportOptions();
  19546. }
  19547. return $data;
  19548. }
  19549. private function dumpValues(PackageInterface $package, array $keys, array $data)
  19550. {
  19551. foreach ($keys as $method => $key) {
  19552. if (is_numeric($method)) {
  19553. $method = $key;
  19554. }
  19555. $getter = 'get'.ucfirst($method);
  19556. $value = $package->$getter();
  19557. if (null !== $value && !(\is_array($value) && 0 === \count($value))) {
  19558. $data[$key] = $value;
  19559. }
  19560. }
  19561. return $data;
  19562. }
  19563. }
  19564. <?php
  19565. namespace Composer\Package;
  19566. use Composer\Semver\Constraint\ConstraintInterface;
  19567. class Link
  19568. {
  19569. const TYPE_REQUIRE = 'requires';
  19570. const TYPE_DEV_REQUIRE = 'devRequires';
  19571. const TYPE_PROVIDE = 'provides';
  19572. const TYPE_CONFLICT = 'conflicts';
  19573. const TYPE_REPLACE = 'replaces';
  19574. public static $TYPES = array(
  19575. self::TYPE_REQUIRE,
  19576. self::TYPE_DEV_REQUIRE,
  19577. self::TYPE_PROVIDE,
  19578. self::TYPE_CONFLICT,
  19579. self::TYPE_REPLACE,
  19580. );
  19581. protected $source;
  19582. protected $target;
  19583. protected $constraint;
  19584. protected $description;
  19585. protected $prettyConstraint;
  19586. public function __construct(
  19587. $source,
  19588. $target,
  19589. ConstraintInterface $constraint,
  19590. $description = 'relates to',
  19591. $prettyConstraint = null
  19592. ) {
  19593. $this->source = strtolower($source);
  19594. $this->target = strtolower($target);
  19595. $this->constraint = $constraint;
  19596. $this->description = $description;
  19597. $this->prettyConstraint = $prettyConstraint;
  19598. }
  19599. public function getDescription()
  19600. {
  19601. return $this->description;
  19602. }
  19603. public function getSource()
  19604. {
  19605. return $this->source;
  19606. }
  19607. public function getTarget()
  19608. {
  19609. return $this->target;
  19610. }
  19611. public function getConstraint()
  19612. {
  19613. return $this->constraint;
  19614. }
  19615. public function getPrettyConstraint()
  19616. {
  19617. if (null === $this->prettyConstraint) {
  19618. throw new \UnexpectedValueException(sprintf('Link %s has been misconfigured and had no prettyConstraint given.', $this));
  19619. }
  19620. return $this->prettyConstraint;
  19621. }
  19622. public function __toString()
  19623. {
  19624. return $this->source.' '.$this->description.' '.$this->target.' ('.$this->constraint.')';
  19625. }
  19626. public function getPrettyString(PackageInterface $sourcePackage)
  19627. {
  19628. return $sourcePackage->getPrettyString().' '.$this->description.' '.$this->target.($this->constraint ? ' '.$this->constraint->getPrettyString() : '');
  19629. }
  19630. }
  19631. <?php
  19632. namespace Composer\Package\Loader;
  19633. use Composer\Package;
  19634. use Composer\Package\AliasPackage;
  19635. use Composer\Package\Link;
  19636. use Composer\Package\RootAliasPackage;
  19637. use Composer\Package\RootPackageInterface;
  19638. use Composer\Package\Version\VersionParser;
  19639. class ArrayLoader implements LoaderInterface
  19640. {
  19641. protected $versionParser;
  19642. protected $loadOptions;
  19643. public function __construct(VersionParser $parser = null, $loadOptions = false)
  19644. {
  19645. if (!$parser) {
  19646. $parser = new VersionParser;
  19647. }
  19648. $this->versionParser = $parser;
  19649. $this->loadOptions = $loadOptions;
  19650. }
  19651. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  19652. {
  19653. $package = $this->createObject($config, $class);
  19654. foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
  19655. if (isset($config[$type])) {
  19656. $method = 'set'.ucfirst($opts['method']);
  19657. $package->{$method}(
  19658. $this->parseLinks(
  19659. $package->getName(),
  19660. $package->getPrettyVersion(),
  19661. $opts['description'],
  19662. $config[$type]
  19663. )
  19664. );
  19665. }
  19666. }
  19667. $package = $this->configureObject($package, $config);
  19668. return $package;
  19669. }
  19670. public function loadPackages(array $versions, $class)
  19671. {
  19672. $packages = array();
  19673. $linkCache = array();
  19674. foreach ($versions as $version) {
  19675. $package = $this->createObject($version, $class);
  19676. $this->configureCachedLinks($linkCache, $package, $version);
  19677. $package = $this->configureObject($package, $version);
  19678. $packages[] = $package;
  19679. }
  19680. return $packages;
  19681. }
  19682. private function createObject(array $config, $class)
  19683. {
  19684. if (!isset($config['name'])) {
  19685. throw new \UnexpectedValueException('Unknown package has no name defined ('.json_encode($config).').');
  19686. }
  19687. if (!isset($config['version'])) {
  19688. throw new \UnexpectedValueException('Package '.$config['name'].' has no version defined.');
  19689. }
  19690. if (isset($config['version_normalized'])) {
  19691. $version = $config['version_normalized'];
  19692. if ($version === VersionParser::DEFAULT_BRANCH_ALIAS) {
  19693. $version = $this->versionParser->normalize($config['version']);
  19694. }
  19695. } else {
  19696. $version = $this->versionParser->normalize($config['version']);
  19697. }
  19698. return new $class($config['name'], $version, $config['version']);
  19699. }
  19700. private function configureObject($package, array $config)
  19701. {
  19702. $package->setType(isset($config['type']) ? strtolower($config['type']) : 'library');
  19703. if (isset($config['target-dir'])) {
  19704. $package->setTargetDir($config['target-dir']);
  19705. }
  19706. if (isset($config['extra']) && \is_array($config['extra'])) {
  19707. $package->setExtra($config['extra']);
  19708. }
  19709. if (isset($config['bin'])) {
  19710. if (!\is_array($config['bin'])) {
  19711. $config['bin'] = array($config['bin']);
  19712. }
  19713. foreach ($config['bin'] as $key => $bin) {
  19714. $config['bin'][$key] = ltrim($bin, '/');
  19715. }
  19716. $package->setBinaries($config['bin']);
  19717. }
  19718. if (isset($config['installation-source'])) {
  19719. $package->setInstallationSource($config['installation-source']);
  19720. }
  19721. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  19722. $package->setIsDefaultBranch(true);
  19723. }
  19724. if (isset($config['source'])) {
  19725. if (!isset($config['source']['type'], $config['source']['url'], $config['source']['reference'])) {
  19726. throw new \UnexpectedValueException(sprintf(
  19727. "Package %s's source key should be specified as {\"type\": ..., \"url\": ..., \"reference\": ...},\n%s given.",
  19728. $config['name'],
  19729. json_encode($config['source'])
  19730. ));
  19731. }
  19732. $package->setSourceType($config['source']['type']);
  19733. $package->setSourceUrl($config['source']['url']);
  19734. $package->setSourceReference(isset($config['source']['reference']) ? $config['source']['reference'] : null);
  19735. if (isset($config['source']['mirrors'])) {
  19736. $package->setSourceMirrors($config['source']['mirrors']);
  19737. }
  19738. }
  19739. if (isset($config['dist'])) {
  19740. if (!isset($config['dist']['type'], $config['dist']['url'])) {
  19741. throw new \UnexpectedValueException(sprintf(
  19742. "Package %s's dist key should be specified as ".
  19743. "{\"type\": ..., \"url\": ..., \"reference\": ..., \"shasum\": ...},\n%s given.",
  19744. $config['name'],
  19745. json_encode($config['dist'])
  19746. ));
  19747. }
  19748. $package->setDistType($config['dist']['type']);
  19749. $package->setDistUrl($config['dist']['url']);
  19750. $package->setDistReference(isset($config['dist']['reference']) ? $config['dist']['reference'] : null);
  19751. $package->setDistSha1Checksum(isset($config['dist']['shasum']) ? $config['dist']['shasum'] : null);
  19752. if (isset($config['dist']['mirrors'])) {
  19753. $package->setDistMirrors($config['dist']['mirrors']);
  19754. }
  19755. }
  19756. if (isset($config['suggest']) && \is_array($config['suggest'])) {
  19757. foreach ($config['suggest'] as $target => $reason) {
  19758. if ('self.version' === trim($reason)) {
  19759. $config['suggest'][$target] = $package->getPrettyVersion();
  19760. }
  19761. }
  19762. $package->setSuggests($config['suggest']);
  19763. }
  19764. if (isset($config['autoload'])) {
  19765. $package->setAutoload($config['autoload']);
  19766. }
  19767. if (isset($config['autoload-dev'])) {
  19768. $package->setDevAutoload($config['autoload-dev']);
  19769. }
  19770. if (isset($config['include-path'])) {
  19771. $package->setIncludePaths($config['include-path']);
  19772. }
  19773. if (!empty($config['time'])) {
  19774. $time = preg_match('/^\d++$/D', $config['time']) ? '@'.$config['time'] : $config['time'];
  19775. try {
  19776. $date = new \DateTime($time, new \DateTimeZone('UTC'));
  19777. $package->setReleaseDate($date);
  19778. } catch (\Exception $e) {
  19779. }
  19780. }
  19781. if (!empty($config['notification-url'])) {
  19782. $package->setNotificationUrl($config['notification-url']);
  19783. }
  19784. if (!empty($config['archive']['name'])) {
  19785. $package->setArchiveName($config['archive']['name']);
  19786. }
  19787. if (!empty($config['archive']['exclude'])) {
  19788. $package->setArchiveExcludes($config['archive']['exclude']);
  19789. }
  19790. if ($package instanceof Package\CompletePackageInterface) {
  19791. if (isset($config['scripts']) && \is_array($config['scripts'])) {
  19792. foreach ($config['scripts'] as $event => $listeners) {
  19793. $config['scripts'][$event] = (array) $listeners;
  19794. }
  19795. if (isset($config['scripts']['composer'])) {
  19796. trigger_error('The `composer` script name is reserved for internal use, please avoid defining it', E_USER_DEPRECATED);
  19797. }
  19798. $package->setScripts($config['scripts']);
  19799. }
  19800. if (!empty($config['description']) && \is_string($config['description'])) {
  19801. $package->setDescription($config['description']);
  19802. }
  19803. if (!empty($config['homepage']) && \is_string($config['homepage'])) {
  19804. $package->setHomepage($config['homepage']);
  19805. }
  19806. if (!empty($config['keywords']) && \is_array($config['keywords'])) {
  19807. $package->setKeywords($config['keywords']);
  19808. }
  19809. if (!empty($config['license'])) {
  19810. $package->setLicense(\is_array($config['license']) ? $config['license'] : array($config['license']));
  19811. }
  19812. if (!empty($config['authors']) && \is_array($config['authors'])) {
  19813. $package->setAuthors($config['authors']);
  19814. }
  19815. if (isset($config['support'])) {
  19816. $package->setSupport($config['support']);
  19817. }
  19818. if (!empty($config['funding']) && \is_array($config['funding'])) {
  19819. $package->setFunding($config['funding']);
  19820. }
  19821. if (isset($config['abandoned'])) {
  19822. $package->setAbandoned($config['abandoned']);
  19823. }
  19824. }
  19825. if ($this->loadOptions && isset($config['transport-options'])) {
  19826. $package->setTransportOptions($config['transport-options']);
  19827. }
  19828. if ($aliasNormalized = $this->getBranchAlias($config)) {
  19829. $prettyAlias = preg_replace('{(\.9{7})+}', '.x', $aliasNormalized);
  19830. if ($package instanceof RootPackageInterface) {
  19831. return new RootAliasPackage($package, $aliasNormalized, $prettyAlias);
  19832. }
  19833. return new AliasPackage($package, $aliasNormalized, $prettyAlias);
  19834. }
  19835. return $package;
  19836. }
  19837. private function configureCachedLinks(&$linkCache, $package, array $config)
  19838. {
  19839. $name = $package->getName();
  19840. $prettyVersion = $package->getPrettyVersion();
  19841. foreach (Package\BasePackage::$supportedLinkTypes as $type => $opts) {
  19842. if (isset($config[$type])) {
  19843. $method = 'set'.ucfirst($opts['method']);
  19844. $links = array();
  19845. foreach ($config[$type] as $prettyTarget => $constraint) {
  19846. $target = strtolower($prettyTarget);
  19847. if ($constraint === 'self.version') {
  19848. $links[$target] = $this->createLink($name, $prettyVersion, $opts['description'], $target, $constraint);
  19849. } else {
  19850. if (!isset($linkCache[$name][$type][$target][$constraint])) {
  19851. $linkCache[$name][$type][$target][$constraint] = array($target, $this->createLink($name, $prettyVersion, $opts['description'], $target, $constraint));
  19852. }
  19853. list($target, $link) = $linkCache[$name][$type][$target][$constraint];
  19854. $links[$target] = $link;
  19855. }
  19856. }
  19857. $package->{$method}($links);
  19858. }
  19859. }
  19860. }
  19861. public function parseLinks($source, $sourceVersion, $description, $links)
  19862. {
  19863. $res = array();
  19864. foreach ($links as $target => $constraint) {
  19865. $res[strtolower($target)] = $this->createLink($source, $sourceVersion, $description, $target, $constraint);
  19866. }
  19867. return $res;
  19868. }
  19869. private function createLink($source, $sourceVersion, $description, $target, $prettyConstraint)
  19870. {
  19871. if (!\is_string($prettyConstraint)) {
  19872. throw new \UnexpectedValueException('Link constraint in '.$source.' '.$description.' > '.$target.' should be a string, got '.\gettype($prettyConstraint) . ' (' . var_export($prettyConstraint, true) . ')');
  19873. }
  19874. if ('self.version' === $prettyConstraint) {
  19875. $parsedConstraint = $this->versionParser->parseConstraints($sourceVersion);
  19876. } else {
  19877. $parsedConstraint = $this->versionParser->parseConstraints($prettyConstraint);
  19878. }
  19879. return new Link($source, $target, $parsedConstraint, $description, $prettyConstraint);
  19880. }
  19881. public function getBranchAlias(array $config)
  19882. {
  19883. if (strpos($config['version'], 'dev-') !== 0 && '-dev' !== substr($config['version'], -4)) {
  19884. return;
  19885. }
  19886. if (isset($config['extra']['branch-alias']) && \is_array($config['extra']['branch-alias'])) {
  19887. foreach ($config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  19888. if ('-dev' !== substr($targetBranch, -4)) {
  19889. continue;
  19890. }
  19891. if ($targetBranch === VersionParser::DEFAULT_BRANCH_ALIAS) {
  19892. $validatedTargetBranch = VersionParser::DEFAULT_BRANCH_ALIAS;
  19893. } else {
  19894. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  19895. }
  19896. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  19897. continue;
  19898. }
  19899. if (strtolower($config['version']) !== strtolower($sourceBranch)) {
  19900. continue;
  19901. }
  19902. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  19903. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  19904. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  19905. ) {
  19906. continue;
  19907. }
  19908. return $validatedTargetBranch;
  19909. }
  19910. }
  19911. if (isset($config['default-branch']) && $config['default-branch'] === true) {
  19912. return VersionParser::DEFAULT_BRANCH_ALIAS;
  19913. }
  19914. }
  19915. }
  19916. <?php
  19917. namespace Composer\Package\Loader;
  19918. class InvalidPackageException extends \Exception
  19919. {
  19920. private $errors;
  19921. private $warnings;
  19922. private $data;
  19923. public function __construct(array $errors, array $warnings, array $data)
  19924. {
  19925. $this->errors = $errors;
  19926. $this->warnings = $warnings;
  19927. $this->data = $data;
  19928. parent::__construct("Invalid package information: \n".implode("\n", array_merge($errors, $warnings)));
  19929. }
  19930. public function getData()
  19931. {
  19932. return $this->data;
  19933. }
  19934. public function getErrors()
  19935. {
  19936. return $this->errors;
  19937. }
  19938. public function getWarnings()
  19939. {
  19940. return $this->warnings;
  19941. }
  19942. }
  19943. <?php
  19944. namespace Composer\Package\Loader;
  19945. use Composer\Json\JsonFile;
  19946. class JsonLoader
  19947. {
  19948. private $loader;
  19949. public function __construct(LoaderInterface $loader)
  19950. {
  19951. $this->loader = $loader;
  19952. }
  19953. public function load($json)
  19954. {
  19955. if ($json instanceof JsonFile) {
  19956. $config = $json->read();
  19957. } elseif (file_exists($json)) {
  19958. $config = JsonFile::parseJson(file_get_contents($json), $json);
  19959. } elseif (is_string($json)) {
  19960. $config = JsonFile::parseJson($json);
  19961. } else {
  19962. throw new \InvalidArgumentException(sprintf(
  19963. "JsonLoader: Unknown \$json parameter %s. Please report at https://github.com/composer/composer/issues/new.",
  19964. gettype($json)
  19965. ));
  19966. }
  19967. return $this->loader->load($config);
  19968. }
  19969. }
  19970. <?php
  19971. namespace Composer\Package\Loader;
  19972. interface LoaderInterface
  19973. {
  19974. public function load(array $package, $class = 'Composer\Package\CompletePackage');
  19975. }
  19976. <?php
  19977. namespace Composer\Package\Loader;
  19978. use Composer\Package\BasePackage;
  19979. use Composer\Package\AliasPackage;
  19980. use Composer\Config;
  19981. use Composer\IO\IOInterface;
  19982. use Composer\Package\RootPackageInterface;
  19983. use Composer\Repository\RepositoryFactory;
  19984. use Composer\Package\Version\VersionGuesser;
  19985. use Composer\Package\Version\VersionParser;
  19986. use Composer\Package\RootPackage;
  19987. use Composer\Repository\RepositoryManager;
  19988. use Composer\Util\ProcessExecutor;
  19989. class RootPackageLoader extends ArrayLoader
  19990. {
  19991. private $manager;
  19992. private $config;
  19993. private $versionGuesser;
  19994. public function __construct(RepositoryManager $manager, Config $config, VersionParser $parser = null, VersionGuesser $versionGuesser = null, IOInterface $io = null)
  19995. {
  19996. parent::__construct($parser);
  19997. $this->manager = $manager;
  19998. $this->config = $config;
  19999. $this->versionGuesser = $versionGuesser ?: new VersionGuesser($config, new ProcessExecutor($io), $this->versionParser);
  20000. }
  20001. public function load(array $config, $class = 'Composer\Package\RootPackage', $cwd = null)
  20002. {
  20003. if (!isset($config['name'])) {
  20004. $config['name'] = '__root__';
  20005. } elseif ($err = ValidatingArrayLoader::hasPackageNamingError($config['name'])) {
  20006. throw new \RuntimeException('Your package name '.$err);
  20007. }
  20008. $autoVersioned = false;
  20009. if (!isset($config['version'])) {
  20010. $commit = null;
  20011. if (getenv('COMPOSER_ROOT_VERSION')) {
  20012. $config['version'] = getenv('COMPOSER_ROOT_VERSION');
  20013. } else {
  20014. $versionData = $this->versionGuesser->guessVersion($config, $cwd ?: getcwd());
  20015. if ($versionData) {
  20016. $config['version'] = $versionData['pretty_version'];
  20017. $config['version_normalized'] = $versionData['version'];
  20018. $commit = $versionData['commit'];
  20019. }
  20020. }
  20021. if (!isset($config['version'])) {
  20022. $config['version'] = '1.0.0';
  20023. $autoVersioned = true;
  20024. }
  20025. if ($commit) {
  20026. $config['source'] = array(
  20027. 'type' => '',
  20028. 'url' => '',
  20029. 'reference' => $commit,
  20030. );
  20031. $config['dist'] = array(
  20032. 'type' => '',
  20033. 'url' => '',
  20034. 'reference' => $commit,
  20035. );
  20036. }
  20037. }
  20038. $realPackage = $package = parent::load($config, $class);
  20039. if ($realPackage instanceof AliasPackage) {
  20040. $realPackage = $package->getAliasOf();
  20041. }
  20042. if ($autoVersioned) {
  20043. $realPackage->replaceVersion($realPackage->getVersion(), RootPackage::DEFAULT_PRETTY_VERSION);
  20044. }
  20045. if (isset($config['minimum-stability'])) {
  20046. $realPackage->setMinimumStability(VersionParser::normalizeStability($config['minimum-stability']));
  20047. }
  20048. $aliases = array();
  20049. $stabilityFlags = array();
  20050. $references = array();
  20051. foreach (array('require', 'require-dev') as $linkType) {
  20052. if (isset($config[$linkType])) {
  20053. $linkInfo = BasePackage::$supportedLinkTypes[$linkType];
  20054. $method = 'get'.ucfirst($linkInfo['method']);
  20055. $links = array();
  20056. foreach ($realPackage->$method() as $link) {
  20057. $links[$link->getTarget()] = $link->getConstraint()->getPrettyString();
  20058. }
  20059. $aliases = $this->extractAliases($links, $aliases);
  20060. $stabilityFlags = $this->extractStabilityFlags($links, $stabilityFlags, $realPackage->getMinimumStability());
  20061. $references = $this->extractReferences($links, $references);
  20062. if (isset($links[$config['name']])) {
  20063. throw new \RuntimeException(sprintf('Root package \'%s\' cannot require itself in its composer.json' . PHP_EOL .
  20064. 'Did you accidentally name your root package after an external package?', $config['name']));
  20065. }
  20066. }
  20067. }
  20068. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  20069. if (isset($config[$linkType])) {
  20070. foreach ($config[$linkType] as $linkName => $constraint) {
  20071. if ($err = ValidatingArrayLoader::hasPackageNamingError($linkName, true)) {
  20072. throw new \RuntimeException($linkType.'.'.$err);
  20073. }
  20074. }
  20075. }
  20076. }
  20077. $realPackage->setAliases($aliases);
  20078. $realPackage->setStabilityFlags($stabilityFlags);
  20079. $realPackage->setReferences($references);
  20080. if (isset($config['prefer-stable'])) {
  20081. $realPackage->setPreferStable((bool) $config['prefer-stable']);
  20082. }
  20083. if (isset($config['config'])) {
  20084. $realPackage->setConfig($config['config']);
  20085. }
  20086. $repos = RepositoryFactory::defaultRepos(null, $this->config, $this->manager);
  20087. foreach ($repos as $repo) {
  20088. $this->manager->addRepository($repo);
  20089. }
  20090. $realPackage->setRepositories($this->config->getRepositories());
  20091. return $package;
  20092. }
  20093. private function extractAliases(array $requires, array $aliases)
  20094. {
  20095. foreach ($requires as $reqName => $reqVersion) {
  20096. if (preg_match('{^([^,\s#]+)(?:#[^ ]+)? +as +([^,\s]+)$}', $reqVersion, $match)) {
  20097. $aliases[] = array(
  20098. 'package' => strtolower($reqName),
  20099. 'version' => $this->versionParser->normalize($match[1], $reqVersion),
  20100. 'alias' => $match[2],
  20101. 'alias_normalized' => $this->versionParser->normalize($match[2], $reqVersion),
  20102. );
  20103. } elseif (strpos($reqVersion, ' as ') !== false) {
  20104. throw new \UnexpectedValueException('Invalid alias definition in "'.$reqName.'": "'.$reqVersion.'". Aliases should be in the form "exact-version as other-exact-version".');
  20105. }
  20106. }
  20107. return $aliases;
  20108. }
  20109. private function extractStabilityFlags(array $requires, array $stabilityFlags, $minimumStability)
  20110. {
  20111. $stabilities = BasePackage::$stabilities;
  20112. $minimumStability = $stabilities[$minimumStability];
  20113. foreach ($requires as $reqName => $reqVersion) {
  20114. $constraints = array();
  20115. $orSplit = preg_split('{\s*\|\|?\s*}', trim($reqVersion));
  20116. foreach ($orSplit as $orConstraint) {
  20117. $andSplit = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $orConstraint);
  20118. foreach ($andSplit as $andConstraint) {
  20119. $constraints[] = $andConstraint;
  20120. }
  20121. }
  20122. $match = false;
  20123. foreach ($constraints as $constraint) {
  20124. if (preg_match('{^[^@]*?@('.implode('|', array_keys($stabilities)).')$}i', $constraint, $match)) {
  20125. $name = strtolower($reqName);
  20126. $stability = $stabilities[VersionParser::normalizeStability($match[1])];
  20127. if (isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) {
  20128. continue;
  20129. }
  20130. $stabilityFlags[$name] = $stability;
  20131. $match = true;
  20132. }
  20133. }
  20134. if ($match) {
  20135. continue;
  20136. }
  20137. foreach ($constraints as $constraint) {
  20138. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $constraint);
  20139. if (preg_match('{^[^,\s@]+$}', $reqVersion) && 'stable' !== ($stabilityName = VersionParser::parseStability($reqVersion))) {
  20140. $name = strtolower($reqName);
  20141. $stability = $stabilities[$stabilityName];
  20142. if ((isset($stabilityFlags[$name]) && $stabilityFlags[$name] > $stability) || ($minimumStability > $stability)) {
  20143. continue;
  20144. }
  20145. $stabilityFlags[$name] = $stability;
  20146. }
  20147. }
  20148. }
  20149. return $stabilityFlags;
  20150. }
  20151. private function extractReferences(array $requires, array $references)
  20152. {
  20153. foreach ($requires as $reqName => $reqVersion) {
  20154. $reqVersion = preg_replace('{^([^,\s@]+) as .+$}', '$1', $reqVersion);
  20155. if (preg_match('{^[^,\s@]+?#([a-f0-9]+)$}', $reqVersion, $match) && 'dev' === VersionParser::parseStability($reqVersion)) {
  20156. $name = strtolower($reqName);
  20157. $references[$name] = $match[1];
  20158. }
  20159. }
  20160. return $references;
  20161. }
  20162. }
  20163. <?php
  20164. namespace Composer\Package\Loader;
  20165. use Composer\Package\BasePackage;
  20166. use Composer\Semver\Constraint\Constraint;
  20167. use Composer\Package\Version\VersionParser;
  20168. use Composer\Repository\PlatformRepository;
  20169. use Composer\Spdx\SpdxLicenses;
  20170. class ValidatingArrayLoader implements LoaderInterface
  20171. {
  20172. const CHECK_ALL = 3;
  20173. const CHECK_UNBOUND_CONSTRAINTS = 1;
  20174. const CHECK_STRICT_CONSTRAINTS = 2;
  20175. private $loader;
  20176. private $versionParser;
  20177. private $errors;
  20178. private $warnings;
  20179. private $config;
  20180. private $strictName;
  20181. private $flags;
  20182. public function __construct(LoaderInterface $loader, $strictName = true, VersionParser $parser = null, $flags = 0)
  20183. {
  20184. $this->loader = $loader;
  20185. $this->versionParser = $parser ?: new VersionParser();
  20186. $this->strictName = $strictName;
  20187. $this->flags = $flags;
  20188. }
  20189. public function load(array $config, $class = 'Composer\Package\CompletePackage')
  20190. {
  20191. $this->errors = array();
  20192. $this->warnings = array();
  20193. $this->config = $config;
  20194. if ($err = self::hasPackageNamingError($config['name'])) {
  20195. $this->warnings[] = 'Deprecation warning: Your package name '.$err.' Make sure you fix this as Composer 2.0 will error.';
  20196. }
  20197. if ($this->strictName) {
  20198. $this->validateRegex('name', '[A-Za-z0-9][A-Za-z0-9_.-]*/[A-Za-z0-9][A-Za-z0-9_.-]*', true);
  20199. } else {
  20200. $this->validateString('name', true);
  20201. }
  20202. if (!empty($this->config['version'])) {
  20203. try {
  20204. $this->versionParser->normalize($this->config['version']);
  20205. } catch (\Exception $e) {
  20206. $this->errors[] = 'version : invalid value ('.$this->config['version'].'): '.$e->getMessage();
  20207. unset($this->config['version']);
  20208. }
  20209. }
  20210. if (!empty($this->config['config']['platform'])) {
  20211. foreach ((array) $this->config['config']['platform'] as $key => $platform) {
  20212. try {
  20213. $this->versionParser->normalize($platform);
  20214. } catch (\Exception $e) {
  20215. $this->errors[] = 'config.platform.' . $key . ' : invalid value ('.$platform.'): '.$e->getMessage();
  20216. }
  20217. }
  20218. }
  20219. $this->validateRegex('type', '[A-Za-z0-9-]+');
  20220. $this->validateString('target-dir');
  20221. $this->validateArray('extra');
  20222. if (isset($this->config['bin'])) {
  20223. if (is_string($this->config['bin'])) {
  20224. $this->validateString('bin');
  20225. } else {
  20226. $this->validateFlatArray('bin');
  20227. }
  20228. }
  20229. $this->validateArray('scripts');
  20230. $this->validateString('description');
  20231. $this->validateUrl('homepage');
  20232. $this->validateFlatArray('keywords', '[\p{N}\p{L} ._-]+');
  20233. $releaseDate = null;
  20234. $this->validateString('time');
  20235. if (!empty($this->config['time'])) {
  20236. try {
  20237. $releaseDate = new \DateTime($this->config['time'], new \DateTimeZone('UTC'));
  20238. } catch (\Exception $e) {
  20239. $this->errors[] = 'time : invalid value ('.$this->config['time'].'): '.$e->getMessage();
  20240. unset($this->config['time']);
  20241. }
  20242. }
  20243. if (isset($this->config['license']) && (!$releaseDate || $releaseDate->getTimestamp() >= strtotime('-8days'))) {
  20244. if (is_array($this->config['license']) || is_string($this->config['license'])) {
  20245. $licenses = (array) $this->config['license'];
  20246. $licenseValidator = new SpdxLicenses();
  20247. foreach ($licenses as $license) {
  20248. if ('proprietary' === $license) {
  20249. continue;
  20250. }
  20251. $licenseToValidate = str_replace('proprietary', 'MIT', $license);
  20252. if (!$licenseValidator->validate($licenseToValidate)) {
  20253. if ($licenseValidator->validate(trim($licenseToValidate))) {
  20254. $this->warnings[] = sprintf(
  20255. 'License %s must not contain extra spaces, make sure to trim it.',
  20256. json_encode($license)
  20257. );
  20258. } else {
  20259. $this->warnings[] = sprintf(
  20260. 'License %s is not a valid SPDX license identifier, see https://spdx.org/licenses/ if you use an open license.' . PHP_EOL .
  20261. 'If the software is closed-source, you may use "proprietary" as license.',
  20262. json_encode($license)
  20263. );
  20264. }
  20265. }
  20266. }
  20267. }
  20268. }
  20269. if ($this->validateArray('authors') && !empty($this->config['authors'])) {
  20270. foreach ($this->config['authors'] as $key => $author) {
  20271. if (!is_array($author)) {
  20272. $this->errors[] = 'authors.'.$key.' : should be an array, '.gettype($author).' given';
  20273. unset($this->config['authors'][$key]);
  20274. continue;
  20275. }
  20276. foreach (array('homepage', 'email', 'name', 'role') as $authorData) {
  20277. if (isset($author[$authorData]) && !is_string($author[$authorData])) {
  20278. $this->errors[] = 'authors.'.$key.'.'.$authorData.' : invalid value, must be a string';
  20279. unset($this->config['authors'][$key][$authorData]);
  20280. }
  20281. }
  20282. if (isset($author['homepage']) && !$this->filterUrl($author['homepage'])) {
  20283. $this->warnings[] = 'authors.'.$key.'.homepage : invalid value ('.$author['homepage'].'), must be an http/https URL';
  20284. unset($this->config['authors'][$key]['homepage']);
  20285. }
  20286. if (isset($author['email']) && !filter_var($author['email'], FILTER_VALIDATE_EMAIL)) {
  20287. $this->warnings[] = 'authors.'.$key.'.email : invalid value ('.$author['email'].'), must be a valid email address';
  20288. unset($this->config['authors'][$key]['email']);
  20289. }
  20290. if (empty($this->config['authors'][$key])) {
  20291. unset($this->config['authors'][$key]);
  20292. }
  20293. }
  20294. if (empty($this->config['authors'])) {
  20295. unset($this->config['authors']);
  20296. }
  20297. }
  20298. if ($this->validateArray('support') && !empty($this->config['support'])) {
  20299. foreach (array('issues', 'forum', 'wiki', 'source', 'email', 'irc', 'docs', 'rss', 'chat') as $key) {
  20300. if (isset($this->config['support'][$key]) && !is_string($this->config['support'][$key])) {
  20301. $this->errors[] = 'support.'.$key.' : invalid value, must be a string';
  20302. unset($this->config['support'][$key]);
  20303. }
  20304. }
  20305. if (isset($this->config['support']['email']) && !filter_var($this->config['support']['email'], FILTER_VALIDATE_EMAIL)) {
  20306. $this->warnings[] = 'support.email : invalid value ('.$this->config['support']['email'].'), must be a valid email address';
  20307. unset($this->config['support']['email']);
  20308. }
  20309. if (isset($this->config['support']['irc']) && !$this->filterUrl($this->config['support']['irc'], array('irc'))) {
  20310. $this->warnings[] = 'support.irc : invalid value ('.$this->config['support']['irc'].'), must be a irc://<server>/<channel> URL';
  20311. unset($this->config['support']['irc']);
  20312. }
  20313. foreach (array('issues', 'forum', 'wiki', 'source', 'docs', 'chat') as $key) {
  20314. if (isset($this->config['support'][$key]) && !$this->filterUrl($this->config['support'][$key])) {
  20315. $this->warnings[] = 'support.'.$key.' : invalid value ('.$this->config['support'][$key].'), must be an http/https URL';
  20316. unset($this->config['support'][$key]);
  20317. }
  20318. }
  20319. if (empty($this->config['support'])) {
  20320. unset($this->config['support']);
  20321. }
  20322. }
  20323. if ($this->validateArray('funding') && !empty($this->config['funding'])) {
  20324. foreach ($this->config['funding'] as $key => $fundingOption) {
  20325. if (!is_array($fundingOption)) {
  20326. $this->errors[] = 'funding.'.$key.' : should be an array, '.gettype($fundingOption).' given';
  20327. unset($this->config['funding'][$key]);
  20328. continue;
  20329. }
  20330. foreach (array('type', 'url') as $fundingData) {
  20331. if (isset($fundingOption[$fundingData]) && !is_string($fundingOption[$fundingData])) {
  20332. $this->errors[] = 'funding.'.$key.'.'.$fundingData.' : invalid value, must be a string';
  20333. unset($this->config['funding'][$key][$fundingData]);
  20334. }
  20335. }
  20336. if (isset($fundingOption['url']) && !$this->filterUrl($fundingOption['url'])) {
  20337. $this->warnings[] = 'funding.'.$key.'.url : invalid value ('.$fundingOption['url'].'), must be an http/https URL';
  20338. unset($this->config['funding'][$key]['url']);
  20339. }
  20340. if (empty($this->config['funding'][$key])) {
  20341. unset($this->config['funding'][$key]);
  20342. }
  20343. }
  20344. if (empty($this->config['funding'])) {
  20345. unset($this->config['funding']);
  20346. }
  20347. }
  20348. $unboundConstraint = new Constraint('=', '10000000-dev');
  20349. $stableConstraint = new Constraint('=', '1.0.0');
  20350. foreach (array_keys(BasePackage::$supportedLinkTypes) as $linkType) {
  20351. if ($this->validateArray($linkType) && isset($this->config[$linkType])) {
  20352. foreach ($this->config[$linkType] as $package => $constraint) {
  20353. if ($err = self::hasPackageNamingError($package, true)) {
  20354. $this->warnings[] = 'Deprecation warning: '.$linkType.'.'.$err.' Make sure you fix this as Composer 2.0 will error.';
  20355. } elseif (!preg_match('{^[A-Za-z0-9_./-]+$}', $package)) {
  20356. $this->warnings[] = $linkType.'.'.$package.' : invalid key, package names must be strings containing only [A-Za-z0-9_./-]';
  20357. }
  20358. if (!is_string($constraint)) {
  20359. $this->errors[] = $linkType.'.'.$package.' : invalid value, must be a string containing a version constraint';
  20360. unset($this->config[$linkType][$package]);
  20361. } elseif ('self.version' !== $constraint) {
  20362. try {
  20363. $linkConstraint = $this->versionParser->parseConstraints($constraint);
  20364. } catch (\Exception $e) {
  20365. $this->errors[] = $linkType.'.'.$package.' : invalid version constraint ('.$e->getMessage().')';
  20366. unset($this->config[$linkType][$package]);
  20367. continue;
  20368. }
  20369. if (
  20370. ($this->flags & self::CHECK_UNBOUND_CONSTRAINTS)
  20371. && 'require' === $linkType
  20372. && $linkConstraint->matches($unboundConstraint)
  20373. && !PlatformRepository::isPlatformPackage($package)
  20374. ) {
  20375. $this->warnings[] = $linkType.'.'.$package.' : unbound version constraints ('.$constraint.') should be avoided';
  20376. } elseif (
  20377. ($this->flags & self::CHECK_STRICT_CONSTRAINTS)
  20378. && 'require' === $linkType
  20379. && strpos($linkConstraint, '=') === 0
  20380. && $stableConstraint->versionCompare($stableConstraint, $linkConstraint, '<=')
  20381. ) {
  20382. $this->warnings[] = $linkType.'.'.$package.' : exact version constraints ('.$constraint.') should be avoided if the package follows semantic versioning';
  20383. }
  20384. }
  20385. }
  20386. }
  20387. }
  20388. if ($this->validateArray('suggest') && !empty($this->config['suggest'])) {
  20389. foreach ($this->config['suggest'] as $package => $description) {
  20390. if (!is_string($description)) {
  20391. $this->errors[] = 'suggest.'.$package.' : invalid value, must be a string describing why the package is suggested';
  20392. unset($this->config['suggest'][$package]);
  20393. }
  20394. }
  20395. }
  20396. if ($this->validateString('minimum-stability') && !empty($this->config['minimum-stability'])) {
  20397. if (!isset(BasePackage::$stabilities[$this->config['minimum-stability']])) {
  20398. $this->errors[] = 'minimum-stability : invalid value ('.$this->config['minimum-stability'].'), must be one of '.implode(', ', array_keys(BasePackage::$stabilities));
  20399. unset($this->config['minimum-stability']);
  20400. }
  20401. }
  20402. if ($this->validateArray('autoload') && !empty($this->config['autoload'])) {
  20403. $types = array('psr-0', 'psr-4', 'classmap', 'files', 'exclude-from-classmap');
  20404. foreach ($this->config['autoload'] as $type => $typeConfig) {
  20405. if (!in_array($type, $types)) {
  20406. $this->errors[] = 'autoload : invalid value ('.$type.'), must be one of '.implode(', ', $types);
  20407. unset($this->config['autoload'][$type]);
  20408. }
  20409. if ($type === 'psr-4') {
  20410. foreach ($typeConfig as $namespace => $dirs) {
  20411. if ($namespace !== '' && '\\' !== substr($namespace, -1)) {
  20412. $this->errors[] = 'autoload.psr-4 : invalid value ('.$namespace.'), namespaces must end with a namespace separator, should be '.$namespace.'\\\\';
  20413. }
  20414. }
  20415. }
  20416. }
  20417. }
  20418. if (!empty($this->config['autoload']['psr-4']) && !empty($this->config['target-dir'])) {
  20419. $this->errors[] = 'target-dir : this can not be used together with the autoload.psr-4 setting, remove target-dir to upgrade to psr-4';
  20420. unset($this->config['autoload']['psr-4']);
  20421. }
  20422. $this->validateFlatArray('include-path');
  20423. $this->validateArray('transport-options');
  20424. if (isset($this->config['extra']['branch-alias'])) {
  20425. if (!is_array($this->config['extra']['branch-alias'])) {
  20426. $this->errors[] = 'extra.branch-alias : must be an array of versions => aliases';
  20427. } else {
  20428. foreach ($this->config['extra']['branch-alias'] as $sourceBranch => $targetBranch) {
  20429. if ('-dev' !== substr($targetBranch, -4)) {
  20430. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must end in -dev';
  20431. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20432. continue;
  20433. }
  20434. $validatedTargetBranch = $this->versionParser->normalizeBranch(substr($targetBranch, 0, -4));
  20435. if ('-dev' !== substr($validatedTargetBranch, -4)) {
  20436. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') must be a parseable number like 2.0-dev';
  20437. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20438. continue;
  20439. }
  20440. if (($sourcePrefix = $this->versionParser->parseNumericAliasPrefix($sourceBranch))
  20441. && ($targetPrefix = $this->versionParser->parseNumericAliasPrefix($targetBranch))
  20442. && (stripos($targetPrefix, $sourcePrefix) !== 0)
  20443. ) {
  20444. $this->warnings[] = 'extra.branch-alias.'.$sourceBranch.' : the target branch ('.$targetBranch.') is not a valid numeric alias for this version';
  20445. unset($this->config['extra']['branch-alias'][$sourceBranch]);
  20446. }
  20447. }
  20448. }
  20449. }
  20450. if ($this->errors) {
  20451. throw new InvalidPackageException($this->errors, $this->warnings, $config);
  20452. }
  20453. $package = $this->loader->load($this->config, $class);
  20454. $this->config = null;
  20455. return $package;
  20456. }
  20457. public function getWarnings()
  20458. {
  20459. return $this->warnings;
  20460. }
  20461. public function getErrors()
  20462. {
  20463. return $this->errors;
  20464. }
  20465. public static function hasPackageNamingError($name, $isLink = false)
  20466. {
  20467. if (PlatformRepository::isPlatformPackage($name)) {
  20468. return;
  20469. }
  20470. if (!preg_match('{^[a-z0-9](?:[_.-]?[a-z0-9]+)*/[a-z0-9](?:(?:[_.]?|-{0,2})[a-z0-9]+)*$}iD', $name)) {
  20471. 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]+)*$".';
  20472. }
  20473. $reservedNames = array('nul', 'con', 'prn', 'aux', 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9', 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9');
  20474. $bits = explode('/', strtolower($name));
  20475. if (in_array($bits[0], $reservedNames, true) || in_array($bits[1], $reservedNames, true)) {
  20476. return $name.' is reserved, package and vendor names can not match any of: '.implode(', ', $reservedNames).'.';
  20477. }
  20478. if (preg_match('{\.json$}', $name)) {
  20479. return $name.' is invalid, package names can not end in .json, consider renaming it or perhaps using a -json suffix instead.';
  20480. }
  20481. if (preg_match('{[A-Z]}', $name)) {
  20482. if ($isLink) {
  20483. return $name.' is invalid, it should not contain uppercase characters. Please use '.strtolower($name).' instead.';
  20484. }
  20485. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $name);
  20486. $suggestName = strtolower($suggestName);
  20487. return $name.' is invalid, it should not contain uppercase characters. We suggest using '.$suggestName.' instead.';
  20488. }
  20489. }
  20490. private function validateRegex($property, $regex, $mandatory = false)
  20491. {
  20492. if (!$this->validateString($property, $mandatory)) {
  20493. return false;
  20494. }
  20495. if (!preg_match('{^'.$regex.'$}u', $this->config[$property])) {
  20496. $message = $property.' : invalid value ('.$this->config[$property].'), must match '.$regex;
  20497. if ($mandatory) {
  20498. $this->errors[] = $message;
  20499. } else {
  20500. $this->warnings[] = $message;
  20501. }
  20502. unset($this->config[$property]);
  20503. return false;
  20504. }
  20505. return true;
  20506. }
  20507. private function validateString($property, $mandatory = false)
  20508. {
  20509. if (isset($this->config[$property]) && !is_string($this->config[$property])) {
  20510. $this->errors[] = $property.' : should be a string, '.gettype($this->config[$property]).' given';
  20511. unset($this->config[$property]);
  20512. return false;
  20513. }
  20514. if (!isset($this->config[$property]) || trim($this->config[$property]) === '') {
  20515. if ($mandatory) {
  20516. $this->errors[] = $property.' : must be present';
  20517. }
  20518. unset($this->config[$property]);
  20519. return false;
  20520. }
  20521. return true;
  20522. }
  20523. private function validateArray($property, $mandatory = false)
  20524. {
  20525. if (isset($this->config[$property]) && !is_array($this->config[$property])) {
  20526. $this->errors[] = $property.' : should be an array, '.gettype($this->config[$property]).' given';
  20527. unset($this->config[$property]);
  20528. return false;
  20529. }
  20530. if (!isset($this->config[$property]) || !count($this->config[$property])) {
  20531. if ($mandatory) {
  20532. $this->errors[] = $property.' : must be present and contain at least one element';
  20533. }
  20534. unset($this->config[$property]);
  20535. return false;
  20536. }
  20537. return true;
  20538. }
  20539. private function validateFlatArray($property, $regex = null, $mandatory = false)
  20540. {
  20541. if (!$this->validateArray($property, $mandatory)) {
  20542. return false;
  20543. }
  20544. $pass = true;
  20545. foreach ($this->config[$property] as $key => $value) {
  20546. if (!is_string($value) && !is_numeric($value)) {
  20547. $this->errors[] = $property.'.'.$key.' : must be a string or int, '.gettype($value).' given';
  20548. unset($this->config[$property][$key]);
  20549. $pass = false;
  20550. continue;
  20551. }
  20552. if ($regex && !preg_match('{^'.$regex.'$}u', $value)) {
  20553. $this->warnings[] = $property.'.'.$key.' : invalid value ('.$value.'), must match '.$regex;
  20554. unset($this->config[$property][$key]);
  20555. $pass = false;
  20556. }
  20557. }
  20558. return $pass;
  20559. }
  20560. private function validateUrl($property, $mandatory = false)
  20561. {
  20562. if (!$this->validateString($property, $mandatory)) {
  20563. return false;
  20564. }
  20565. if (!$this->filterUrl($this->config[$property])) {
  20566. $this->warnings[] = $property.' : invalid value ('.$this->config[$property].'), must be an http/https URL';
  20567. unset($this->config[$property]);
  20568. return false;
  20569. }
  20570. return true;
  20571. }
  20572. private function filterUrl($value, array $schemes = array('http', 'https'))
  20573. {
  20574. if ($value === '') {
  20575. return true;
  20576. }
  20577. $bits = parse_url($value);
  20578. if (empty($bits['scheme']) || empty($bits['host'])) {
  20579. return false;
  20580. }
  20581. if (!in_array($bits['scheme'], $schemes, true)) {
  20582. return false;
  20583. }
  20584. return true;
  20585. }
  20586. }
  20587. <?php
  20588. namespace Composer\Package;
  20589. use Composer\Json\JsonFile;
  20590. use Composer\Installer\InstallationManager;
  20591. use Composer\Repository\LockArrayRepository;
  20592. use Composer\Util\ProcessExecutor;
  20593. use Composer\Package\Dumper\ArrayDumper;
  20594. use Composer\Package\Loader\ArrayLoader;
  20595. use Composer\Package\Version\VersionParser;
  20596. use Composer\Plugin\PluginInterface;
  20597. use Composer\Util\Git as GitUtil;
  20598. use Composer\IO\IOInterface;
  20599. use Seld\JsonLint\ParsingException;
  20600. class Locker
  20601. {
  20602. private $lockFile;
  20603. private $installationManager;
  20604. private $hash;
  20605. private $contentHash;
  20606. private $loader;
  20607. private $dumper;
  20608. private $process;
  20609. private $lockDataCache;
  20610. private $virtualFileWritten;
  20611. public function __construct(IOInterface $io, JsonFile $lockFile, InstallationManager $installationManager, $composerFileContents, ProcessExecutor $process = null)
  20612. {
  20613. $this->lockFile = $lockFile;
  20614. $this->installationManager = $installationManager;
  20615. $this->hash = md5($composerFileContents);
  20616. $this->contentHash = self::getContentHash($composerFileContents);
  20617. $this->loader = new ArrayLoader(null, true);
  20618. $this->dumper = new ArrayDumper();
  20619. $this->process = $process ?: new ProcessExecutor($io);
  20620. }
  20621. public static function getContentHash($composerFileContents)
  20622. {
  20623. $content = json_decode($composerFileContents, true);
  20624. $relevantKeys = array(
  20625. 'name',
  20626. 'version',
  20627. 'require',
  20628. 'require-dev',
  20629. 'conflict',
  20630. 'replace',
  20631. 'provide',
  20632. 'minimum-stability',
  20633. 'prefer-stable',
  20634. 'repositories',
  20635. 'extra',
  20636. );
  20637. $relevantContent = array();
  20638. foreach (array_intersect($relevantKeys, array_keys($content)) as $key) {
  20639. $relevantContent[$key] = $content[$key];
  20640. }
  20641. if (isset($content['config']['platform'])) {
  20642. $relevantContent['config']['platform'] = $content['config']['platform'];
  20643. }
  20644. ksort($relevantContent);
  20645. return md5(json_encode($relevantContent));
  20646. }
  20647. public function isLocked()
  20648. {
  20649. if (!$this->virtualFileWritten && !$this->lockFile->exists()) {
  20650. return false;
  20651. }
  20652. $data = $this->getLockData();
  20653. return isset($data['packages']);
  20654. }
  20655. public function isFresh()
  20656. {
  20657. $lock = $this->lockFile->read();
  20658. if (!empty($lock['content-hash'])) {
  20659. return $this->contentHash === $lock['content-hash'];
  20660. }
  20661. if (!empty($lock['hash'])) {
  20662. return $this->hash === $lock['hash'];
  20663. }
  20664. return false;
  20665. }
  20666. public function getLockedRepository($withDevReqs = false)
  20667. {
  20668. $lockData = $this->getLockData();
  20669. $packages = new LockArrayRepository();
  20670. $lockedPackages = $lockData['packages'];
  20671. if ($withDevReqs) {
  20672. if (isset($lockData['packages-dev'])) {
  20673. $lockedPackages = array_merge($lockedPackages, $lockData['packages-dev']);
  20674. } else {
  20675. 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.');
  20676. }
  20677. }
  20678. if (empty($lockedPackages)) {
  20679. return $packages;
  20680. }
  20681. if (isset($lockedPackages[0]['name'])) {
  20682. $packageByName = array();
  20683. foreach ($lockedPackages as $info) {
  20684. $package = $this->loader->load($info);
  20685. $packages->addPackage($package);
  20686. $packageByName[$package->getName()] = $package;
  20687. if ($package instanceof AliasPackage) {
  20688. $packageByName[$package->getAliasOf()->getName()] = $package->getAliasOf();
  20689. }
  20690. }
  20691. if (isset($lockData['aliases'])) {
  20692. foreach ($lockData['aliases'] as $alias) {
  20693. if (isset($packageByName[$alias['package']])) {
  20694. $aliasPkg = new AliasPackage($packageByName[$alias['package']], $alias['alias_normalized'], $alias['alias']);
  20695. $aliasPkg->setRootPackageAlias(true);
  20696. $packages->addPackage($aliasPkg);
  20697. }
  20698. }
  20699. }
  20700. return $packages;
  20701. }
  20702. throw new \RuntimeException('Your composer.lock is invalid. Run "composer update" to generate a new one.');
  20703. }
  20704. public function getDevPackageNames()
  20705. {
  20706. $names = array();
  20707. $lockData = $this->getLockData();
  20708. if (isset($lockData['packages-dev'])) {
  20709. foreach ($lockData['packages-dev'] as $package) {
  20710. $names[] = strtolower($package['name']);
  20711. }
  20712. }
  20713. return $names;
  20714. }
  20715. public function getPlatformRequirements($withDevReqs = false)
  20716. {
  20717. $lockData = $this->getLockData();
  20718. $requirements = array();
  20719. if (!empty($lockData['platform'])) {
  20720. $requirements = $this->loader->parseLinks(
  20721. '__root__',
  20722. '1.0.0',
  20723. Link::TYPE_REQUIRE,
  20724. isset($lockData['platform']) ? $lockData['platform'] : array()
  20725. );
  20726. }
  20727. if ($withDevReqs && !empty($lockData['platform-dev'])) {
  20728. $devRequirements = $this->loader->parseLinks(
  20729. '__root__',
  20730. '1.0.0',
  20731. Link::TYPE_REQUIRE,
  20732. isset($lockData['platform-dev']) ? $lockData['platform-dev'] : array()
  20733. );
  20734. $requirements = array_merge($requirements, $devRequirements);
  20735. }
  20736. return $requirements;
  20737. }
  20738. public function getMinimumStability()
  20739. {
  20740. $lockData = $this->getLockData();
  20741. return isset($lockData['minimum-stability']) ? $lockData['minimum-stability'] : 'stable';
  20742. }
  20743. public function getStabilityFlags()
  20744. {
  20745. $lockData = $this->getLockData();
  20746. return isset($lockData['stability-flags']) ? $lockData['stability-flags'] : array();
  20747. }
  20748. public function getPreferStable()
  20749. {
  20750. $lockData = $this->getLockData();
  20751. return isset($lockData['prefer-stable']) ? $lockData['prefer-stable'] : null;
  20752. }
  20753. public function getPreferLowest()
  20754. {
  20755. $lockData = $this->getLockData();
  20756. return isset($lockData['prefer-lowest']) ? $lockData['prefer-lowest'] : null;
  20757. }
  20758. public function getPlatformOverrides()
  20759. {
  20760. $lockData = $this->getLockData();
  20761. return isset($lockData['platform-overrides']) ? $lockData['platform-overrides'] : array();
  20762. }
  20763. public function getAliases()
  20764. {
  20765. $lockData = $this->getLockData();
  20766. return isset($lockData['aliases']) ? $lockData['aliases'] : array();
  20767. }
  20768. public function getLockData()
  20769. {
  20770. if (null !== $this->lockDataCache) {
  20771. return $this->lockDataCache;
  20772. }
  20773. if (!$this->lockFile->exists()) {
  20774. throw new \LogicException('No lockfile found. Unable to read locked packages');
  20775. }
  20776. return $this->lockDataCache = $this->lockFile->read();
  20777. }
  20778. public function setLockData(array $packages, $devPackages, array $platformReqs, $platformDevReqs, array $aliases, $minimumStability, array $stabilityFlags, $preferStable, $preferLowest, array $platformOverrides, $write = true)
  20779. {
  20780. $aliases = array_map(function ($alias) {
  20781. if (in_array($alias['version'], array('dev-master', 'dev-trunk', 'dev-default'), true)) {
  20782. $alias['version'] = VersionParser::DEFAULT_BRANCH_ALIAS;
  20783. }
  20784. return $alias;
  20785. }, $aliases);
  20786. $lock = array(
  20787. '_readme' => array('This file locks the dependencies of your project to a known state',
  20788. 'Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies',
  20789. 'This file is @gener'.'ated automatically', ),
  20790. 'content-hash' => $this->contentHash,
  20791. 'packages' => null,
  20792. 'packages-dev' => null,
  20793. 'aliases' => $aliases,
  20794. 'minimum-stability' => $minimumStability,
  20795. 'stability-flags' => $stabilityFlags,
  20796. 'prefer-stable' => $preferStable,
  20797. 'prefer-lowest' => $preferLowest,
  20798. );
  20799. $lock['packages'] = $this->lockPackages($packages);
  20800. if (null !== $devPackages) {
  20801. $lock['packages-dev'] = $this->lockPackages($devPackages);
  20802. }
  20803. $lock['platform'] = $platformReqs;
  20804. $lock['platform-dev'] = $platformDevReqs;
  20805. if ($platformOverrides) {
  20806. $lock['platform-overrides'] = $platformOverrides;
  20807. }
  20808. $lock['plugin-api-version'] = PluginInterface::PLUGIN_API_VERSION;
  20809. try {
  20810. $isLocked = $this->isLocked();
  20811. } catch (ParsingException $e) {
  20812. $isLocked = false;
  20813. }
  20814. if (!$isLocked || $lock !== $this->getLockData()) {
  20815. if ($write) {
  20816. $this->lockFile->write($lock);
  20817. $this->lockDataCache = null;
  20818. $this->virtualFileWritten = false;
  20819. } else {
  20820. $this->virtualFileWritten = true;
  20821. $this->lockDataCache = JsonFile::parseJson(JsonFile::encode($lock, 448 & JsonFile::JSON_PRETTY_PRINT));
  20822. }
  20823. return true;
  20824. }
  20825. return false;
  20826. }
  20827. private function lockPackages(array $packages)
  20828. {
  20829. $locked = array();
  20830. foreach ($packages as $package) {
  20831. if ($package instanceof AliasPackage) {
  20832. continue;
  20833. }
  20834. $name = $package->getPrettyName();
  20835. $version = $package->getPrettyVersion();
  20836. if (!$name || !$version) {
  20837. throw new \LogicException(sprintf(
  20838. 'Package "%s" has no version or name and can not be locked',
  20839. $package
  20840. ));
  20841. }
  20842. $spec = $this->dumper->dump($package);
  20843. unset($spec['version_normalized']);
  20844. $time = isset($spec['time']) ? $spec['time'] : null;
  20845. unset($spec['time']);
  20846. if ($package->isDev() && $package->getInstallationSource() === 'source') {
  20847. $time = $this->getPackageTime($package) ?: $time;
  20848. }
  20849. if (null !== $time) {
  20850. $spec['time'] = $time;
  20851. }
  20852. unset($spec['installation-source']);
  20853. $locked[] = $spec;
  20854. }
  20855. usort($locked, function ($a, $b) {
  20856. $comparison = strcmp($a['name'], $b['name']);
  20857. if (0 !== $comparison) {
  20858. return $comparison;
  20859. }
  20860. return strcmp($a['version'], $b['version']);
  20861. });
  20862. return $locked;
  20863. }
  20864. private function getPackageTime(PackageInterface $package)
  20865. {
  20866. if (!function_exists('proc_open')) {
  20867. return null;
  20868. }
  20869. $path = realpath($this->installationManager->getInstallPath($package));
  20870. $sourceType = $package->getSourceType();
  20871. $datetime = null;
  20872. if ($path && in_array($sourceType, array('git', 'hg'))) {
  20873. $sourceRef = $package->getSourceReference() ?: $package->getDistReference();
  20874. switch ($sourceType) {
  20875. case 'git':
  20876. GitUtil::cleanEnv();
  20877. 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)) {
  20878. $datetime = new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  20879. }
  20880. break;
  20881. case 'hg':
  20882. if (0 === $this->process->execute('hg log --template "{date|hgdate}" -r '.ProcessExecutor::escape($sourceRef), $output, $path) && preg_match('{^\s*(\d+)\s*}', $output, $match)) {
  20883. $datetime = new \DateTime('@'.$match[1], new \DateTimeZone('UTC'));
  20884. }
  20885. break;
  20886. }
  20887. }
  20888. return $datetime ? $datetime->format(DATE_RFC3339) : null;
  20889. }
  20890. }
  20891. <?php
  20892. namespace Composer\Package;
  20893. use Composer\Package\Version\VersionParser;
  20894. use Composer\Util\ComposerMirror;
  20895. class Package extends BasePackage
  20896. {
  20897. protected $type;
  20898. protected $targetDir;
  20899. protected $installationSource;
  20900. protected $sourceType;
  20901. protected $sourceUrl;
  20902. protected $sourceReference;
  20903. protected $sourceMirrors;
  20904. protected $distType;
  20905. protected $distUrl;
  20906. protected $distReference;
  20907. protected $distSha1Checksum;
  20908. protected $distMirrors;
  20909. protected $version;
  20910. protected $prettyVersion;
  20911. protected $releaseDate;
  20912. protected $extra = array();
  20913. protected $binaries = array();
  20914. protected $dev;
  20915. protected $stability;
  20916. protected $notificationUrl;
  20917. protected $requires = array();
  20918. protected $conflicts = array();
  20919. protected $provides = array();
  20920. protected $replaces = array();
  20921. protected $devRequires = array();
  20922. protected $suggests = array();
  20923. protected $autoload = array();
  20924. protected $devAutoload = array();
  20925. protected $includePaths = array();
  20926. protected $archiveName;
  20927. protected $archiveExcludes = array();
  20928. protected $isDefaultBranch = false;
  20929. public function __construct($name, $version, $prettyVersion)
  20930. {
  20931. parent::__construct($name);
  20932. $this->version = $version;
  20933. $this->prettyVersion = $prettyVersion;
  20934. $this->stability = VersionParser::parseStability($version);
  20935. $this->dev = $this->stability === 'dev';
  20936. }
  20937. public function isDev()
  20938. {
  20939. return $this->dev;
  20940. }
  20941. public function setType($type)
  20942. {
  20943. $this->type = $type;
  20944. }
  20945. public function getType()
  20946. {
  20947. return $this->type ?: 'library';
  20948. }
  20949. public function getStability()
  20950. {
  20951. return $this->stability;
  20952. }
  20953. public function setTargetDir($targetDir)
  20954. {
  20955. $this->targetDir = $targetDir;
  20956. }
  20957. public function getTargetDir()
  20958. {
  20959. if (null === $this->targetDir) {
  20960. return;
  20961. }
  20962. return ltrim(preg_replace('{ (?:^|[\\\\/]+) \.\.? (?:[\\\\/]+|$) (?:\.\.? (?:[\\\\/]+|$) )*}x', '/', $this->targetDir), '/');
  20963. }
  20964. public function setExtra(array $extra)
  20965. {
  20966. $this->extra = $extra;
  20967. }
  20968. public function getExtra()
  20969. {
  20970. return $this->extra;
  20971. }
  20972. public function setBinaries(array $binaries)
  20973. {
  20974. $this->binaries = $binaries;
  20975. }
  20976. public function getBinaries()
  20977. {
  20978. return $this->binaries;
  20979. }
  20980. public function setInstallationSource($type)
  20981. {
  20982. $this->installationSource = $type;
  20983. }
  20984. public function getInstallationSource()
  20985. {
  20986. return $this->installationSource;
  20987. }
  20988. public function setSourceType($type)
  20989. {
  20990. $this->sourceType = $type;
  20991. }
  20992. public function getSourceType()
  20993. {
  20994. return $this->sourceType;
  20995. }
  20996. public function setSourceUrl($url)
  20997. {
  20998. $this->sourceUrl = $url;
  20999. }
  21000. public function getSourceUrl()
  21001. {
  21002. return $this->sourceUrl;
  21003. }
  21004. public function setSourceReference($reference)
  21005. {
  21006. $this->sourceReference = $reference;
  21007. }
  21008. public function getSourceReference()
  21009. {
  21010. return $this->sourceReference;
  21011. }
  21012. public function setSourceMirrors($mirrors)
  21013. {
  21014. $this->sourceMirrors = $mirrors;
  21015. }
  21016. public function getSourceMirrors()
  21017. {
  21018. return $this->sourceMirrors;
  21019. }
  21020. public function getSourceUrls()
  21021. {
  21022. return $this->getUrls($this->sourceUrl, $this->sourceMirrors, $this->sourceReference, $this->sourceType, 'source');
  21023. }
  21024. public function setDistType($type)
  21025. {
  21026. $this->distType = $type;
  21027. }
  21028. public function getDistType()
  21029. {
  21030. return $this->distType;
  21031. }
  21032. public function setDistUrl($url)
  21033. {
  21034. $this->distUrl = $url;
  21035. }
  21036. public function getDistUrl()
  21037. {
  21038. return $this->distUrl;
  21039. }
  21040. public function setDistReference($reference)
  21041. {
  21042. $this->distReference = $reference;
  21043. }
  21044. public function getDistReference()
  21045. {
  21046. return $this->distReference;
  21047. }
  21048. public function setDistSha1Checksum($sha1checksum)
  21049. {
  21050. $this->distSha1Checksum = $sha1checksum;
  21051. }
  21052. public function getDistSha1Checksum()
  21053. {
  21054. return $this->distSha1Checksum;
  21055. }
  21056. public function setDistMirrors($mirrors)
  21057. {
  21058. $this->distMirrors = $mirrors;
  21059. }
  21060. public function getDistMirrors()
  21061. {
  21062. return $this->distMirrors;
  21063. }
  21064. public function getDistUrls()
  21065. {
  21066. return $this->getUrls($this->distUrl, $this->distMirrors, $this->distReference, $this->distType, 'dist');
  21067. }
  21068. public function getVersion()
  21069. {
  21070. return $this->version;
  21071. }
  21072. public function getPrettyVersion()
  21073. {
  21074. return $this->prettyVersion;
  21075. }
  21076. public function setReleaseDate(\DateTime $releaseDate)
  21077. {
  21078. $this->releaseDate = $releaseDate;
  21079. }
  21080. public function getReleaseDate()
  21081. {
  21082. return $this->releaseDate;
  21083. }
  21084. public function setRequires(array $requires)
  21085. {
  21086. $this->requires = $requires;
  21087. }
  21088. public function getRequires()
  21089. {
  21090. return $this->requires;
  21091. }
  21092. public function setConflicts(array $conflicts)
  21093. {
  21094. $this->conflicts = $conflicts;
  21095. }
  21096. public function getConflicts()
  21097. {
  21098. return $this->conflicts;
  21099. }
  21100. public function setProvides(array $provides)
  21101. {
  21102. $this->provides = $provides;
  21103. }
  21104. public function getProvides()
  21105. {
  21106. return $this->provides;
  21107. }
  21108. public function setReplaces(array $replaces)
  21109. {
  21110. $this->replaces = $replaces;
  21111. }
  21112. public function getReplaces()
  21113. {
  21114. return $this->replaces;
  21115. }
  21116. public function setDevRequires(array $devRequires)
  21117. {
  21118. $this->devRequires = $devRequires;
  21119. }
  21120. public function getDevRequires()
  21121. {
  21122. return $this->devRequires;
  21123. }
  21124. public function setSuggests(array $suggests)
  21125. {
  21126. $this->suggests = $suggests;
  21127. }
  21128. public function getSuggests()
  21129. {
  21130. return $this->suggests;
  21131. }
  21132. public function setAutoload(array $autoload)
  21133. {
  21134. $this->autoload = $autoload;
  21135. }
  21136. public function getAutoload()
  21137. {
  21138. return $this->autoload;
  21139. }
  21140. public function setDevAutoload(array $devAutoload)
  21141. {
  21142. $this->devAutoload = $devAutoload;
  21143. }
  21144. public function getDevAutoload()
  21145. {
  21146. return $this->devAutoload;
  21147. }
  21148. public function setIncludePaths(array $includePaths)
  21149. {
  21150. $this->includePaths = $includePaths;
  21151. }
  21152. public function getIncludePaths()
  21153. {
  21154. return $this->includePaths;
  21155. }
  21156. public function setNotificationUrl($notificationUrl)
  21157. {
  21158. $this->notificationUrl = $notificationUrl;
  21159. }
  21160. public function getNotificationUrl()
  21161. {
  21162. return $this->notificationUrl;
  21163. }
  21164. public function setArchiveName($name)
  21165. {
  21166. $this->archiveName = $name;
  21167. }
  21168. public function getArchiveName()
  21169. {
  21170. return $this->archiveName;
  21171. }
  21172. public function setArchiveExcludes(array $excludes)
  21173. {
  21174. $this->archiveExcludes = $excludes;
  21175. }
  21176. public function getArchiveExcludes()
  21177. {
  21178. return $this->archiveExcludes;
  21179. }
  21180. public function setIsDefaultBranch($defaultBranch)
  21181. {
  21182. $this->isDefaultBranch = $defaultBranch;
  21183. }
  21184. public function isDefaultBranch()
  21185. {
  21186. return $this->isDefaultBranch;
  21187. }
  21188. public function setSourceDistReferences($reference)
  21189. {
  21190. $this->setSourceReference($reference);
  21191. if (preg_match('{^https?://(?:(?:www\.)?bitbucket\.org|(api\.)?github\.com|(?:www\.)?gitlab\.com)/}i', $this->getDistUrl())) {
  21192. $this->setDistReference($reference);
  21193. $this->setDistUrl(preg_replace('{(?<=/|sha=)[a-f0-9]{40}(?=/|$)}i', $reference, $this->getDistUrl()));
  21194. } elseif ($this->getDistReference()) {
  21195. $this->setDistReference($reference);
  21196. }
  21197. }
  21198. public function replaceVersion($version, $prettyVersion)
  21199. {
  21200. $this->version = $version;
  21201. $this->prettyVersion = $prettyVersion;
  21202. $this->stability = VersionParser::parseStability($version);
  21203. $this->dev = $this->stability === 'dev';
  21204. }
  21205. protected function getUrls($url, $mirrors, $ref, $type, $urlType)
  21206. {
  21207. if (!$url) {
  21208. return array();
  21209. }
  21210. $urls = array($url);
  21211. if ($mirrors) {
  21212. foreach ($mirrors as $mirror) {
  21213. if ($urlType === 'dist') {
  21214. $mirrorUrl = ComposerMirror::processUrl($mirror['url'], $this->name, $this->version, $ref, $type);
  21215. } elseif ($urlType === 'source' && $type === 'git') {
  21216. $mirrorUrl = ComposerMirror::processGitUrl($mirror['url'], $this->name, $url, $type);
  21217. } elseif ($urlType === 'source' && $type === 'hg') {
  21218. $mirrorUrl = ComposerMirror::processHgUrl($mirror['url'], $this->name, $url, $type);
  21219. } else {
  21220. continue;
  21221. }
  21222. if (!\in_array($mirrorUrl, $urls)) {
  21223. $func = $mirror['preferred'] ? 'array_unshift' : 'array_push';
  21224. $func($urls, $mirrorUrl);
  21225. }
  21226. }
  21227. }
  21228. return $urls;
  21229. }
  21230. }
  21231. <?php
  21232. namespace Composer\Package;
  21233. use Composer\Repository\RepositoryInterface;
  21234. interface PackageInterface
  21235. {
  21236. const DISPLAY_SOURCE_REF_IF_DEV = 0;
  21237. const DISPLAY_SOURCE_REF = 1;
  21238. const DISPLAY_DIST_REF = 2;
  21239. public function getName();
  21240. public function getPrettyName();
  21241. public function getNames($provides = true);
  21242. public function setId($id);
  21243. public function getId();
  21244. public function isDev();
  21245. public function getType();
  21246. public function getTargetDir();
  21247. public function getExtra();
  21248. public function setInstallationSource($type);
  21249. public function getInstallationSource();
  21250. public function getSourceType();
  21251. public function getSourceUrl();
  21252. public function getSourceUrls();
  21253. public function getSourceReference();
  21254. public function getSourceMirrors();
  21255. public function getDistType();
  21256. public function getDistUrl();
  21257. public function getDistUrls();
  21258. public function getDistReference();
  21259. public function getDistSha1Checksum();
  21260. public function getDistMirrors();
  21261. public function getVersion();
  21262. public function getPrettyVersion();
  21263. public function getFullPrettyVersion($truncate = true, $displayMode = self::DISPLAY_SOURCE_REF_IF_DEV);
  21264. public function getReleaseDate();
  21265. public function getStability();
  21266. public function getRequires();
  21267. public function getConflicts();
  21268. public function getProvides();
  21269. public function getReplaces();
  21270. public function getDevRequires();
  21271. public function getSuggests();
  21272. public function getAutoload();
  21273. public function getDevAutoload();
  21274. public function getIncludePaths();
  21275. public function setRepository(RepositoryInterface $repository);
  21276. public function getRepository();
  21277. public function getBinaries();
  21278. public function getUniqueName();
  21279. public function getNotificationUrl();
  21280. public function __toString();
  21281. public function getPrettyString();
  21282. public function getArchiveName();
  21283. public function getArchiveExcludes();
  21284. public function isDefaultBranch();
  21285. public function getTransportOptions();
  21286. public function setSourceReference($reference);
  21287. public function setDistUrl($url);
  21288. public function setDistType($type);
  21289. public function setDistReference($reference);
  21290. public function setSourceDistReferences($reference);
  21291. }
  21292. <?php
  21293. namespace Composer\Package;
  21294. class RootAliasPackage extends AliasPackage implements RootPackageInterface
  21295. {
  21296. public function __construct(RootPackageInterface $aliasOf, $version, $prettyVersion)
  21297. {
  21298. parent::__construct($aliasOf, $version, $prettyVersion);
  21299. }
  21300. public function getAliases()
  21301. {
  21302. return $this->aliasOf->getAliases();
  21303. }
  21304. public function getMinimumStability()
  21305. {
  21306. return $this->aliasOf->getMinimumStability();
  21307. }
  21308. public function getStabilityFlags()
  21309. {
  21310. return $this->aliasOf->getStabilityFlags();
  21311. }
  21312. public function getReferences()
  21313. {
  21314. return $this->aliasOf->getReferences();
  21315. }
  21316. public function getPreferStable()
  21317. {
  21318. return $this->aliasOf->getPreferStable();
  21319. }
  21320. public function getConfig()
  21321. {
  21322. return $this->aliasOf->getConfig();
  21323. }
  21324. public function setRequires(array $require)
  21325. {
  21326. $this->requires = $this->replaceSelfVersionDependencies($require, Link::TYPE_REQUIRE);
  21327. $this->aliasOf->setRequires($require);
  21328. }
  21329. public function setDevRequires(array $devRequire)
  21330. {
  21331. $this->devRequires = $this->replaceSelfVersionDependencies($devRequire, Link::TYPE_DEV_REQUIRE);
  21332. $this->aliasOf->setDevRequires($devRequire);
  21333. }
  21334. public function setConflicts(array $conflicts)
  21335. {
  21336. $this->conflicts = $this->replaceSelfVersionDependencies($conflicts, Link::TYPE_CONFLICT);
  21337. $this->aliasOf->setConflicts($conflicts);
  21338. }
  21339. public function setProvides(array $provides)
  21340. {
  21341. $this->provides = $this->replaceSelfVersionDependencies($provides, Link::TYPE_PROVIDE);
  21342. $this->aliasOf->setProvides($provides);
  21343. }
  21344. public function setReplaces(array $replaces)
  21345. {
  21346. $this->replaces = $this->replaceSelfVersionDependencies($replaces, Link::TYPE_REPLACE);
  21347. $this->aliasOf->setReplaces($replaces);
  21348. }
  21349. public function setRepositories($repositories)
  21350. {
  21351. $this->aliasOf->setRepositories($repositories);
  21352. }
  21353. public function setAutoload(array $autoload)
  21354. {
  21355. $this->aliasOf->setAutoload($autoload);
  21356. }
  21357. public function setDevAutoload(array $devAutoload)
  21358. {
  21359. $this->aliasOf->setDevAutoload($devAutoload);
  21360. }
  21361. public function setStabilityFlags(array $stabilityFlags)
  21362. {
  21363. $this->aliasOf->setStabilityFlags($stabilityFlags);
  21364. }
  21365. public function setSuggests(array $suggests)
  21366. {
  21367. $this->aliasOf->setSuggests($suggests);
  21368. }
  21369. public function setExtra(array $extra)
  21370. {
  21371. $this->aliasOf->setExtra($extra);
  21372. }
  21373. public function __clone()
  21374. {
  21375. parent::__clone();
  21376. $this->aliasOf = clone $this->aliasOf;
  21377. }
  21378. }
  21379. <?php
  21380. namespace Composer\Package;
  21381. class RootPackage extends CompletePackage implements RootPackageInterface
  21382. {
  21383. const DEFAULT_PRETTY_VERSION = '1.0.0+no-version-set';
  21384. protected $minimumStability = 'stable';
  21385. protected $preferStable = false;
  21386. protected $stabilityFlags = array();
  21387. protected $config = array();
  21388. protected $references = array();
  21389. protected $aliases = array();
  21390. public function setMinimumStability($minimumStability)
  21391. {
  21392. $this->minimumStability = $minimumStability;
  21393. }
  21394. public function getMinimumStability()
  21395. {
  21396. return $this->minimumStability;
  21397. }
  21398. public function setStabilityFlags(array $stabilityFlags)
  21399. {
  21400. $this->stabilityFlags = $stabilityFlags;
  21401. }
  21402. public function getStabilityFlags()
  21403. {
  21404. return $this->stabilityFlags;
  21405. }
  21406. public function setPreferStable($preferStable)
  21407. {
  21408. $this->preferStable = $preferStable;
  21409. }
  21410. public function getPreferStable()
  21411. {
  21412. return $this->preferStable;
  21413. }
  21414. public function setConfig(array $config)
  21415. {
  21416. $this->config = $config;
  21417. }
  21418. public function getConfig()
  21419. {
  21420. return $this->config;
  21421. }
  21422. public function setReferences(array $references)
  21423. {
  21424. $this->references = $references;
  21425. }
  21426. public function getReferences()
  21427. {
  21428. return $this->references;
  21429. }
  21430. public function setAliases(array $aliases)
  21431. {
  21432. $this->aliases = $aliases;
  21433. }
  21434. public function getAliases()
  21435. {
  21436. return $this->aliases;
  21437. }
  21438. }
  21439. <?php
  21440. namespace Composer\Package;
  21441. interface RootPackageInterface extends CompletePackageInterface
  21442. {
  21443. public function getAliases();
  21444. public function getMinimumStability();
  21445. public function getStabilityFlags();
  21446. public function getReferences();
  21447. public function getPreferStable();
  21448. public function getConfig();
  21449. public function setRequires(array $requires);
  21450. public function setDevRequires(array $devRequires);
  21451. public function setConflicts(array $conflicts);
  21452. public function setProvides(array $provides);
  21453. public function setReplaces(array $replaces);
  21454. public function setRepositories($repositories);
  21455. public function setAutoload(array $autoload);
  21456. public function setDevAutoload(array $devAutoload);
  21457. public function setStabilityFlags(array $stabilityFlags);
  21458. public function setSuggests(array $suggests);
  21459. public function setExtra(array $extra);
  21460. }
  21461. <?php
  21462. namespace Composer\Package\Version;
  21463. use Composer\Package\BasePackage;
  21464. class StabilityFilter
  21465. {
  21466. public static function isPackageAcceptable(array $acceptableStabilities, array $stabilityFlags, $names, $stability)
  21467. {
  21468. foreach ($names as $name) {
  21469. if (isset($stabilityFlags[$name])) {
  21470. if (BasePackage::$stabilities[$stability] <= $stabilityFlags[$name]) {
  21471. return true;
  21472. }
  21473. } elseif (isset($acceptableStabilities[$stability])) {
  21474. return true;
  21475. }
  21476. }
  21477. return false;
  21478. }
  21479. }
  21480. <?php
  21481. namespace Composer\Package\Version;
  21482. use Composer\Config;
  21483. use Composer\Repository\Vcs\HgDriver;
  21484. use Composer\IO\NullIO;
  21485. use Composer\Semver\VersionParser as SemverVersionParser;
  21486. use Composer\Util\Git as GitUtil;
  21487. use Composer\Util\HttpDownloader;
  21488. use Composer\Util\ProcessExecutor;
  21489. use Composer\Util\Svn as SvnUtil;
  21490. class VersionGuesser
  21491. {
  21492. private $config;
  21493. private $process;
  21494. private $versionParser;
  21495. public function __construct(Config $config, ProcessExecutor $process, SemverVersionParser $versionParser)
  21496. {
  21497. $this->config = $config;
  21498. $this->process = $process;
  21499. $this->versionParser = $versionParser;
  21500. }
  21501. public function guessVersion(array $packageConfig, $path)
  21502. {
  21503. if (!function_exists('proc_open')) {
  21504. return null;
  21505. }
  21506. $versionData = $this->guessGitVersion($packageConfig, $path);
  21507. if (null !== $versionData && null !== $versionData['version']) {
  21508. return $this->postprocess($versionData);
  21509. }
  21510. $versionData = $this->guessHgVersion($packageConfig, $path);
  21511. if (null !== $versionData && null !== $versionData['version']) {
  21512. return $this->postprocess($versionData);
  21513. }
  21514. $versionData = $this->guessFossilVersion($path);
  21515. if (null !== $versionData && null !== $versionData['version']) {
  21516. return $this->postprocess($versionData);
  21517. }
  21518. $versionData = $this->guessSvnVersion($packageConfig, $path);
  21519. if (null !== $versionData && null !== $versionData['version']) {
  21520. return $this->postprocess($versionData);
  21521. }
  21522. return null;
  21523. }
  21524. private function postprocess(array $versionData)
  21525. {
  21526. if (!empty($versionData['feature_version']) && $versionData['feature_version'] === $versionData['version'] && $versionData['feature_pretty_version'] === $versionData['pretty_version']) {
  21527. unset($versionData['feature_version'], $versionData['feature_pretty_version']);
  21528. }
  21529. if ('-dev' === substr($versionData['version'], -4) && preg_match('{\.9{7}}', $versionData['version'])) {
  21530. $versionData['pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['version']);
  21531. }
  21532. if (!empty($versionData['feature_version']) && '-dev' === substr($versionData['feature_version'], -4) && preg_match('{\.9{7}}', $versionData['feature_version'])) {
  21533. $versionData['feature_pretty_version'] = preg_replace('{(\.9{7})+}', '.x', $versionData['feature_version']);
  21534. }
  21535. return $versionData;
  21536. }
  21537. private function guessGitVersion(array $packageConfig, $path)
  21538. {
  21539. GitUtil::cleanEnv();
  21540. $commit = null;
  21541. $version = null;
  21542. $prettyVersion = null;
  21543. $featureVersion = null;
  21544. $featurePrettyVersion = null;
  21545. $isDetached = false;
  21546. if (0 === $this->process->execute('git branch -a --no-color --no-abbrev -v', $output, $path)) {
  21547. $branches = array();
  21548. $isFeatureBranch = false;
  21549. foreach ($this->process->splitLines($output) as $branch) {
  21550. if ($branch && preg_match('{^(?:\* ) *(\(no branch\)|\(detached from \S+\)|\(HEAD detached at \S+\)|\S+) *([a-f0-9]+) .*$}', $branch, $match)) {
  21551. if (
  21552. $match[1] === '(no branch)'
  21553. || strpos($match[1], '(detached ') === 0
  21554. || strpos($match[1], '(HEAD detached at') === 0
  21555. ) {
  21556. $version = 'dev-' . $match[2];
  21557. $prettyVersion = $version;
  21558. $isFeatureBranch = true;
  21559. $isDetached = true;
  21560. } else {
  21561. $version = $this->versionParser->normalizeBranch($match[1]);
  21562. $prettyVersion = 'dev-' . $match[1];
  21563. $isFeatureBranch = $this->isFeatureBranch($packageConfig, $match[1]);
  21564. }
  21565. if ($match[2]) {
  21566. $commit = $match[2];
  21567. }
  21568. }
  21569. if ($branch && !preg_match('{^ *.+/HEAD }', $branch)) {
  21570. if (preg_match('{^(?:\* )? *((?:remotes/(?:origin|upstream)/)?[^\s/]+) *([a-f0-9]+) .*$}', $branch, $match)) {
  21571. $branches[] = $match[1];
  21572. }
  21573. }
  21574. }
  21575. if ($isFeatureBranch) {
  21576. $featureVersion = $version;
  21577. $featurePrettyVersion = $prettyVersion;
  21578. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'git rev-list %candidate%..%branch%', $path);
  21579. $version = $result['version'];
  21580. $prettyVersion = $result['pretty_version'];
  21581. }
  21582. }
  21583. if (!$version || $isDetached) {
  21584. $result = $this->versionFromGitTags($path);
  21585. if ($result) {
  21586. $version = $result['version'];
  21587. $prettyVersion = $result['pretty_version'];
  21588. $featureVersion = null;
  21589. $featurePrettyVersion = null;
  21590. }
  21591. }
  21592. if (!$commit) {
  21593. $command = 'git log --pretty="%H" -n1 HEAD'.GitUtil::getNoShowSignatureFlag($this->process);
  21594. if (0 === $this->process->execute($command, $output, $path)) {
  21595. $commit = trim($output) ?: null;
  21596. }
  21597. }
  21598. if ($featureVersion) {
  21599. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion, 'feature_version' => $featureVersion, 'feature_pretty_version' => $featurePrettyVersion);
  21600. }
  21601. return array('version' => $version, 'commit' => $commit, 'pretty_version' => $prettyVersion);
  21602. }
  21603. private function versionFromGitTags($path)
  21604. {
  21605. if (0 === $this->process->execute('git describe --exact-match --tags', $output, $path)) {
  21606. try {
  21607. $version = $this->versionParser->normalize(trim($output));
  21608. return array('version' => $version, 'pretty_version' => trim($output));
  21609. } catch (\Exception $e) {
  21610. }
  21611. }
  21612. return null;
  21613. }
  21614. private function guessHgVersion(array $packageConfig, $path)
  21615. {
  21616. if (0 === $this->process->execute('hg branch', $output, $path)) {
  21617. $branch = trim($output);
  21618. $version = $this->versionParser->normalizeBranch($branch);
  21619. $isFeatureBranch = 0 === strpos($version, 'dev-');
  21620. if (VersionParser::DEFAULT_BRANCH_ALIAS === $version) {
  21621. return array('version' => $version, 'commit' => null, 'pretty_version' => 'dev-'.$branch);
  21622. }
  21623. if (!$isFeatureBranch) {
  21624. return array('version' => $version, 'commit' => null, 'pretty_version' => $version);
  21625. }
  21626. $io = new NullIO();
  21627. $driver = new HgDriver(array('url' => $path), $io, $this->config, new HttpDownloader($io, $this->config), $this->process);
  21628. $branches = array_keys($driver->getBranches());
  21629. $result = $this->guessFeatureVersion($packageConfig, $version, $branches, 'hg log -r "not ancestors(\'%candidate%\') and ancestors(\'%branch%\')" --template "{node}\\n"', $path);
  21630. $result['commit'] = '';
  21631. $result['feature_version'] = $version;
  21632. $result['feature_pretty_version'] = $version;
  21633. return $result;
  21634. }
  21635. }
  21636. private function guessFeatureVersion(array $packageConfig, $version, array $branches, $scmCmdline, $path)
  21637. {
  21638. $prettyVersion = $version;
  21639. if (!isset($packageConfig['extra']['branch-alias'][$version])
  21640. || strpos(json_encode($packageConfig), '"self.version"')
  21641. ) {
  21642. $branch = preg_replace('{^dev-}', '', $version);
  21643. $length = PHP_INT_MAX;
  21644. if (!$this->isFeatureBranch($packageConfig, $branch)) {
  21645. return array('version' => $version, 'pretty_version' => $prettyVersion);
  21646. }
  21647. usort($branches, function ($a, $b) {
  21648. $aRemote = 0 === strpos($a, 'remotes/');
  21649. $bRemote = 0 === strpos($b, 'remotes/');
  21650. if ($aRemote !== $bRemote) {
  21651. return $aRemote ? 1 : -1;
  21652. }
  21653. return strnatcasecmp($b, $a);
  21654. });
  21655. foreach ($branches as $candidate) {
  21656. $candidateVersion = preg_replace('{^remotes/\S+/}', '', $candidate);
  21657. if ($candidate === $branch || $this->isFeatureBranch($packageConfig, $candidateVersion)) {
  21658. continue;
  21659. }
  21660. $cmdLine = str_replace(array('%candidate%', '%branch%'), array($candidate, $branch), $scmCmdline);
  21661. if (0 !== $this->process->execute($cmdLine, $output, $path)) {
  21662. continue;
  21663. }
  21664. if (strlen($output) < $length) {
  21665. $length = strlen($output);
  21666. $version = $this->versionParser->normalizeBranch($candidateVersion);
  21667. $prettyVersion = 'dev-' . $candidateVersion;
  21668. if ($length === 0) {
  21669. break;
  21670. }
  21671. }
  21672. }
  21673. }
  21674. return array('version' => $version, 'pretty_version' => $prettyVersion);
  21675. }
  21676. private function isFeatureBranch(array $packageConfig, $branchName)
  21677. {
  21678. $nonFeatureBranches = '';
  21679. if (!empty($packageConfig['non-feature-branches'])) {
  21680. $nonFeatureBranches = implode('|', $packageConfig['non-feature-branches']);
  21681. }
  21682. return !preg_match('{^(' . $nonFeatureBranches . '|master|main|latest|next|current|support|tip|trunk|default|develop|\d+\..+)$}', $branchName, $match);
  21683. }
  21684. private function guessFossilVersion($path)
  21685. {
  21686. $version = null;
  21687. $prettyVersion = null;
  21688. if (0 === $this->process->execute('fossil branch list', $output, $path)) {
  21689. $branch = trim($output);
  21690. $version = $this->versionParser->normalizeBranch($branch);
  21691. $prettyVersion = 'dev-' . $branch;
  21692. }
  21693. if (0 === $this->process->execute('fossil tag list', $output, $path)) {
  21694. try {
  21695. $version = $this->versionParser->normalize(trim($output));
  21696. $prettyVersion = trim($output);
  21697. } catch (\Exception $e) {
  21698. }
  21699. }
  21700. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21701. }
  21702. private function guessSvnVersion(array $packageConfig, $path)
  21703. {
  21704. SvnUtil::cleanEnv();
  21705. if (0 === $this->process->execute('svn info --xml', $output, $path)) {
  21706. $trunkPath = isset($packageConfig['trunk-path']) ? preg_quote($packageConfig['trunk-path'], '#') : 'trunk';
  21707. $branchesPath = isset($packageConfig['branches-path']) ? preg_quote($packageConfig['branches-path'], '#') : 'branches';
  21708. $tagsPath = isset($packageConfig['tags-path']) ? preg_quote($packageConfig['tags-path'], '#') : 'tags';
  21709. $urlPattern = '#<url>.*/(' . $trunkPath . '|(' . $branchesPath . '|' . $tagsPath . ')/(.*))</url>#';
  21710. if (preg_match($urlPattern, $output, $matches)) {
  21711. if (isset($matches[2]) && ($branchesPath === $matches[2] || $tagsPath === $matches[2])) {
  21712. $version = $this->versionParser->normalizeBranch($matches[3]);
  21713. $prettyVersion = 'dev-' . $matches[3];
  21714. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21715. }
  21716. $prettyVersion = trim($matches[1]);
  21717. if ($prettyVersion === 'trunk') {
  21718. $version = 'dev-trunk';
  21719. } else {
  21720. $version = $this->versionParser->normalize($prettyVersion);
  21721. }
  21722. return array('version' => $version, 'commit' => '', 'pretty_version' => $prettyVersion);
  21723. }
  21724. }
  21725. }
  21726. }
  21727. <?php
  21728. namespace Composer\Package\Version;
  21729. use Composer\Repository\PlatformRepository;
  21730. use Composer\Semver\VersionParser as SemverVersionParser;
  21731. use Composer\Semver\Semver;
  21732. class VersionParser extends SemverVersionParser
  21733. {
  21734. const DEFAULT_BRANCH_ALIAS = '9999999-dev';
  21735. private static $constraints = array();
  21736. public function parseConstraints($constraints)
  21737. {
  21738. if (!isset(self::$constraints[$constraints])) {
  21739. self::$constraints[$constraints] = parent::parseConstraints($constraints);
  21740. }
  21741. return self::$constraints[$constraints];
  21742. }
  21743. public function parseNameVersionPairs(array $pairs)
  21744. {
  21745. $pairs = array_values($pairs);
  21746. $result = array();
  21747. for ($i = 0, $count = count($pairs); $i < $count; $i++) {
  21748. $pair = preg_replace('{^([^=: ]+)[=: ](.*)$}', '$1 $2', trim($pairs[$i]));
  21749. if (false === strpos($pair, ' ') && isset($pairs[$i + 1]) && false === strpos($pairs[$i + 1], '/') && !PlatformRepository::isPlatformPackage($pairs[$i + 1])) {
  21750. $pair .= ' '.$pairs[$i + 1];
  21751. $i++;
  21752. }
  21753. if (strpos($pair, ' ')) {
  21754. list($name, $version) = explode(' ', $pair, 2);
  21755. $result[] = array('name' => $name, 'version' => $version);
  21756. } else {
  21757. $result[] = array('name' => $pair);
  21758. }
  21759. }
  21760. return $result;
  21761. }
  21762. public static function isUpgrade($normalizedFrom, $normalizedTo)
  21763. {
  21764. if ($normalizedFrom === $normalizedTo) {
  21765. return true;
  21766. }
  21767. $normalizedFrom = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEFAULT_BRANCH_ALIAS, $normalizedFrom);
  21768. $normalizedTo = str_replace(array('dev-master', 'dev-trunk', 'dev-default'), VersionParser::DEFAULT_BRANCH_ALIAS, $normalizedTo);
  21769. if (strpos($normalizedFrom, 'dev-') === 0 || strpos($normalizedTo, 'dev-') === 0) {
  21770. return true;
  21771. }
  21772. $sorted = Semver::sort(array($normalizedTo, $normalizedFrom));
  21773. return $sorted[0] === $normalizedFrom;
  21774. }
  21775. }
  21776. <?php
  21777. namespace Composer\Package\Version;
  21778. use Composer\Package\BasePackage;
  21779. use Composer\Package\AliasPackage;
  21780. use Composer\Package\PackageInterface;
  21781. use Composer\Composer;
  21782. use Composer\Package\Loader\ArrayLoader;
  21783. use Composer\Package\Dumper\ArrayDumper;
  21784. use Composer\Repository\RepositorySet;
  21785. use Composer\Repository\PlatformRepository;
  21786. use Composer\Semver\Constraint\Constraint;
  21787. class VersionSelector
  21788. {
  21789. private $repositorySet;
  21790. private $platformConstraints = array();
  21791. private $parser;
  21792. public function __construct(RepositorySet $repositorySet, PlatformRepository $platformRepo = null)
  21793. {
  21794. $this->repositorySet = $repositorySet;
  21795. if ($platformRepo) {
  21796. foreach ($platformRepo->getPackages() as $package) {
  21797. $this->platformConstraints[$package->getName()][] = new Constraint('==', $package->getVersion());
  21798. }
  21799. }
  21800. }
  21801. public function findBestCandidate($packageName, $targetPackageVersion = null, $preferredStability = 'stable', $ignorePlatformReqs = false, $repoSetFlags = 0)
  21802. {
  21803. if (!isset(BasePackage::$stabilities[$preferredStability])) {
  21804. throw new \UnexpectedValueException('Expected a valid stability name as 3rd argument, got '.$preferredStability);
  21805. }
  21806. $constraint = $targetPackageVersion ? $this->getParser()->parseConstraints($targetPackageVersion) : null;
  21807. $candidates = $this->repositorySet->findPackages(strtolower($packageName), $constraint, $repoSetFlags);
  21808. if ($this->platformConstraints && true !== $ignorePlatformReqs) {
  21809. $platformConstraints = $this->platformConstraints;
  21810. $ignorePlatformReqs = $ignorePlatformReqs ?: array();
  21811. $candidates = array_filter($candidates, function ($pkg) use ($platformConstraints, $ignorePlatformReqs) {
  21812. $reqs = $pkg->getRequires();
  21813. foreach ($reqs as $name => $link) {
  21814. if (!in_array($name, $ignorePlatformReqs, true) && isset($platformConstraints[$name])) {
  21815. foreach ($platformConstraints[$name] as $constraint) {
  21816. if ($link->getConstraint()->matches($constraint)) {
  21817. continue 2;
  21818. }
  21819. }
  21820. return false;
  21821. }
  21822. }
  21823. return true;
  21824. });
  21825. }
  21826. if (!$candidates) {
  21827. return false;
  21828. }
  21829. $package = reset($candidates);
  21830. $minPriority = BasePackage::$stabilities[$preferredStability];
  21831. foreach ($candidates as $candidate) {
  21832. $candidatePriority = $candidate->getStabilityPriority();
  21833. $currentPriority = $package->getStabilityPriority();
  21834. if ($minPriority < $candidatePriority && $currentPriority < $candidatePriority) {
  21835. continue;
  21836. }
  21837. if ($minPriority < $candidatePriority && $candidatePriority < $currentPriority) {
  21838. $package = $candidate;
  21839. continue;
  21840. }
  21841. if ($minPriority >= $candidatePriority && $minPriority < $currentPriority) {
  21842. $package = $candidate;
  21843. continue;
  21844. }
  21845. if (version_compare($package->getVersion(), $candidate->getVersion(), '<')) {
  21846. $package = $candidate;
  21847. }
  21848. }
  21849. if ($package instanceof AliasPackage && $package->getVersion() === VersionParser::DEFAULT_BRANCH_ALIAS) {
  21850. $package = $package->getAliasOf();
  21851. }
  21852. return $package;
  21853. }
  21854. public function findRecommendedRequireVersion(PackageInterface $package)
  21855. {
  21856. $version = $package->getVersion();
  21857. if (!$package->isDev()) {
  21858. return $this->transformVersion($version, $package->getPrettyVersion(), $package->getStability());
  21859. }
  21860. $loader = new ArrayLoader($this->getParser());
  21861. $dumper = new ArrayDumper();
  21862. $extra = $loader->getBranchAlias($dumper->dump($package));
  21863. if ($extra && $extra !== VersionParser::DEFAULT_BRANCH_ALIAS) {
  21864. $extra = preg_replace('{^(\d+\.\d+\.\d+)(\.9999999)-dev$}', '$1.0', $extra, -1, $count);
  21865. if ($count) {
  21866. $extra = str_replace('.9999999', '.0', $extra);
  21867. return $this->transformVersion($extra, $extra, 'dev');
  21868. }
  21869. }
  21870. return $package->getPrettyVersion();
  21871. }
  21872. private function transformVersion($version, $prettyVersion, $stability)
  21873. {
  21874. $semanticVersionParts = explode('.', $version);
  21875. if (count($semanticVersionParts) == 4 && preg_match('{^0\D?}', $semanticVersionParts[3])) {
  21876. if ($semanticVersionParts[0] === '0') {
  21877. unset($semanticVersionParts[3]);
  21878. } else {
  21879. unset($semanticVersionParts[2], $semanticVersionParts[3]);
  21880. }
  21881. $version = implode('.', $semanticVersionParts);
  21882. } else {
  21883. return $prettyVersion;
  21884. }
  21885. if ($stability != 'stable') {
  21886. $version .= '@'.$stability;
  21887. }
  21888. return '^' . $version;
  21889. }
  21890. private function getParser()
  21891. {
  21892. if ($this->parser === null) {
  21893. $this->parser = new VersionParser();
  21894. }
  21895. return $this->parser;
  21896. }
  21897. }
  21898. <?php
  21899. namespace Composer\Platform;
  21900. use Composer\Util\Platform;
  21901. use Composer\Util\ProcessExecutor;
  21902. use Symfony\Component\Process\ExecutableFinder;
  21903. class HhvmDetector
  21904. {
  21905. private static $hhvmVersion;
  21906. private $executableFinder;
  21907. private $processExecutor;
  21908. public function __construct(ExecutableFinder $executableFinder = null, ProcessExecutor $processExecutor = null)
  21909. {
  21910. $this->executableFinder = $executableFinder;
  21911. $this->processExecutor = $processExecutor;
  21912. }
  21913. public function reset()
  21914. {
  21915. self::$hhvmVersion = null;
  21916. }
  21917. public function getVersion()
  21918. {
  21919. if (null !== self::$hhvmVersion) {
  21920. return self::$hhvmVersion ?: null;
  21921. }
  21922. self::$hhvmVersion = defined('HHVM_VERSION') ? HHVM_VERSION : null;
  21923. if (self::$hhvmVersion === null && !Platform::isWindows()) {
  21924. self::$hhvmVersion = false;
  21925. $this->executableFinder = $this->executableFinder ?: new ExecutableFinder();
  21926. $hhvmPath = $this->executableFinder->find('hhvm');
  21927. if ($hhvmPath !== null) {
  21928. $this->processExecutor = $this->processExecutor ?: new ProcessExecutor();
  21929. $exitCode = $this->processExecutor->execute(
  21930. ProcessExecutor::escape($hhvmPath).
  21931. ' --php -d hhvm.jit=0 -r "echo HHVM_VERSION;" 2>/dev/null',
  21932. self::$hhvmVersion
  21933. );
  21934. if ($exitCode !== 0) {
  21935. self::$hhvmVersion = false;
  21936. }
  21937. }
  21938. }
  21939. return self::$hhvmVersion;
  21940. }
  21941. }
  21942. <?php
  21943. namespace Composer\Platform;
  21944. class Runtime
  21945. {
  21946. public function hasConstant($constant, $class = null)
  21947. {
  21948. return defined(ltrim($class.'::'.$constant, ':'));
  21949. }
  21950. public function getConstant($constant, $class = null)
  21951. {
  21952. return constant(ltrim($class.'::'.$constant, ':'));
  21953. }
  21954. public function hasFunction($fn)
  21955. {
  21956. return function_exists($fn);
  21957. }
  21958. public function invoke($callable, array $arguments = array())
  21959. {
  21960. return call_user_func_array($callable, $arguments);
  21961. }
  21962. public function hasClass($class)
  21963. {
  21964. return class_exists($class, false);
  21965. }
  21966. public function construct($class, array $arguments = array())
  21967. {
  21968. if (empty($arguments)) {
  21969. return new $class;
  21970. }
  21971. $refl = new \ReflectionClass($class);
  21972. return $refl->newInstanceArgs($arguments);
  21973. }
  21974. public function getExtensions()
  21975. {
  21976. return get_loaded_extensions();
  21977. }
  21978. public function getExtensionVersion($extension)
  21979. {
  21980. return phpversion($extension);
  21981. }
  21982. public function getExtensionInfo($extension)
  21983. {
  21984. $reflector = new \ReflectionExtension($extension);
  21985. ob_start();
  21986. $reflector->info();
  21987. return ob_get_clean();
  21988. }
  21989. }
  21990. <?php
  21991. namespace Composer\Platform;
  21992. class Version
  21993. {
  21994. public static function parseOpenssl($opensslVersion, &$isFips)
  21995. {
  21996. $isFips = false;
  21997. if (!preg_match('/^(?<version>[0-9.]+)(?<patch>[a-z]{0,2})?(?<suffix>(?:-?(?:dev|pre|alpha|beta|rc|fips)[\d]*)*)?$/', $opensslVersion, $matches)) {
  21998. return null;
  21999. }
  22000. $isFips = strpos($matches['suffix'], 'fips') !== false;
  22001. $suffix = strtr('-'.ltrim($matches['suffix'], '-'), array('-fips' => '', '-pre' => '-alpha'));
  22002. $patch = self::convertAlphaVersionToIntVersion($matches['patch']);
  22003. return rtrim($matches['version'].'.'.$patch.$suffix, '-');
  22004. }
  22005. public static function parseLibjpeg($libjpegVersion)
  22006. {
  22007. if (!preg_match('/^(?<major>\d+)(?<minor>[a-z]*)$/', $libjpegVersion, $matches)) {
  22008. return null;
  22009. }
  22010. return $matches['major'].'.'.self::convertAlphaVersionToIntVersion($matches['minor']);
  22011. }
  22012. public static function parseZoneinfoVersion($zoneinfoVersion)
  22013. {
  22014. if (!preg_match('/^(?<year>\d{4})(?<revision>[a-z]*)$/', $zoneinfoVersion, $matches)) {
  22015. return null;
  22016. }
  22017. return $matches['year'].'.'.self::convertAlphaVersionToIntVersion($matches['revision']);
  22018. }
  22019. private static function convertAlphaVersionToIntVersion($alpha)
  22020. {
  22021. return strlen($alpha) * (-ord('a') + 1) + array_sum(array_map('ord', str_split($alpha)));
  22022. }
  22023. public static function convertLibxpmVersionId($versionId)
  22024. {
  22025. return self::convertVersionId($versionId, 100);
  22026. }
  22027. public static function convertOpenldapVersionId($versionId)
  22028. {
  22029. return self::convertVersionId($versionId, 100);
  22030. }
  22031. private static function convertVersionId($versionId, $base)
  22032. {
  22033. return sprintf(
  22034. '%d.%d.%d',
  22035. $versionId / ($base * $base),
  22036. ($versionId / $base) % $base,
  22037. $versionId % $base
  22038. );
  22039. }
  22040. }
  22041. <?php
  22042. namespace Composer\Plugin\Capability;
  22043. interface Capability
  22044. {
  22045. }
  22046. <?php
  22047. namespace Composer\Plugin\Capability;
  22048. interface CommandProvider extends Capability
  22049. {
  22050. public function getCommands();
  22051. }
  22052. <?php
  22053. namespace Composer\Plugin;
  22054. interface Capable
  22055. {
  22056. public function getCapabilities();
  22057. }
  22058. <?php
  22059. namespace Composer\Plugin;
  22060. use Composer\EventDispatcher\Event;
  22061. use Symfony\Component\Console\Input\InputInterface;
  22062. use Symfony\Component\Console\Output\OutputInterface;
  22063. class CommandEvent extends Event
  22064. {
  22065. private $commandName;
  22066. private $input;
  22067. private $output;
  22068. public function __construct($name, $commandName, $input, $output, array $args = array(), array $flags = array())
  22069. {
  22070. parent::__construct($name, $args, $flags);
  22071. $this->commandName = $commandName;
  22072. $this->input = $input;
  22073. $this->output = $output;
  22074. }
  22075. public function getInput()
  22076. {
  22077. return $this->input;
  22078. }
  22079. public function getOutput()
  22080. {
  22081. return $this->output;
  22082. }
  22083. public function getCommandName()
  22084. {
  22085. return $this->commandName;
  22086. }
  22087. }
  22088. <?php
  22089. namespace Composer\Plugin;
  22090. class PluginEvents
  22091. {
  22092. const INIT = 'init';
  22093. const COMMAND = 'command';
  22094. const PRE_FILE_DOWNLOAD = 'pre-file-download';
  22095. const POST_FILE_DOWNLOAD = 'post-file-download';
  22096. const PRE_COMMAND_RUN = 'pre-command-run';
  22097. const PRE_POOL_CREATE = 'pre-pool-create';
  22098. }
  22099. <?php
  22100. namespace Composer\Plugin;
  22101. use Composer\Composer;
  22102. use Composer\IO\IOInterface;
  22103. interface PluginInterface
  22104. {
  22105. const PLUGIN_API_VERSION = '2.0.0';
  22106. public function activate(Composer $composer, IOInterface $io);
  22107. public function deactivate(Composer $composer, IOInterface $io);
  22108. public function uninstall(Composer $composer, IOInterface $io);
  22109. }
  22110. <?php
  22111. namespace Composer\Plugin;
  22112. use Composer\Composer;
  22113. use Composer\EventDispatcher\EventSubscriberInterface;
  22114. use Composer\IO\IOInterface;
  22115. use Composer\Package\CompletePackage;
  22116. use Composer\Package\Package;
  22117. use Composer\Package\RootPackage;
  22118. use Composer\Package\Version\VersionParser;
  22119. use Composer\Repository\RepositoryInterface;
  22120. use Composer\Repository\InstalledRepository;
  22121. use Composer\Repository\RootPackageRepository;
  22122. use Composer\Package\PackageInterface;
  22123. use Composer\Package\Link;
  22124. use Composer\Semver\Constraint\Constraint;
  22125. use Composer\Plugin\Capability\Capability;
  22126. use Composer\Util\PackageSorter;
  22127. class PluginManager
  22128. {
  22129. protected $composer;
  22130. protected $io;
  22131. protected $globalComposer;
  22132. protected $versionParser;
  22133. protected $disablePlugins = false;
  22134. protected $plugins = array();
  22135. protected $registeredPlugins = array();
  22136. private static $classCounter = 0;
  22137. public function __construct(IOInterface $io, Composer $composer, Composer $globalComposer = null, $disablePlugins = false)
  22138. {
  22139. $this->io = $io;
  22140. $this->composer = $composer;
  22141. $this->globalComposer = $globalComposer;
  22142. $this->versionParser = new VersionParser();
  22143. $this->disablePlugins = $disablePlugins;
  22144. }
  22145. public function loadInstalledPlugins()
  22146. {
  22147. if ($this->disablePlugins) {
  22148. return;
  22149. }
  22150. $repo = $this->composer->getRepositoryManager()->getLocalRepository();
  22151. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  22152. if ($repo) {
  22153. $this->loadRepository($repo, false);
  22154. }
  22155. if ($globalRepo) {
  22156. $this->loadRepository($globalRepo, true);
  22157. }
  22158. }
  22159. public function getPlugins()
  22160. {
  22161. return $this->plugins;
  22162. }
  22163. public function getGlobalComposer()
  22164. {
  22165. return $this->globalComposer;
  22166. }
  22167. public function registerPackage(PackageInterface $package, $failOnMissingClasses = false, $isGlobalPlugin = false)
  22168. {
  22169. if ($this->disablePlugins) {
  22170. return;
  22171. }
  22172. if ($package->getType() === 'composer-plugin') {
  22173. $requiresComposer = null;
  22174. foreach ($package->getRequires() as $link) {
  22175. if ('composer-plugin-api' === $link->getTarget()) {
  22176. $requiresComposer = $link->getConstraint();
  22177. break;
  22178. }
  22179. }
  22180. if (!$requiresComposer) {
  22181. throw new \RuntimeException("Plugin ".$package->getName()." is missing a require statement for a version of the composer-plugin-api package.");
  22182. }
  22183. $currentPluginApiVersion = $this->getPluginApiVersion();
  22184. $currentPluginApiConstraint = new Constraint('==', $this->versionParser->normalize($currentPluginApiVersion));
  22185. if ($requiresComposer->getPrettyString() === $this->getPluginApiVersion()) {
  22186. $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>');
  22187. } elseif (!$requiresComposer->matches($currentPluginApiConstraint)) {
  22188. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin '.($isGlobalPlugin ? '(installed globally) ' : '').'was skipped because it requires a Plugin API version ("' . $requiresComposer->getPrettyString() . '") that does not match your Composer installation ("' . $currentPluginApiVersion . '"). You may need to run composer update with the "--no-plugins" option.</warning>');
  22189. return;
  22190. }
  22191. if ($package->getName() === 'symfony/flex' && preg_match('{^[0-9.]+$}', $package->getVersion()) && version_compare($package->getVersion(), '1.9.8', '<')) {
  22192. $this->io->writeError('<warning>The "' . $package->getName() . '" plugin '.($isGlobalPlugin ? '(installed globally) ' : '').'was skipped because it is not compatible with Composer 2+. Make sure to update it to version 1.9.8 or greater.</warning>');
  22193. return;
  22194. }
  22195. }
  22196. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22197. if (isset($this->registeredPlugins[$package->getName()])) {
  22198. return;
  22199. }
  22200. $extra = $package->getExtra();
  22201. if (empty($extra['class'])) {
  22202. throw new \UnexpectedValueException('Error while installing '.$package->getPrettyName().', composer-plugin packages should have a class defined in their extra key to be usable.');
  22203. }
  22204. $classes = is_array($extra['class']) ? $extra['class'] : array($extra['class']);
  22205. $localRepo = $this->composer->getRepositoryManager()->getLocalRepository();
  22206. $globalRepo = $this->globalComposer ? $this->globalComposer->getRepositoryManager()->getLocalRepository() : null;
  22207. $rootPackage = clone $this->composer->getPackage();
  22208. $rootPackageRepo = new RootPackageRepository($rootPackage);
  22209. $installedRepo = new InstalledRepository(array($localRepo, $rootPackageRepo));
  22210. if ($globalRepo) {
  22211. $installedRepo->addRepository($globalRepo);
  22212. }
  22213. $autoloadPackages = array($package->getName() => $package);
  22214. $autoloadPackages = $this->collectDependencies($installedRepo, $autoloadPackages, $package);
  22215. $generator = $this->composer->getAutoloadGenerator();
  22216. $autoloads = array(array($rootPackage, ''));
  22217. foreach ($autoloadPackages as $autoloadPackage) {
  22218. if ($autoloadPackage === $rootPackage) {
  22219. continue;
  22220. }
  22221. $downloadPath = $this->getInstallPath($autoloadPackage, $globalRepo && $globalRepo->hasPackage($autoloadPackage));
  22222. $autoloads[] = array($autoloadPackage, $downloadPath);
  22223. }
  22224. $map = $generator->parseAutoloads($autoloads, $rootPackage);
  22225. $classLoader = $generator->createLoader($map);
  22226. $classLoader->register();
  22227. foreach ($classes as $class) {
  22228. if (class_exists($class, false)) {
  22229. $class = trim($class, '\\');
  22230. $path = $classLoader->findFile($class);
  22231. $code = file_get_contents($path);
  22232. $separatorPos = strrpos($class, '\\');
  22233. $className = $class;
  22234. if ($separatorPos) {
  22235. $className = substr($class, $separatorPos + 1);
  22236. }
  22237. $code = preg_replace('{^((?:final\s+)?(?:\s*))class\s+('.preg_quote($className).')}mi', '$1class $2_composer_tmp'.self::$classCounter, $code, 1);
  22238. $code = strtr($code, array(
  22239. '__FILE__' => var_export($path, true),
  22240. '__DIR__' => var_export(dirname($path), true),
  22241. '__CLASS__' => var_export($class, true),
  22242. ));
  22243. $code = preg_replace('/^\s*<\?(php)?/i', '', $code, 1);
  22244. eval($code);
  22245. $class .= '_composer_tmp'.self::$classCounter;
  22246. self::$classCounter++;
  22247. }
  22248. if ($oldInstallerPlugin) {
  22249. $installer = new $class($this->io, $this->composer);
  22250. $this->composer->getInstallationManager()->addInstaller($installer);
  22251. $this->registeredPlugins[$package->getName()] = $installer;
  22252. } elseif (class_exists($class)) {
  22253. $plugin = new $class();
  22254. $this->addPlugin($plugin, $isGlobalPlugin);
  22255. $this->registeredPlugins[$package->getName()] = $plugin;
  22256. } elseif ($failOnMissingClasses) {
  22257. throw new \UnexpectedValueException('Plugin '.$package->getName().' could not be initialized, class not found: '.$class);
  22258. }
  22259. }
  22260. }
  22261. public function deactivatePackage(PackageInterface $package)
  22262. {
  22263. if ($this->disablePlugins) {
  22264. return;
  22265. }
  22266. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22267. if (!isset($this->registeredPlugins[$package->getName()])) {
  22268. return;
  22269. }
  22270. if ($oldInstallerPlugin) {
  22271. $installer = $this->registeredPlugins[$package->getName()];
  22272. unset($this->registeredPlugins[$package->getName()]);
  22273. $this->composer->getInstallationManager()->removeInstaller($installer);
  22274. } else {
  22275. $plugin = $this->registeredPlugins[$package->getName()];
  22276. unset($this->registeredPlugins[$package->getName()]);
  22277. $this->removePlugin($plugin);
  22278. }
  22279. }
  22280. public function uninstallPackage(PackageInterface $package)
  22281. {
  22282. if ($this->disablePlugins) {
  22283. return;
  22284. }
  22285. $oldInstallerPlugin = ($package->getType() === 'composer-installer');
  22286. if (!isset($this->registeredPlugins[$package->getName()])) {
  22287. return;
  22288. }
  22289. if ($oldInstallerPlugin) {
  22290. $this->deactivatePackage($package);
  22291. } else {
  22292. $plugin = $this->registeredPlugins[$package->getName()];
  22293. unset($this->registeredPlugins[$package->getName()]);
  22294. $this->removePlugin($plugin);
  22295. $this->uninstallPlugin($plugin);
  22296. }
  22297. }
  22298. protected function getPluginApiVersion()
  22299. {
  22300. return PluginInterface::PLUGIN_API_VERSION;
  22301. }
  22302. public function addPlugin(PluginInterface $plugin, $isGlobalPlugin = false)
  22303. {
  22304. $this->io->writeError('Loading plugin '.get_class($plugin).($isGlobalPlugin ? ' (installed globally)' : ''), true, IOInterface::DEBUG);
  22305. $this->plugins[] = $plugin;
  22306. $plugin->activate($this->composer, $this->io);
  22307. if ($plugin instanceof EventSubscriberInterface) {
  22308. $this->composer->getEventDispatcher()->addSubscriber($plugin);
  22309. }
  22310. }
  22311. public function removePlugin(PluginInterface $plugin)
  22312. {
  22313. $index = array_search($plugin, $this->plugins, true);
  22314. if ($index === false) {
  22315. return;
  22316. }
  22317. $this->io->writeError('Unloading plugin '.get_class($plugin), true, IOInterface::DEBUG);
  22318. unset($this->plugins[$index]);
  22319. $plugin->deactivate($this->composer, $this->io);
  22320. $this->composer->getEventDispatcher()->removeListener($plugin);
  22321. }
  22322. public function uninstallPlugin(PluginInterface $plugin)
  22323. {
  22324. $this->io->writeError('Uninstalling plugin '.get_class($plugin), true, IOInterface::DEBUG);
  22325. $plugin->uninstall($this->composer, $this->io);
  22326. }
  22327. private function loadRepository(RepositoryInterface $repo, $isGlobalRepo)
  22328. {
  22329. $packages = $repo->getPackages();
  22330. $sortedPackages = PackageSorter::sortPackages($packages);
  22331. foreach ($sortedPackages as $package) {
  22332. if (!($package instanceof CompletePackage)) {
  22333. continue;
  22334. }
  22335. if ('composer-plugin' === $package->getType()) {
  22336. $this->registerPackage($package, false, $isGlobalRepo);
  22337. } elseif ('composer-installer' === $package->getType()) {
  22338. $this->registerPackage($package, false, $isGlobalRepo);
  22339. }
  22340. }
  22341. }
  22342. private function collectDependencies(InstalledRepository $installedRepo, array $collected, PackageInterface $package)
  22343. {
  22344. $requires = array_merge(
  22345. $package->getRequires(),
  22346. $package->getDevRequires()
  22347. );
  22348. foreach ($requires as $requireLink) {
  22349. foreach ($installedRepo->findPackagesWithReplacersAndProviders($requireLink->getTarget()) as $requiredPackage) {
  22350. if (!isset($collected[$requiredPackage->getName()])) {
  22351. $collected[$requiredPackage->getName()] = $requiredPackage;
  22352. $collected = $this->collectDependencies($installedRepo, $collected, $requiredPackage);
  22353. }
  22354. }
  22355. }
  22356. return $collected;
  22357. }
  22358. private function getInstallPath(PackageInterface $package, $global = false)
  22359. {
  22360. if (!$global) {
  22361. return $this->composer->getInstallationManager()->getInstallPath($package);
  22362. }
  22363. return $this->globalComposer->getInstallationManager()->getInstallPath($package);
  22364. }
  22365. protected function getCapabilityImplementationClassName(PluginInterface $plugin, $capability)
  22366. {
  22367. if (!($plugin instanceof Capable)) {
  22368. return null;
  22369. }
  22370. $capabilities = (array) $plugin->getCapabilities();
  22371. if (!empty($capabilities[$capability]) && is_string($capabilities[$capability]) && trim($capabilities[$capability])) {
  22372. return trim($capabilities[$capability]);
  22373. }
  22374. if (
  22375. array_key_exists($capability, $capabilities)
  22376. && (empty($capabilities[$capability]) || !is_string($capabilities[$capability]) || !trim($capabilities[$capability]))
  22377. ) {
  22378. throw new \UnexpectedValueException('Plugin '.get_class($plugin).' provided invalid capability class name(s), got '.var_export($capabilities[$capability], 1));
  22379. }
  22380. }
  22381. public function getPluginCapability(PluginInterface $plugin, $capabilityClassName, array $ctorArgs = array())
  22382. {
  22383. if ($capabilityClass = $this->getCapabilityImplementationClassName($plugin, $capabilityClassName)) {
  22384. if (!class_exists($capabilityClass)) {
  22385. throw new \RuntimeException("Cannot instantiate Capability, as class $capabilityClass from plugin ".get_class($plugin)." does not exist.");
  22386. }
  22387. $ctorArgs['plugin'] = $plugin;
  22388. $capabilityObj = new $capabilityClass($ctorArgs);
  22389. if (!$capabilityObj instanceof Capability || !$capabilityObj instanceof $capabilityClassName) {
  22390. throw new \RuntimeException(
  22391. 'Class ' . $capabilityClass . ' must implement both Composer\Plugin\Capability\Capability and '. $capabilityClassName . '.'
  22392. );
  22393. }
  22394. return $capabilityObj;
  22395. }
  22396. }
  22397. public function getPluginCapabilities($capabilityClassName, array $ctorArgs = array())
  22398. {
  22399. $capabilities = array();
  22400. foreach ($this->getPlugins() as $plugin) {
  22401. if ($capability = $this->getPluginCapability($plugin, $capabilityClassName, $ctorArgs)) {
  22402. $capabilities[] = $capability;
  22403. }
  22404. }
  22405. return $capabilities;
  22406. }
  22407. }
  22408. <?php
  22409. namespace Composer\Plugin;
  22410. use Composer\EventDispatcher\Event;
  22411. use Composer\Package\PackageInterface;
  22412. class PostFileDownloadEvent extends Event
  22413. {
  22414. private $fileName;
  22415. private $checksum;
  22416. private $url;
  22417. private $package;
  22418. public function __construct($name, $fileName, $checksum, $url, PackageInterface $package)
  22419. {
  22420. parent::__construct($name);
  22421. $this->fileName = $fileName;
  22422. $this->checksum = $checksum;
  22423. $this->url = $url;
  22424. $this->package = $package;
  22425. }
  22426. public function getFileName()
  22427. {
  22428. return $this->fileName;
  22429. }
  22430. public function getChecksum()
  22431. {
  22432. return $this->checksum;
  22433. }
  22434. public function getUrl()
  22435. {
  22436. return $this->url;
  22437. }
  22438. public function getPackage()
  22439. {
  22440. return $this->package;
  22441. }
  22442. }
  22443. <?php
  22444. namespace Composer\Plugin;
  22445. use Composer\EventDispatcher\Event;
  22446. use Symfony\Component\Console\Input\InputInterface;
  22447. class PreCommandRunEvent extends Event
  22448. {
  22449. private $input;
  22450. private $command;
  22451. public function __construct($name, InputInterface $input, $command)
  22452. {
  22453. parent::__construct($name);
  22454. $this->input = $input;
  22455. $this->command = $command;
  22456. }
  22457. public function getInput()
  22458. {
  22459. return $this->input;
  22460. }
  22461. public function getCommand()
  22462. {
  22463. return $this->command;
  22464. }
  22465. }
  22466. <?php
  22467. namespace Composer\Plugin;
  22468. use Composer\EventDispatcher\Event;
  22469. use Composer\Util\HttpDownloader;
  22470. class PreFileDownloadEvent extends Event
  22471. {
  22472. private $httpDownloader;
  22473. private $processedUrl;
  22474. private $customCacheKey;
  22475. private $type;
  22476. private $context;
  22477. public function __construct($name, HttpDownloader $httpDownloader, $processedUrl, $type, $context = null)
  22478. {
  22479. parent::__construct($name);
  22480. $this->httpDownloader = $httpDownloader;
  22481. $this->processedUrl = $processedUrl;
  22482. $this->type = $type;
  22483. $this->context = $context;
  22484. }
  22485. public function getHttpDownloader()
  22486. {
  22487. return $this->httpDownloader;
  22488. }
  22489. public function getProcessedUrl()
  22490. {
  22491. return $this->processedUrl;
  22492. }
  22493. public function setProcessedUrl($processedUrl)
  22494. {
  22495. $this->processedUrl = $processedUrl;
  22496. }
  22497. public function getCustomCacheKey()
  22498. {
  22499. return $this->customCacheKey;
  22500. }
  22501. public function setCustomCacheKey($customCacheKey)
  22502. {
  22503. $this->customCacheKey = $customCacheKey;
  22504. }
  22505. public function getType()
  22506. {
  22507. return $this->type;
  22508. }
  22509. public function getContext()
  22510. {
  22511. return $this->context;
  22512. }
  22513. }
  22514. <?php
  22515. namespace Composer\Plugin;
  22516. use Composer\EventDispatcher\Event;
  22517. use Composer\Repository\RepositoryInterface;
  22518. use Composer\DependencyResolver\Request;
  22519. use Composer\Package\PackageInterface;
  22520. class PrePoolCreateEvent extends Event
  22521. {
  22522. private $repositories;
  22523. private $request;
  22524. private $acceptableStabilities;
  22525. private $stabilityFlags;
  22526. private $rootAliases;
  22527. private $rootReferences;
  22528. private $packages;
  22529. private $unacceptableFixedPackages;
  22530. public function __construct($name, array $repositories, Request $request, array $acceptableStabilities, array $stabilityFlags, array $rootAliases, array $rootReferences, array $packages, array $unacceptableFixedPackages)
  22531. {
  22532. parent::__construct($name);
  22533. $this->repositories = $repositories;
  22534. $this->request = $request;
  22535. $this->acceptableStabilities = $acceptableStabilities;
  22536. $this->stabilityFlags = $stabilityFlags;
  22537. $this->rootAliases = $rootAliases;
  22538. $this->rootReferences = $rootReferences;
  22539. $this->packages = $packages;
  22540. $this->unacceptableFixedPackages = $unacceptableFixedPackages;
  22541. }
  22542. public function getRepositories()
  22543. {
  22544. return $this->repositories;
  22545. }
  22546. public function getRequest()
  22547. {
  22548. return $this->request;
  22549. }
  22550. public function getAcceptableStabilities()
  22551. {
  22552. return $this->acceptableStabilities;
  22553. }
  22554. public function getStabilityFlags()
  22555. {
  22556. return $this->stabilityFlags;
  22557. }
  22558. public function getRootAliases()
  22559. {
  22560. return $this->rootAliases;
  22561. }
  22562. public function getRootReferences()
  22563. {
  22564. return $this->rootReferences;
  22565. }
  22566. public function getPackages()
  22567. {
  22568. return $this->packages;
  22569. }
  22570. public function getUnacceptableFixedPackages()
  22571. {
  22572. return $this->unacceptableFixedPackages;
  22573. }
  22574. public function setPackages(array $packages)
  22575. {
  22576. $this->packages = $packages;
  22577. }
  22578. public function setUnacceptableFixedPackages(array $packages)
  22579. {
  22580. $this->unacceptableFixedPackages = $packages;
  22581. }
  22582. }
  22583. <?php
  22584. namespace Composer\Question;
  22585. use Symfony\Component\Console\Exception\InvalidArgumentException;
  22586. use Symfony\Component\Console\Question\Question;
  22587. class StrictConfirmationQuestion extends Question
  22588. {
  22589. private $trueAnswerRegex;
  22590. private $falseAnswerRegex;
  22591. public function __construct($question, $default = true, $trueAnswerRegex = '/^y(?:es)?$/i', $falseAnswerRegex = '/^no?$/i')
  22592. {
  22593. parent::__construct($question, (bool) $default);
  22594. $this->trueAnswerRegex = $trueAnswerRegex;
  22595. $this->falseAnswerRegex = $falseAnswerRegex;
  22596. $this->setNormalizer($this->getDefaultNormalizer());
  22597. $this->setValidator($this->getDefaultValidator());
  22598. }
  22599. private function getDefaultNormalizer()
  22600. {
  22601. $default = $this->getDefault();
  22602. $trueRegex = $this->trueAnswerRegex;
  22603. $falseRegex = $this->falseAnswerRegex;
  22604. return function ($answer) use ($default, $trueRegex, $falseRegex) {
  22605. if (is_bool($answer)) {
  22606. return $answer;
  22607. }
  22608. if (empty($answer) && !empty($default)) {
  22609. return $default;
  22610. }
  22611. if (preg_match($trueRegex, $answer)) {
  22612. return true;
  22613. }
  22614. if (preg_match($falseRegex, $answer)) {
  22615. return false;
  22616. }
  22617. return null;
  22618. };
  22619. }
  22620. private function getDefaultValidator()
  22621. {
  22622. return function ($answer) {
  22623. if (!is_bool($answer)) {
  22624. throw new InvalidArgumentException('Please answer yes, y, no, or n.');
  22625. }
  22626. return $answer;
  22627. };
  22628. }
  22629. }
  22630. <?php
  22631. namespace Composer\Repository;
  22632. use Composer\Package\AliasPackage;
  22633. use Composer\Package\PackageInterface;
  22634. use Composer\Package\CompletePackageInterface;
  22635. use Composer\Package\Version\VersionParser;
  22636. use Composer\Package\Version\StabilityFilter;
  22637. use Composer\Semver\Constraint\ConstraintInterface;
  22638. use Composer\Semver\Constraint\Constraint;
  22639. class ArrayRepository implements RepositoryInterface
  22640. {
  22641. protected $packages;
  22642. protected $packageMap;
  22643. public function __construct(array $packages = array())
  22644. {
  22645. foreach ($packages as $package) {
  22646. $this->addPackage($package);
  22647. }
  22648. }
  22649. public function getRepoName()
  22650. {
  22651. return 'array repo (defining '.$this->count().' package'.($this->count() > 1 ? 's' : '').')';
  22652. }
  22653. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  22654. {
  22655. $packages = $this->getPackages();
  22656. $result = array();
  22657. $namesFound = array();
  22658. foreach ($packages as $package) {
  22659. if (array_key_exists($package->getName(), $packageMap)) {
  22660. if (
  22661. (!$packageMap[$package->getName()] || $packageMap[$package->getName()]->matches(new Constraint('==', $package->getVersion())))
  22662. && StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, $package->getNames(), $package->getStability())
  22663. && !isset($alreadyLoaded[$package->getName()][$package->getVersion()])
  22664. ) {
  22665. $result[spl_object_hash($package)] = $package;
  22666. if ($package instanceof AliasPackage && !isset($result[spl_object_hash($package->getAliasOf())])) {
  22667. $result[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  22668. }
  22669. }
  22670. $namesFound[$package->getName()] = true;
  22671. }
  22672. }
  22673. foreach ($packages as $package) {
  22674. if ($package instanceof AliasPackage) {
  22675. if (isset($result[spl_object_hash($package->getAliasOf())])) {
  22676. $result[spl_object_hash($package)] = $package;
  22677. }
  22678. }
  22679. }
  22680. return array('namesFound' => array_keys($namesFound), 'packages' => $result);
  22681. }
  22682. public function findPackage($name, $constraint)
  22683. {
  22684. $name = strtolower($name);
  22685. if (!$constraint instanceof ConstraintInterface) {
  22686. $versionParser = new VersionParser();
  22687. $constraint = $versionParser->parseConstraints($constraint);
  22688. }
  22689. foreach ($this->getPackages() as $package) {
  22690. if ($name === $package->getName()) {
  22691. $pkgConstraint = new Constraint('==', $package->getVersion());
  22692. if ($constraint->matches($pkgConstraint)) {
  22693. return $package;
  22694. }
  22695. }
  22696. }
  22697. return null;
  22698. }
  22699. public function findPackages($name, $constraint = null)
  22700. {
  22701. $name = strtolower($name);
  22702. $packages = array();
  22703. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  22704. $versionParser = new VersionParser();
  22705. $constraint = $versionParser->parseConstraints($constraint);
  22706. }
  22707. foreach ($this->getPackages() as $package) {
  22708. if ($name === $package->getName()) {
  22709. if (null === $constraint || $constraint->matches(new Constraint('==', $package->getVersion()))) {
  22710. $packages[] = $package;
  22711. }
  22712. }
  22713. }
  22714. return $packages;
  22715. }
  22716. public function search($query, $mode = 0, $type = null)
  22717. {
  22718. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  22719. $matches = array();
  22720. foreach ($this->getPackages() as $package) {
  22721. $name = $package->getName();
  22722. if (isset($matches[$name])) {
  22723. continue;
  22724. }
  22725. if (preg_match($regex, $name)
  22726. || ($mode === self::SEARCH_FULLTEXT && $package instanceof CompletePackageInterface && preg_match($regex, implode(' ', (array) $package->getKeywords()) . ' ' . $package->getDescription()))
  22727. ) {
  22728. if (null !== $type && $package->getType() !== $type) {
  22729. continue;
  22730. }
  22731. $matches[$name] = array(
  22732. 'name' => $package->getPrettyName(),
  22733. 'description' => $package instanceof CompletePackageInterface ? $package->getDescription() : null,
  22734. );
  22735. }
  22736. }
  22737. return array_values($matches);
  22738. }
  22739. public function hasPackage(PackageInterface $package)
  22740. {
  22741. if ($this->packageMap === null) {
  22742. $this->packageMap = array();
  22743. foreach ($this->getPackages() as $repoPackage) {
  22744. $this->packageMap[$repoPackage->getUniqueName()] = $repoPackage;
  22745. }
  22746. }
  22747. return isset($this->packageMap[$package->getUniqueName()]);
  22748. }
  22749. public function addPackage(PackageInterface $package)
  22750. {
  22751. if (null === $this->packages) {
  22752. $this->initialize();
  22753. }
  22754. $package->setRepository($this);
  22755. $this->packages[] = $package;
  22756. if ($package instanceof AliasPackage) {
  22757. $aliasedPackage = $package->getAliasOf();
  22758. if (null === $aliasedPackage->getRepository()) {
  22759. $this->addPackage($aliasedPackage);
  22760. }
  22761. }
  22762. $this->packageMap = null;
  22763. }
  22764. public function getProviders($packageName)
  22765. {
  22766. $result = array();
  22767. foreach ($this->getPackages() as $candidate) {
  22768. if (isset($result[$candidate->getName()])) {
  22769. continue;
  22770. }
  22771. foreach ($candidate->getProvides() as $link) {
  22772. if ($packageName === $link->getTarget()) {
  22773. $result[$candidate->getName()] = array(
  22774. 'name' => $candidate->getName(),
  22775. 'description' => $candidate->getDescription(),
  22776. 'type' => $candidate->getType(),
  22777. );
  22778. continue 2;
  22779. }
  22780. }
  22781. }
  22782. return $result;
  22783. }
  22784. protected function createAliasPackage(PackageInterface $package, $alias, $prettyAlias)
  22785. {
  22786. return new AliasPackage($package instanceof AliasPackage ? $package->getAliasOf() : $package, $alias, $prettyAlias);
  22787. }
  22788. public function removePackage(PackageInterface $package)
  22789. {
  22790. $packageId = $package->getUniqueName();
  22791. foreach ($this->getPackages() as $key => $repoPackage) {
  22792. if ($packageId === $repoPackage->getUniqueName()) {
  22793. array_splice($this->packages, $key, 1);
  22794. $this->packageMap = null;
  22795. return;
  22796. }
  22797. }
  22798. }
  22799. public function getPackages()
  22800. {
  22801. if (null === $this->packages) {
  22802. $this->initialize();
  22803. }
  22804. return $this->packages;
  22805. }
  22806. public function count()
  22807. {
  22808. if (null === $this->packages) {
  22809. $this->initialize();
  22810. }
  22811. return count($this->packages);
  22812. }
  22813. protected function initialize()
  22814. {
  22815. $this->packages = array();
  22816. }
  22817. }
  22818. <?php
  22819. namespace Composer\Repository;
  22820. use Composer\IO\IOInterface;
  22821. use Composer\Json\JsonFile;
  22822. use Composer\Package\Loader\ArrayLoader;
  22823. use Composer\Package\Loader\LoaderInterface;
  22824. use Composer\Util\Tar;
  22825. use Composer\Util\Zip;
  22826. class ArtifactRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  22827. {
  22828. protected $loader;
  22829. protected $lookup;
  22830. protected $repoConfig;
  22831. private $io;
  22832. public function __construct(array $repoConfig, IOInterface $io)
  22833. {
  22834. parent::__construct();
  22835. if (!extension_loaded('zip')) {
  22836. throw new \RuntimeException('The artifact repository requires PHP\'s zip extension');
  22837. }
  22838. $this->loader = new ArrayLoader();
  22839. $this->lookup = $repoConfig['url'];
  22840. $this->io = $io;
  22841. $this->repoConfig = $repoConfig;
  22842. }
  22843. public function getRepoName()
  22844. {
  22845. return 'artifact repo ('.$this->lookup.')';
  22846. }
  22847. public function getRepoConfig()
  22848. {
  22849. return $this->repoConfig;
  22850. }
  22851. protected function initialize()
  22852. {
  22853. parent::initialize();
  22854. $this->scanDirectory($this->lookup);
  22855. }
  22856. private function scanDirectory($path)
  22857. {
  22858. $io = $this->io;
  22859. $directory = new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
  22860. $iterator = new \RecursiveIteratorIterator($directory);
  22861. $regex = new \RegexIterator($iterator, '/^.+\.(zip|phar|tar|gz|tgz)$/i');
  22862. foreach ($regex as $file) {
  22863. if (!$file->isFile()) {
  22864. continue;
  22865. }
  22866. $package = $this->getComposerInformation($file);
  22867. if (!$package) {
  22868. $io->writeError("File <comment>{$file->getBasename()}</comment> doesn't seem to hold a package", true, IOInterface::VERBOSE);
  22869. continue;
  22870. }
  22871. $template = 'Found package <info>%s</info> (<comment>%s</comment>) in file <info>%s</info>';
  22872. $io->writeError(sprintf($template, $package->getName(), $package->getPrettyVersion(), $file->getBasename()), true, IOInterface::VERBOSE);
  22873. $this->addPackage($package);
  22874. }
  22875. }
  22876. private function getComposerInformation(\SplFileInfo $file)
  22877. {
  22878. $json = null;
  22879. $fileType = null;
  22880. $fileExtension = pathinfo($file->getPathname(), PATHINFO_EXTENSION);
  22881. if (in_array($fileExtension, array('gz', 'tar', 'tgz'), true)) {
  22882. $fileType = 'tar';
  22883. } elseif ($fileExtension === 'zip') {
  22884. $fileType = 'zip';
  22885. } else {
  22886. throw new \RuntimeException('Files with "'.$fileExtension.'" extensions aren\'t supported. Only ZIP and TAR/TAR.GZ/TGZ archives are supported.');
  22887. }
  22888. try {
  22889. if ($fileType === 'tar') {
  22890. $json = Tar::getComposerJson($file->getPathname());
  22891. } else {
  22892. $json = Zip::getComposerJson($file->getPathname());
  22893. }
  22894. } catch (\Exception $exception) {
  22895. $this->io->write('Failed loading package '.$file->getPathname().': '.$exception->getMessage(), false, IOInterface::VERBOSE);
  22896. }
  22897. if (null === $json) {
  22898. return false;
  22899. }
  22900. $package = JsonFile::parseJson($json, $file->getPathname().'#composer.json');
  22901. $package['dist'] = array(
  22902. 'type' => $fileType,
  22903. 'url' => strtr($file->getPathname(), '\\', '/'),
  22904. 'shasum' => sha1_file($file->getRealPath()),
  22905. );
  22906. try {
  22907. $package = $this->loader->load($package);
  22908. } catch (\UnexpectedValueException $e) {
  22909. throw new \UnexpectedValueException('Failed loading package in '.$file.': '.$e->getMessage(), 0, $e);
  22910. }
  22911. return $package;
  22912. }
  22913. }
  22914. <?php
  22915. namespace Composer\Repository;
  22916. use Composer\Package\BasePackage;
  22917. use Composer\Package\Loader\ArrayLoader;
  22918. use Composer\Package\PackageInterface;
  22919. use Composer\Package\AliasPackage;
  22920. use Composer\Package\Version\VersionParser;
  22921. use Composer\Package\Version\StabilityFilter;
  22922. use Composer\Json\JsonFile;
  22923. use Composer\Cache;
  22924. use Composer\Config;
  22925. use Composer\IO\IOInterface;
  22926. use Composer\Semver\CompilingMatcher;
  22927. use Composer\Util\HttpDownloader;
  22928. use Composer\Util\Loop;
  22929. use Composer\Plugin\PluginEvents;
  22930. use Composer\Plugin\PreFileDownloadEvent;
  22931. use Composer\EventDispatcher\EventDispatcher;
  22932. use Composer\Downloader\TransportException;
  22933. use Composer\Semver\Constraint\ConstraintInterface;
  22934. use Composer\Semver\Constraint\Constraint;
  22935. use Composer\Semver\Constraint\MatchAllConstraint;
  22936. use Composer\Util\Http\Response;
  22937. use Composer\Util\MetadataMinifier;
  22938. use Composer\Util\Url;
  22939. class ComposerRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  22940. {
  22941. private $repoConfig;
  22942. private $options;
  22943. private $url;
  22944. private $baseUrl;
  22945. private $io;
  22946. private $httpDownloader;
  22947. private $loop;
  22948. protected $cache;
  22949. protected $notifyUrl;
  22950. protected $searchUrl;
  22951. protected $providersApiUrl;
  22952. protected $hasProviders = false;
  22953. protected $providersUrl;
  22954. protected $listUrl;
  22955. protected $hasAvailablePackageList = false;
  22956. protected $availablePackages;
  22957. protected $availablePackagePatterns;
  22958. protected $lazyProvidersUrl;
  22959. protected $providerListing;
  22960. protected $loader;
  22961. private $allowSslDowngrade = false;
  22962. private $eventDispatcher;
  22963. private $sourceMirrors;
  22964. private $distMirrors;
  22965. private $degradedMode = false;
  22966. private $rootData;
  22967. private $hasPartialPackages;
  22968. private $partialPackagesByName;
  22969. public $freshMetadataUrls = array();
  22970. public $packagesNotFoundCache = array();
  22971. public $versionParser;
  22972. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null)
  22973. {
  22974. parent::__construct();
  22975. if (!preg_match('{^[\w.]+\??://}', $repoConfig['url'])) {
  22976. $repoConfig['url'] = 'http://'.$repoConfig['url'];
  22977. }
  22978. $repoConfig['url'] = rtrim($repoConfig['url'], '/');
  22979. if (strpos($repoConfig['url'], 'https?') === 0) {
  22980. $repoConfig['url'] = (extension_loaded('openssl') ? 'https' : 'http') . substr($repoConfig['url'], 6);
  22981. }
  22982. $urlBits = parse_url($repoConfig['url']);
  22983. if ($urlBits === false || empty($urlBits['scheme'])) {
  22984. throw new \UnexpectedValueException('Invalid url given for Composer repository: '.$repoConfig['url']);
  22985. }
  22986. if (!isset($repoConfig['options'])) {
  22987. $repoConfig['options'] = array();
  22988. }
  22989. if (isset($repoConfig['allow_ssl_downgrade']) && true === $repoConfig['allow_ssl_downgrade']) {
  22990. $this->allowSslDowngrade = true;
  22991. }
  22992. $this->options = $repoConfig['options'];
  22993. $this->url = $repoConfig['url'];
  22994. if (preg_match('{^(?P<proto>https?)://packagist\.org/?$}i', $this->url, $match)) {
  22995. $this->url = $match['proto'].'://repo.packagist.org';
  22996. }
  22997. $this->baseUrl = rtrim(preg_replace('{(?:/[^/\\\\]+\.json)?(?:[?#].*)?$}', '', $this->url), '/');
  22998. $this->io = $io;
  22999. $this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->url)), 'a-z0-9.$~');
  23000. $this->cache->setReadOnly($config->get('cache-read-only'));
  23001. $this->versionParser = new VersionParser();
  23002. $this->loader = new ArrayLoader($this->versionParser);
  23003. $this->httpDownloader = $httpDownloader;
  23004. $this->eventDispatcher = $eventDispatcher;
  23005. $this->repoConfig = $repoConfig;
  23006. $this->loop = new Loop($this->httpDownloader);
  23007. }
  23008. public function getRepoName()
  23009. {
  23010. return 'composer repo ('.Url::sanitize($this->url).')';
  23011. }
  23012. public function getRepoConfig()
  23013. {
  23014. return $this->repoConfig;
  23015. }
  23016. public function findPackage($name, $constraint)
  23017. {
  23018. $hasProviders = $this->hasProviders();
  23019. $name = strtolower($name);
  23020. if (!$constraint instanceof ConstraintInterface) {
  23021. $constraint = $this->versionParser->parseConstraints($constraint);
  23022. }
  23023. if ($this->lazyProvidersUrl) {
  23024. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  23025. return $this->filterPackages($this->whatProvides($name), $constraint, true);
  23026. }
  23027. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  23028. return;
  23029. }
  23030. $packages = $this->loadAsyncPackages(array($name => $constraint));
  23031. return reset($packages['packages']);
  23032. }
  23033. if ($hasProviders) {
  23034. foreach ($this->getProviderNames() as $providerName) {
  23035. if ($name === $providerName) {
  23036. return $this->filterPackages($this->whatProvides($providerName), $constraint, true);
  23037. }
  23038. }
  23039. return;
  23040. }
  23041. return parent::findPackage($name, $constraint);
  23042. }
  23043. public function findPackages($name, $constraint = null)
  23044. {
  23045. $hasProviders = $this->hasProviders();
  23046. $name = strtolower($name);
  23047. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  23048. $constraint = $this->versionParser->parseConstraints($constraint);
  23049. }
  23050. if ($this->lazyProvidersUrl) {
  23051. if ($this->hasPartialPackages() && isset($this->partialPackagesByName[$name])) {
  23052. return $this->filterPackages($this->whatProvides($name), $constraint);
  23053. }
  23054. if ($this->hasAvailablePackageList && !$this->lazyProvidersRepoContains($name)) {
  23055. return array();
  23056. }
  23057. $result = $this->loadAsyncPackages(array($name => $constraint));
  23058. return $result['packages'];
  23059. }
  23060. if ($hasProviders) {
  23061. foreach ($this->getProviderNames() as $providerName) {
  23062. if ($name === $providerName) {
  23063. return $this->filterPackages($this->whatProvides($providerName), $constraint);
  23064. }
  23065. }
  23066. return array();
  23067. }
  23068. return parent::findPackages($name, $constraint);
  23069. }
  23070. private function filterPackages(array $packages, $constraint = null, $returnFirstMatch = false)
  23071. {
  23072. if (null === $constraint) {
  23073. if ($returnFirstMatch) {
  23074. return reset($packages);
  23075. }
  23076. return $packages;
  23077. }
  23078. $filteredPackages = array();
  23079. foreach ($packages as $package) {
  23080. $pkgConstraint = new Constraint('==', $package->getVersion());
  23081. if ($constraint->matches($pkgConstraint)) {
  23082. if ($returnFirstMatch) {
  23083. return $package;
  23084. }
  23085. $filteredPackages[] = $package;
  23086. }
  23087. }
  23088. if ($returnFirstMatch) {
  23089. return null;
  23090. }
  23091. return $filteredPackages;
  23092. }
  23093. public function getPackages()
  23094. {
  23095. $hasProviders = $this->hasProviders();
  23096. if ($this->lazyProvidersUrl) {
  23097. if (is_array($this->availablePackages) && !$this->availablePackagePatterns) {
  23098. $packageMap = array();
  23099. foreach ($this->availablePackages as $name) {
  23100. $packageMap[$name] = new MatchAllConstraint();
  23101. }
  23102. $result = $this->loadAsyncPackages($packageMap);
  23103. return array_values($result['packages']);
  23104. }
  23105. if ($this->hasPartialPackages()) {
  23106. return array_values($this->partialPackagesByName);
  23107. }
  23108. 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.');
  23109. }
  23110. if ($hasProviders) {
  23111. throw new \LogicException('Composer repositories that have providers can not load the complete list of packages, use getPackageNames instead.');
  23112. }
  23113. return parent::getPackages();
  23114. }
  23115. public function getPackageNames($packageFilter = null)
  23116. {
  23117. $hasProviders = $this->hasProviders();
  23118. $packageFilterCb = function ($name) {
  23119. return true;
  23120. };
  23121. if (null !== $packageFilter) {
  23122. $packageFilterRegex = '{^'.str_replace('\\*', '.*?', preg_quote($packageFilter)).'$}i';
  23123. $packageFilterCb = function ($name) use ($packageFilterRegex) {
  23124. return (bool) preg_match($packageFilterRegex, $name);
  23125. };
  23126. }
  23127. if ($this->lazyProvidersUrl) {
  23128. if (is_array($this->availablePackages)) {
  23129. return array_filter(array_keys($this->availablePackages), $packageFilterCb);
  23130. }
  23131. if ($this->listUrl) {
  23132. $url = $this->listUrl;
  23133. if ($packageFilter) {
  23134. $url .= '?filter='.urlencode($packageFilter);
  23135. }
  23136. $result = $this->httpDownloader->get($url, $this->options)->decodeJson();
  23137. return $result['packageNames'];
  23138. }
  23139. if ($this->hasPartialPackages()) {
  23140. return array_filter(array_keys($this->partialPackagesByName), $packageFilterCb);
  23141. }
  23142. return array();
  23143. }
  23144. if ($hasProviders) {
  23145. return array_filter($this->getProviderNames(), $packageFilterCb);
  23146. }
  23147. $names = array();
  23148. foreach ($this->getPackages() as $package) {
  23149. if ($packageFilterCb($package->getName())) {
  23150. $names[] = $package->getPrettyName();
  23151. }
  23152. }
  23153. return $names;
  23154. }
  23155. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  23156. {
  23157. $hasProviders = $this->hasProviders();
  23158. if (!$hasProviders && !$this->hasPartialPackages() && !$this->lazyProvidersUrl) {
  23159. return parent::loadPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23160. }
  23161. $packages = array();
  23162. $namesFound = array();
  23163. if ($hasProviders || $this->hasPartialPackages()) {
  23164. foreach ($packageNameMap as $name => $constraint) {
  23165. $matches = array();
  23166. if (!$hasProviders && !isset($this->partialPackagesByName[$name])) {
  23167. continue;
  23168. }
  23169. $candidates = $this->whatProvides($name, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23170. foreach ($candidates as $candidate) {
  23171. if ($candidate->getName() !== $name) {
  23172. throw new \LogicException('whatProvides should never return a package with a different name than the requested one');
  23173. }
  23174. $namesFound[$name] = true;
  23175. if (!$constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  23176. $matches[spl_object_hash($candidate)] = $candidate;
  23177. if ($candidate instanceof AliasPackage && !isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  23178. $matches[spl_object_hash($candidate->getAliasOf())] = $candidate->getAliasOf();
  23179. }
  23180. }
  23181. }
  23182. foreach ($candidates as $candidate) {
  23183. if ($candidate instanceof AliasPackage) {
  23184. if (isset($matches[spl_object_hash($candidate->getAliasOf())])) {
  23185. $matches[spl_object_hash($candidate)] = $candidate;
  23186. }
  23187. }
  23188. }
  23189. $packages = array_merge($packages, $matches);
  23190. unset($packageNameMap[$name]);
  23191. }
  23192. }
  23193. if ($this->lazyProvidersUrl && count($packageNameMap)) {
  23194. if ($this->hasAvailablePackageList) {
  23195. foreach ($packageNameMap as $name => $constraint) {
  23196. if (!$this->lazyProvidersRepoContains(strtolower($name))) {
  23197. unset($packageNameMap[$name]);
  23198. }
  23199. }
  23200. }
  23201. $result = $this->loadAsyncPackages($packageNameMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23202. $packages = array_merge($packages, $result['packages']);
  23203. $namesFound = array_merge($namesFound, $result['namesFound']);
  23204. }
  23205. return array('namesFound' => array_keys($namesFound), 'packages' => $packages);
  23206. }
  23207. public function search($query, $mode = 0, $type = null)
  23208. {
  23209. $this->loadRootServerFile();
  23210. if ($this->searchUrl && $mode === self::SEARCH_FULLTEXT) {
  23211. $url = str_replace(array('%query%', '%type%'), array($query, $type), $this->searchUrl);
  23212. $search = $this->httpDownloader->get($url, $this->options)->decodeJson();
  23213. if (empty($search['results'])) {
  23214. return array();
  23215. }
  23216. $results = array();
  23217. foreach ($search['results'] as $result) {
  23218. if (empty($result['virtual'])) {
  23219. $results[] = $result;
  23220. }
  23221. }
  23222. return $results;
  23223. }
  23224. if ($this->hasProviders() || $this->lazyProvidersUrl) {
  23225. $results = array();
  23226. $regex = '{(?:'.implode('|', preg_split('{\s+}', $query)).')}i';
  23227. foreach ($this->getPackageNames() as $name) {
  23228. if (preg_match($regex, $name)) {
  23229. $results[] = array('name' => $name);
  23230. }
  23231. }
  23232. return $results;
  23233. }
  23234. return parent::search($query, $mode);
  23235. }
  23236. public function getProviders($packageName)
  23237. {
  23238. $this->loadRootServerFile();
  23239. $result = array();
  23240. if ($this->providersApiUrl) {
  23241. $apiResult = $this->httpDownloader->get(str_replace('%package%', $packageName, $this->providersApiUrl), $this->options)->decodeJson();
  23242. foreach ($apiResult['providers'] as $provider) {
  23243. $result[$provider['name']] = $provider;
  23244. }
  23245. return $result;
  23246. }
  23247. if ($this->hasPartialPackages()) {
  23248. foreach ($this->partialPackagesByName as $versions) {
  23249. foreach ($versions as $candidate) {
  23250. if (isset($result[$candidate['name']]) || !isset($candidate['provide'][$packageName])) {
  23251. continue;
  23252. }
  23253. $result[$candidate['name']] = array(
  23254. 'name' => $candidate['name'],
  23255. 'description' => isset($candidate['description']) ? $candidate['description'] : '',
  23256. 'type' => isset($candidate['type']) ? $candidate['type'] : '',
  23257. );
  23258. }
  23259. }
  23260. }
  23261. if ($this->packages) {
  23262. $result = array_merge($result, parent::getProviders($packageName));
  23263. }
  23264. return $result;
  23265. }
  23266. private function getProviderNames()
  23267. {
  23268. $this->loadRootServerFile();
  23269. if (null === $this->providerListing) {
  23270. $this->loadProviderListings($this->loadRootServerFile());
  23271. }
  23272. if ($this->lazyProvidersUrl) {
  23273. return array();
  23274. }
  23275. if ($this->providersUrl) {
  23276. return array_keys($this->providerListing);
  23277. }
  23278. return array();
  23279. }
  23280. private function configurePackageTransportOptions(PackageInterface $package)
  23281. {
  23282. foreach ($package->getDistUrls() as $url) {
  23283. if (strpos($url, $this->baseUrl) === 0) {
  23284. $package->setTransportOptions($this->options);
  23285. return;
  23286. }
  23287. }
  23288. }
  23289. private function hasProviders()
  23290. {
  23291. $this->loadRootServerFile();
  23292. return $this->hasProviders;
  23293. }
  23294. private function whatProvides($name, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  23295. {
  23296. if (!$this->hasPartialPackages() || !isset($this->partialPackagesByName[$name])) {
  23297. if (PlatformRepository::isPlatformPackage($name) || '__root__' === $name) {
  23298. return array();
  23299. }
  23300. if (null === $this->providerListing) {
  23301. $this->loadProviderListings($this->loadRootServerFile());
  23302. }
  23303. $useLastModifiedCheck = false;
  23304. if ($this->lazyProvidersUrl && !isset($this->providerListing[$name])) {
  23305. $hash = null;
  23306. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  23307. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  23308. $useLastModifiedCheck = true;
  23309. } elseif ($this->providersUrl) {
  23310. if (!isset($this->providerListing[$name])) {
  23311. return array();
  23312. }
  23313. $hash = $this->providerListing[$name]['sha256'];
  23314. $url = str_replace(array('%package%', '%hash%'), array($name, $hash), $this->providersUrl);
  23315. $cacheKey = 'provider-'.strtr($name, '/', '$').'.json';
  23316. } else {
  23317. return array();
  23318. }
  23319. $packages = null;
  23320. if ($cacheKey) {
  23321. if (!$useLastModifiedCheck && $hash && $this->cache->sha256($cacheKey) === $hash) {
  23322. $packages = json_decode($this->cache->read($cacheKey), true);
  23323. } elseif ($useLastModifiedCheck) {
  23324. if ($contents = $this->cache->read($cacheKey)) {
  23325. $contents = json_decode($contents, true);
  23326. if (isset($alreadyLoaded[$name])) {
  23327. $packages = $contents;
  23328. } elseif (isset($contents['last-modified'])) {
  23329. $response = $this->fetchFileIfLastModified($url, $cacheKey, $contents['last-modified']);
  23330. $packages = true === $response ? $contents : $response;
  23331. }
  23332. }
  23333. }
  23334. }
  23335. if (!$packages) {
  23336. try {
  23337. $packages = $this->fetchFile($url, $cacheKey, $hash, $useLastModifiedCheck);
  23338. } catch (TransportException $e) {
  23339. if ($this->lazyProvidersUrl && in_array($e->getStatusCode(), array(404, 499), true)) {
  23340. $packages = array('packages' => array());
  23341. if ($e->getStatusCode() === 499) {
  23342. $this->io->error('<warning>' . $e->getMessage() . '</warning>');
  23343. }
  23344. } else {
  23345. throw $e;
  23346. }
  23347. }
  23348. }
  23349. $loadingPartialPackage = false;
  23350. } else {
  23351. $packages = array('packages' => array('versions' => $this->partialPackagesByName[$name]));
  23352. $loadingPartialPackage = true;
  23353. }
  23354. $result = array();
  23355. $versionsToLoad = array();
  23356. foreach ($packages['packages'] as $versions) {
  23357. foreach ($versions as $version) {
  23358. $normalizedName = strtolower($version['name']);
  23359. if ($normalizedName !== $name) {
  23360. continue;
  23361. }
  23362. if (!$loadingPartialPackage && $this->hasPartialPackages() && isset($this->partialPackagesByName[$normalizedName])) {
  23363. continue;
  23364. }
  23365. if (!isset($versionsToLoad[$version['uid']])) {
  23366. if (!isset($version['version_normalized'])) {
  23367. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  23368. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23369. $version['version_normalized'] = $this->versionParser->normalize($version['version']);
  23370. }
  23371. if (isset($alreadyLoaded[$name][$version['version_normalized']])) {
  23372. continue;
  23373. }
  23374. if ($this->isVersionAcceptable(null, $normalizedName, $version, $acceptableStabilities, $stabilityFlags)) {
  23375. $versionsToLoad[$version['uid']] = $version;
  23376. }
  23377. }
  23378. }
  23379. }
  23380. $loadedPackages = $this->createPackages($versionsToLoad);
  23381. $uids = array_keys($versionsToLoad);
  23382. foreach ($loadedPackages as $index => $package) {
  23383. $package->setRepository($this);
  23384. $uid = $uids[$index];
  23385. if ($package instanceof AliasPackage) {
  23386. $aliased = $package->getAliasOf();
  23387. $aliased->setRepository($this);
  23388. $result[$uid] = $aliased;
  23389. $result[$uid.'-alias'] = $package;
  23390. } else {
  23391. $result[$uid] = $package;
  23392. }
  23393. }
  23394. return $result;
  23395. }
  23396. protected function initialize()
  23397. {
  23398. parent::initialize();
  23399. $repoData = $this->loadDataFromServer();
  23400. foreach ($this->createPackages($repoData) as $package) {
  23401. $this->addPackage($package);
  23402. }
  23403. }
  23404. public function addPackage(PackageInterface $package)
  23405. {
  23406. parent::addPackage($package);
  23407. $this->configurePackageTransportOptions($package);
  23408. }
  23409. private function loadAsyncPackages(array $packageNames, array $acceptableStabilities = null, array $stabilityFlags = null, array $alreadyLoaded = array())
  23410. {
  23411. $this->loadRootServerFile();
  23412. $packages = array();
  23413. $namesFound = array();
  23414. $promises = array();
  23415. $repo = $this;
  23416. if (!$this->lazyProvidersUrl) {
  23417. throw new \LogicException('loadAsyncPackages only supports v2 protocol composer repos with a metadata-url');
  23418. }
  23419. foreach ($packageNames as $name => $constraint) {
  23420. if ($acceptableStabilities === null || $stabilityFlags === null || StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), 'dev')) {
  23421. $packageNames[$name.'~dev'] = $constraint;
  23422. }
  23423. if (isset($acceptableStabilities['dev']) && count($acceptableStabilities) === 1 && count($stabilityFlags) === 0) {
  23424. unset($packageNames[$name]);
  23425. }
  23426. }
  23427. foreach ($packageNames as $name => $constraint) {
  23428. $name = strtolower($name);
  23429. $realName = preg_replace('{~dev$}', '', $name);
  23430. if (PlatformRepository::isPlatformPackage($realName) || '__root__' === $realName) {
  23431. continue;
  23432. }
  23433. $url = str_replace('%package%', $name, $this->lazyProvidersUrl);
  23434. $cacheKey = 'provider-'.strtr($name, '/', '~').'.json';
  23435. $lastModified = null;
  23436. if ($contents = $this->cache->read($cacheKey)) {
  23437. $contents = json_decode($contents, true);
  23438. $lastModified = isset($contents['last-modified']) ? $contents['last-modified'] : null;
  23439. }
  23440. $promises[] = $this->asyncFetchFile($url, $cacheKey, $lastModified)
  23441. ->then(function ($response) use (&$packages, &$namesFound, $contents, $realName, $constraint, $repo, $acceptableStabilities, $stabilityFlags, $alreadyLoaded) {
  23442. if (true === $response) {
  23443. $response = $contents;
  23444. }
  23445. if (!isset($response['packages'][$realName])) {
  23446. return;
  23447. }
  23448. $versions = $response['packages'][$realName];
  23449. if (isset($response['minified']) && $response['minified'] === 'composer/2.0') {
  23450. $versions = MetadataMinifier::expand($versions);
  23451. }
  23452. $namesFound[$realName] = true;
  23453. $versionsToLoad = array();
  23454. foreach ($versions as $version) {
  23455. if (!isset($version['version_normalized'])) {
  23456. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  23457. } elseif ($version['version_normalized'] === VersionParser::DEFAULT_BRANCH_ALIAS) {
  23458. $version['version_normalized'] = $repo->versionParser->normalize($version['version']);
  23459. }
  23460. if (isset($alreadyLoaded[$realName][$version['version_normalized']])) {
  23461. continue;
  23462. }
  23463. if ($repo->isVersionAcceptable($constraint, $realName, $version, $acceptableStabilities, $stabilityFlags)) {
  23464. $versionsToLoad[] = $version;
  23465. }
  23466. }
  23467. $loadedPackages = $repo->createPackages($versionsToLoad);
  23468. foreach ($loadedPackages as $package) {
  23469. $package->setRepository($repo);
  23470. $packages[spl_object_hash($package)] = $package;
  23471. if ($package instanceof AliasPackage && !isset($packages[spl_object_hash($package->getAliasOf())])) {
  23472. $package->getAliasOf()->setRepository($repo);
  23473. $packages[spl_object_hash($package->getAliasOf())] = $package->getAliasOf();
  23474. }
  23475. }
  23476. });
  23477. }
  23478. $this->loop->wait($promises);
  23479. return array('namesFound' => $namesFound, 'packages' => $packages);
  23480. }
  23481. public function isVersionAcceptable($constraint, $name, $versionData, array $acceptableStabilities = null, array $stabilityFlags = null)
  23482. {
  23483. $versions = array($versionData['version_normalized']);
  23484. if ($alias = $this->loader->getBranchAlias($versionData)) {
  23485. $versions[] = $alias;
  23486. }
  23487. foreach ($versions as $version) {
  23488. if (null !== $acceptableStabilities && null !== $stabilityFlags && !StabilityFilter::isPackageAcceptable($acceptableStabilities, $stabilityFlags, array($name), VersionParser::parseStability($version))) {
  23489. continue;
  23490. }
  23491. if ($constraint && !CompilingMatcher::match($constraint, Constraint::OP_EQ, $version)) {
  23492. continue;
  23493. }
  23494. return true;
  23495. }
  23496. return false;
  23497. }
  23498. protected function loadRootServerFile()
  23499. {
  23500. if (null !== $this->rootData) {
  23501. return $this->rootData;
  23502. }
  23503. if (!extension_loaded('openssl') && strpos($this->url, 'https') === 0) {
  23504. throw new \RuntimeException('You must enable the openssl extension in your php.ini to load information from '.$this->url);
  23505. }
  23506. $jsonUrlParts = parse_url($this->url);
  23507. if (isset($jsonUrlParts['path']) && false !== strpos($jsonUrlParts['path'], '.json')) {
  23508. $jsonUrl = $this->url;
  23509. } else {
  23510. $jsonUrl = $this->url . '/packages.json';
  23511. }
  23512. $data = $this->fetchFile($jsonUrl, 'packages.json');
  23513. if (!empty($data['notify-batch'])) {
  23514. $this->notifyUrl = $this->canonicalizeUrl($data['notify-batch']);
  23515. } elseif (!empty($data['notify'])) {
  23516. $this->notifyUrl = $this->canonicalizeUrl($data['notify']);
  23517. }
  23518. if (!empty($data['search'])) {
  23519. $this->searchUrl = $this->canonicalizeUrl($data['search']);
  23520. }
  23521. if (!empty($data['mirrors'])) {
  23522. foreach ($data['mirrors'] as $mirror) {
  23523. if (!empty($mirror['git-url'])) {
  23524. $this->sourceMirrors['git'][] = array('url' => $mirror['git-url'], 'preferred' => !empty($mirror['preferred']));
  23525. }
  23526. if (!empty($mirror['hg-url'])) {
  23527. $this->sourceMirrors['hg'][] = array('url' => $mirror['hg-url'], 'preferred' => !empty($mirror['preferred']));
  23528. }
  23529. if (!empty($mirror['dist-url'])) {
  23530. $this->distMirrors[] = array(
  23531. 'url' => $this->canonicalizeUrl($mirror['dist-url']),
  23532. 'preferred' => !empty($mirror['preferred']),
  23533. );
  23534. }
  23535. }
  23536. }
  23537. if (!empty($data['providers-lazy-url'])) {
  23538. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['providers-lazy-url']);
  23539. $this->hasProviders = true;
  23540. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  23541. }
  23542. if (!empty($data['metadata-url']) && !empty($data['list']) && $data['metadata-url'] === '/p/%package%.json' && $data['list'] === 'https://packagist.org/packages/list.json') {
  23543. $this->io->writeError('<warning>Composer 2 repository support for '.$this->url.' has been disabled due to what seems like a misconfiguration. If this is a packagist.org mirror we recommend removing it as Composer 2 handles network operations much faster and should work fine without.</warning>');
  23544. unset($data['metadata-url']);
  23545. }
  23546. if (!empty($data['metadata-url'])) {
  23547. $this->lazyProvidersUrl = $this->canonicalizeUrl($data['metadata-url']);
  23548. $this->providersUrl = null;
  23549. $this->hasProviders = false;
  23550. $this->hasPartialPackages = !empty($data['packages']) && is_array($data['packages']);
  23551. $this->allowSslDowngrade = false;
  23552. if (!empty($data['available-packages'])) {
  23553. $availPackages = array_map('strtolower', $data['available-packages']);
  23554. $this->availablePackages = array_combine($availPackages, $availPackages);
  23555. $this->hasAvailablePackageList = true;
  23556. }
  23557. if (!empty($data['available-package-patterns'])) {
  23558. $this->availablePackagePatterns = array_map(function ($pattern) {
  23559. return BasePackage::packageNameToRegexp($pattern);
  23560. }, $data['available-package-patterns']);
  23561. $this->hasAvailablePackageList = true;
  23562. }
  23563. unset($data['providers-url'], $data['providers'], $data['providers-includes']);
  23564. }
  23565. if ($this->allowSslDowngrade) {
  23566. $this->url = str_replace('https://', 'http://', $this->url);
  23567. $this->baseUrl = str_replace('https://', 'http://', $this->baseUrl);
  23568. }
  23569. if (!empty($data['providers-url'])) {
  23570. $this->providersUrl = $this->canonicalizeUrl($data['providers-url']);
  23571. $this->hasProviders = true;
  23572. }
  23573. if (!empty($data['list'])) {
  23574. $this->listUrl = $this->canonicalizeUrl($data['list']);
  23575. }
  23576. if (!empty($data['providers']) || !empty($data['providers-includes'])) {
  23577. $this->hasProviders = true;
  23578. }
  23579. if (!empty($data['providers-api'])) {
  23580. $this->providersApiUrl = $this->canonicalizeUrl($data['providers-api']);
  23581. }
  23582. return $this->rootData = $data;
  23583. }
  23584. private function canonicalizeUrl($url)
  23585. {
  23586. if ('/' === $url[0]) {
  23587. if (preg_match('{^[^:]++://[^/]*+}', $this->url, $matches)) {
  23588. return $matches[0] . $url;
  23589. }
  23590. return $this->url;
  23591. }
  23592. return $url;
  23593. }
  23594. private function loadDataFromServer()
  23595. {
  23596. $data = $this->loadRootServerFile();
  23597. return $this->loadIncludes($data);
  23598. }
  23599. private function hasPartialPackages()
  23600. {
  23601. if ($this->hasPartialPackages && null === $this->partialPackagesByName) {
  23602. $this->initializePartialPackages();
  23603. }
  23604. return $this->hasPartialPackages;
  23605. }
  23606. private function loadProviderListings($data)
  23607. {
  23608. if (isset($data['providers'])) {
  23609. if (!is_array($this->providerListing)) {
  23610. $this->providerListing = array();
  23611. }
  23612. $this->providerListing = array_merge($this->providerListing, $data['providers']);
  23613. }
  23614. if ($this->providersUrl && isset($data['provider-includes'])) {
  23615. $includes = $data['provider-includes'];
  23616. foreach ($includes as $include => $metadata) {
  23617. $url = $this->baseUrl . '/' . str_replace('%hash%', $metadata['sha256'], $include);
  23618. $cacheKey = str_replace(array('%hash%','$'), '', $include);
  23619. if ($this->cache->sha256($cacheKey) === $metadata['sha256']) {
  23620. $includedData = json_decode($this->cache->read($cacheKey), true);
  23621. } else {
  23622. $includedData = $this->fetchFile($url, $cacheKey, $metadata['sha256']);
  23623. }
  23624. $this->loadProviderListings($includedData);
  23625. }
  23626. }
  23627. }
  23628. private function loadIncludes($data)
  23629. {
  23630. $packages = array();
  23631. if (!isset($data['packages']) && !isset($data['includes'])) {
  23632. foreach ($data as $pkg) {
  23633. foreach ($pkg['versions'] as $metadata) {
  23634. $packages[] = $metadata;
  23635. }
  23636. }
  23637. return $packages;
  23638. }
  23639. if (isset($data['packages'])) {
  23640. foreach ($data['packages'] as $package => $versions) {
  23641. foreach ($versions as $version => $metadata) {
  23642. $packages[] = $metadata;
  23643. }
  23644. }
  23645. }
  23646. if (isset($data['includes'])) {
  23647. foreach ($data['includes'] as $include => $metadata) {
  23648. if (isset($metadata['sha1']) && $this->cache->sha1($include) === $metadata['sha1']) {
  23649. $includedData = json_decode($this->cache->read($include), true);
  23650. } else {
  23651. $includedData = $this->fetchFile($include);
  23652. }
  23653. $packages = array_merge($packages, $this->loadIncludes($includedData));
  23654. }
  23655. }
  23656. return $packages;
  23657. }
  23658. public function createPackages(array $packages, $class = 'Composer\Package\CompletePackage')
  23659. {
  23660. if (!$packages) {
  23661. return array();
  23662. }
  23663. try {
  23664. foreach ($packages as &$data) {
  23665. if (!isset($data['notification-url'])) {
  23666. $data['notification-url'] = $this->notifyUrl;
  23667. }
  23668. }
  23669. $packages = $this->loader->loadPackages($packages, $class);
  23670. foreach ($packages as $package) {
  23671. if (isset($this->sourceMirrors[$package->getSourceType()])) {
  23672. $package->setSourceMirrors($this->sourceMirrors[$package->getSourceType()]);
  23673. }
  23674. $package->setDistMirrors($this->distMirrors);
  23675. $this->configurePackageTransportOptions($package);
  23676. }
  23677. return $packages;
  23678. } catch (\Exception $e) {
  23679. 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);
  23680. }
  23681. }
  23682. protected function fetchFile($filename, $cacheKey = null, $sha256 = null, $storeLastModifiedTime = false)
  23683. {
  23684. if (null === $cacheKey) {
  23685. $cacheKey = $filename;
  23686. $filename = $this->baseUrl.'/'.$filename;
  23687. }
  23688. if (($pos = strpos($filename, '$')) && preg_match('{^https?://}i', $filename)) {
  23689. $filename = substr($filename, 0, $pos) . '%24' . substr($filename, $pos + 1);
  23690. }
  23691. $retries = 3;
  23692. while ($retries--) {
  23693. try {
  23694. if ($this->eventDispatcher) {
  23695. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23696. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23697. $filename = $preFileDownloadEvent->getProcessedUrl();
  23698. }
  23699. $response = $this->httpDownloader->get($filename, $this->options);
  23700. $json = $response->getBody();
  23701. if ($sha256 && $sha256 !== hash('sha256', $json)) {
  23702. if ($this->allowSslDowngrade) {
  23703. $this->url = str_replace('http://', 'https://', $this->url);
  23704. $this->baseUrl = str_replace('http://', 'https://', $this->baseUrl);
  23705. $filename = str_replace('http://', 'https://', $filename);
  23706. }
  23707. if ($retries) {
  23708. usleep(100000);
  23709. continue;
  23710. }
  23711. 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.');
  23712. }
  23713. $data = $response->decodeJson();
  23714. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  23715. if ($cacheKey && !$this->cache->isReadOnly()) {
  23716. if ($storeLastModifiedTime) {
  23717. $lastModifiedDate = $response->getHeader('last-modified');
  23718. if ($lastModifiedDate) {
  23719. $data['last-modified'] = $lastModifiedDate;
  23720. $json = json_encode($data);
  23721. }
  23722. }
  23723. $this->cache->write($cacheKey, $json);
  23724. }
  23725. $response->collect();
  23726. break;
  23727. } catch (\Exception $e) {
  23728. if ($e instanceof \LogicException) {
  23729. throw $e;
  23730. }
  23731. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23732. throw $e;
  23733. }
  23734. if ($retries) {
  23735. usleep(100000);
  23736. continue;
  23737. }
  23738. if ($e instanceof RepositorySecurityException) {
  23739. throw $e;
  23740. }
  23741. if ($cacheKey && ($contents = $this->cache->read($cacheKey))) {
  23742. if (!$this->degradedMode) {
  23743. $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>');
  23744. }
  23745. $this->degradedMode = true;
  23746. $data = JsonFile::parseJson($contents, $this->cache->getRoot().$cacheKey);
  23747. break;
  23748. }
  23749. throw $e;
  23750. }
  23751. }
  23752. if (!isset($data)) {
  23753. throw new \LogicException("ComposerRepository: Undefined \$data. Please report at https://github.com/composer/composer/issues/new.");
  23754. }
  23755. return $data;
  23756. }
  23757. private function fetchFileIfLastModified($filename, $cacheKey, $lastModifiedTime)
  23758. {
  23759. $retries = 3;
  23760. while ($retries--) {
  23761. try {
  23762. if ($this->eventDispatcher) {
  23763. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23764. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23765. $filename = $preFileDownloadEvent->getProcessedUrl();
  23766. }
  23767. $options = $this->options;
  23768. if (isset($options['http']['header'])) {
  23769. $options['http']['header'] = (array) $options['http']['header'];
  23770. }
  23771. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  23772. $response = $this->httpDownloader->get($filename, $options);
  23773. $json = $response->getBody();
  23774. if ($json === '' && $response->getStatusCode() === 304) {
  23775. return true;
  23776. }
  23777. $data = $response->decodeJson();
  23778. HttpDownloader::outputWarnings($this->io, $this->url, $data);
  23779. $lastModifiedDate = $response->getHeader('last-modified');
  23780. $response->collect();
  23781. if ($lastModifiedDate) {
  23782. $data['last-modified'] = $lastModifiedDate;
  23783. $json = json_encode($data);
  23784. }
  23785. if (!$this->cache->isReadOnly()) {
  23786. $this->cache->write($cacheKey, $json);
  23787. }
  23788. return $data;
  23789. } catch (\Exception $e) {
  23790. if ($e instanceof \LogicException) {
  23791. throw $e;
  23792. }
  23793. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23794. throw $e;
  23795. }
  23796. if ($retries) {
  23797. usleep(100000);
  23798. continue;
  23799. }
  23800. if (!$this->degradedMode) {
  23801. $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>');
  23802. }
  23803. $this->degradedMode = true;
  23804. return true;
  23805. }
  23806. }
  23807. }
  23808. private function asyncFetchFile($filename, $cacheKey, $lastModifiedTime = null)
  23809. {
  23810. $retries = 3;
  23811. if (isset($this->packagesNotFoundCache[$filename])) {
  23812. return \React\Promise\resolve(array('packages' => array()));
  23813. }
  23814. if (isset($this->freshMetadataUrls[$filename]) && $lastModifiedTime) {
  23815. return \React\Promise\resolve(true);
  23816. }
  23817. $httpDownloader = $this->httpDownloader;
  23818. if ($this->eventDispatcher) {
  23819. $preFileDownloadEvent = new PreFileDownloadEvent(PluginEvents::PRE_FILE_DOWNLOAD, $this->httpDownloader, $filename, 'metadata');
  23820. $this->eventDispatcher->dispatch($preFileDownloadEvent->getName(), $preFileDownloadEvent);
  23821. $filename = $preFileDownloadEvent->getProcessedUrl();
  23822. }
  23823. $options = $this->options;
  23824. if ($lastModifiedTime) {
  23825. if (isset($options['http']['header'])) {
  23826. $options['http']['header'] = (array) $options['http']['header'];
  23827. }
  23828. $options['http']['header'][] = 'If-Modified-Since: '.$lastModifiedTime;
  23829. }
  23830. $io = $this->io;
  23831. $url = $this->url;
  23832. $cache = $this->cache;
  23833. $degradedMode = &$this->degradedMode;
  23834. $repo = $this;
  23835. $accept = function ($response) use ($io, $url, $filename, $cache, $cacheKey, $repo) {
  23836. if ($response->getStatusCode() === 404) {
  23837. $repo->packagesNotFoundCache[$filename] = true;
  23838. return array('packages' => array());
  23839. }
  23840. $json = $response->getBody();
  23841. if ($json === '' && $response->getStatusCode() === 304) {
  23842. $repo->freshMetadataUrls[$filename] = true;
  23843. return true;
  23844. }
  23845. $data = $response->decodeJson();
  23846. HttpDownloader::outputWarnings($io, $url, $data);
  23847. $lastModifiedDate = $response->getHeader('last-modified');
  23848. $response->collect();
  23849. if ($lastModifiedDate) {
  23850. $data['last-modified'] = $lastModifiedDate;
  23851. $json = JsonFile::encode($data, JsonFile::JSON_UNESCAPED_SLASHES | JsonFile::JSON_UNESCAPED_UNICODE);
  23852. }
  23853. if (!$cache->isReadOnly()) {
  23854. $cache->write($cacheKey, $json);
  23855. }
  23856. $repo->freshMetadataUrls[$filename] = true;
  23857. return $data;
  23858. };
  23859. $reject = function ($e) use (&$retries, $httpDownloader, $filename, $options, &$reject, $accept, $io, $url, &$degradedMode, $repo) {
  23860. if ($e instanceof TransportException && $e->getStatusCode() === 404) {
  23861. $repo->packagesNotFoundCache[$filename] = true;
  23862. return false;
  23863. }
  23864. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  23865. $retries = 0;
  23866. }
  23867. if (--$retries > 0) {
  23868. usleep(100000);
  23869. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  23870. }
  23871. if (!$degradedMode) {
  23872. $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>');
  23873. }
  23874. $degradedMode = true;
  23875. if ($e instanceof TransportException && $e->getStatusCode() === 499) {
  23876. return $accept(new Response(array('url' => $url), 404, array(), ''));
  23877. }
  23878. throw $e;
  23879. };
  23880. return $httpDownloader->add($filename, $options)->then($accept, $reject);
  23881. }
  23882. private function initializePartialPackages()
  23883. {
  23884. $rootData = $this->loadRootServerFile();
  23885. $this->partialPackagesByName = array();
  23886. foreach ($rootData['packages'] as $package => $versions) {
  23887. foreach ($versions as $version) {
  23888. $this->partialPackagesByName[strtolower($version['name'])][] = $version;
  23889. }
  23890. }
  23891. $this->rootData = true;
  23892. }
  23893. protected function lazyProvidersRepoContains($name)
  23894. {
  23895. if (!$this->hasAvailablePackageList) {
  23896. throw new \LogicException('lazyProvidersRepoContains should not be called unless hasAvailablePackageList is true');
  23897. }
  23898. if (is_array($this->availablePackages) && isset($this->availablePackages[$name])) {
  23899. return true;
  23900. }
  23901. if (is_array($this->availablePackagePatterns)) {
  23902. foreach ($this->availablePackagePatterns as $providerRegex) {
  23903. if (preg_match($providerRegex, $name)) {
  23904. return true;
  23905. }
  23906. }
  23907. }
  23908. return false;
  23909. }
  23910. }
  23911. <?php
  23912. namespace Composer\Repository;
  23913. use Composer\Package\PackageInterface;
  23914. class CompositeRepository implements RepositoryInterface
  23915. {
  23916. private $repositories;
  23917. public function __construct(array $repositories)
  23918. {
  23919. $this->repositories = array();
  23920. foreach ($repositories as $repo) {
  23921. $this->addRepository($repo);
  23922. }
  23923. }
  23924. public function getRepoName()
  23925. {
  23926. return 'composite repo ('.implode(', ', array_map(function ($repo) {
  23927. return $repo->getRepoName();
  23928. }, $this->repositories)).')';
  23929. }
  23930. public function getRepositories()
  23931. {
  23932. return $this->repositories;
  23933. }
  23934. public function hasPackage(PackageInterface $package)
  23935. {
  23936. foreach ($this->repositories as $repository) {
  23937. if ($repository->hasPackage($package)) {
  23938. return true;
  23939. }
  23940. }
  23941. return false;
  23942. }
  23943. public function findPackage($name, $constraint)
  23944. {
  23945. foreach ($this->repositories as $repository) {
  23946. $package = $repository->findPackage($name, $constraint);
  23947. if (null !== $package) {
  23948. return $package;
  23949. }
  23950. }
  23951. return null;
  23952. }
  23953. public function findPackages($name, $constraint = null)
  23954. {
  23955. $packages = array();
  23956. foreach ($this->repositories as $repository) {
  23957. $packages[] = $repository->findPackages($name, $constraint);
  23958. }
  23959. return $packages ? call_user_func_array('array_merge', $packages) : array();
  23960. }
  23961. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  23962. {
  23963. $packages = array();
  23964. $namesFound = array();
  23965. foreach ($this->repositories as $repository) {
  23966. $result = $repository->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  23967. $packages[] = $result['packages'];
  23968. $namesFound[] = $result['namesFound'];
  23969. }
  23970. return array(
  23971. 'packages' => $packages ? call_user_func_array('array_merge', $packages) : array(),
  23972. 'namesFound' => $namesFound ? array_unique(call_user_func_array('array_merge', $namesFound)) : array(),
  23973. );
  23974. }
  23975. public function search($query, $mode = 0, $type = null)
  23976. {
  23977. $matches = array();
  23978. foreach ($this->repositories as $repository) {
  23979. $matches[] = $repository->search($query, $mode, $type);
  23980. }
  23981. return $matches ? call_user_func_array('array_merge', $matches) : array();
  23982. }
  23983. public function getPackages()
  23984. {
  23985. $packages = array();
  23986. foreach ($this->repositories as $repository) {
  23987. $packages[] = $repository->getPackages();
  23988. }
  23989. return $packages ? call_user_func_array('array_merge', $packages) : array();
  23990. }
  23991. public function getProviders($packageName)
  23992. {
  23993. $results = array();
  23994. foreach ($this->repositories as $repository) {
  23995. $results[] = $repository->getProviders($packageName);
  23996. }
  23997. return $results ? call_user_func_array('array_merge', $results) : array();
  23998. }
  23999. public function removePackage(PackageInterface $package)
  24000. {
  24001. foreach ($this->repositories as $repository) {
  24002. $repository->removePackage($package);
  24003. }
  24004. }
  24005. public function count()
  24006. {
  24007. $total = 0;
  24008. foreach ($this->repositories as $repository) {
  24009. $total += $repository->count();
  24010. }
  24011. return $total;
  24012. }
  24013. public function addRepository(RepositoryInterface $repository)
  24014. {
  24015. if ($repository instanceof self) {
  24016. foreach ($repository->getRepositories() as $repo) {
  24017. $this->addRepository($repo);
  24018. }
  24019. } else {
  24020. $this->repositories[] = $repository;
  24021. }
  24022. }
  24023. }
  24024. <?php
  24025. namespace Composer\Repository;
  24026. interface ConfigurableRepositoryInterface
  24027. {
  24028. public function getRepoConfig();
  24029. }
  24030. <?php
  24031. namespace Composer\Repository;
  24032. use Composer\Json\JsonFile;
  24033. use Composer\Package\Loader\ArrayLoader;
  24034. use Composer\Package\RootPackageInterface;
  24035. use Composer\Package\AliasPackage;
  24036. use Composer\Package\Dumper\ArrayDumper;
  24037. use Composer\Installer\InstallationManager;
  24038. use Composer\Util\Filesystem;
  24039. class FilesystemRepository extends WritableArrayRepository
  24040. {
  24041. protected $file;
  24042. private $dumpVersions;
  24043. private $rootPackage;
  24044. public function __construct(JsonFile $repositoryFile, $dumpVersions = false, RootPackageInterface $rootPackage = null)
  24045. {
  24046. parent::__construct();
  24047. $this->file = $repositoryFile;
  24048. $this->dumpVersions = $dumpVersions;
  24049. $this->rootPackage = $rootPackage;
  24050. if ($dumpVersions && !$rootPackage) {
  24051. throw new \InvalidArgumentException('Expected a root package instance if $dumpVersions is true');
  24052. }
  24053. }
  24054. protected function initialize()
  24055. {
  24056. parent::initialize();
  24057. if (!$this->file->exists()) {
  24058. return;
  24059. }
  24060. try {
  24061. $data = $this->file->read();
  24062. if (isset($data['packages'])) {
  24063. $packages = $data['packages'];
  24064. } else {
  24065. $packages = $data;
  24066. }
  24067. if (isset($data['dev-package-names'])) {
  24068. $this->setDevPackageNames($data['dev-package-names']);
  24069. }
  24070. if (!is_array($packages)) {
  24071. throw new \UnexpectedValueException('Could not parse package list from the repository');
  24072. }
  24073. } catch (\Exception $e) {
  24074. throw new InvalidRepositoryException('Invalid repository data in '.$this->file->getPath().', packages could not be loaded: ['.get_class($e).'] '.$e->getMessage());
  24075. }
  24076. $loader = new ArrayLoader(null, true);
  24077. foreach ($packages as $packageData) {
  24078. $package = $loader->load($packageData);
  24079. $this->addPackage($package);
  24080. }
  24081. }
  24082. public function reload()
  24083. {
  24084. $this->packages = null;
  24085. $this->initialize();
  24086. }
  24087. public function write($devMode, InstallationManager $installationManager)
  24088. {
  24089. $data = array('packages' => array(), 'dev' => $devMode, 'dev-package-names' => array());
  24090. $dumper = new ArrayDumper();
  24091. $fs = new Filesystem();
  24092. $repoDir = dirname($fs->normalizePath($this->file->getPath()));
  24093. foreach ($this->getCanonicalPackages() as $package) {
  24094. $pkgArray = $dumper->dump($package);
  24095. $path = $installationManager->getInstallPath($package);
  24096. $pkgArray['install-path'] = ('' !== $path && null !== $path) ? $fs->findShortestPath($repoDir, $fs->isAbsolutePath($path) ? $path : getcwd() . '/' . $path, true) : null;
  24097. $data['packages'][] = $pkgArray;
  24098. if (in_array($package->getName(), $this->devPackageNames, true)) {
  24099. $data['dev-package-names'][] = $package->getName();
  24100. }
  24101. }
  24102. sort($data['dev-package-names']);
  24103. usort($data['packages'], function ($a, $b) {
  24104. return strcmp($a['name'], $b['name']);
  24105. });
  24106. $this->file->write($data);
  24107. if ($this->dumpVersions) {
  24108. $versions = array('versions' => array());
  24109. $packages = $this->getPackages();
  24110. $packages[] = $rootPackage = $this->rootPackage;
  24111. while ($rootPackage instanceof AliasPackage) {
  24112. $rootPackage = $rootPackage->getAliasOf();
  24113. $packages[] = $rootPackage;
  24114. }
  24115. foreach ($packages as $package) {
  24116. if ($package instanceof AliasPackage) {
  24117. continue;
  24118. }
  24119. $reference = null;
  24120. if ($package->getInstallationSource()) {
  24121. $reference = $package->getInstallationSource() === 'source' ? $package->getSourceReference() : $package->getDistReference();
  24122. }
  24123. if (null === $reference) {
  24124. $reference = ($package->getSourceReference() ?: $package->getDistReference()) ?: null;
  24125. }
  24126. $versions['versions'][$package->getName()] = array(
  24127. 'pretty_version' => $package->getPrettyVersion(),
  24128. 'version' => $package->getVersion(),
  24129. 'aliases' => array(),
  24130. 'reference' => $reference,
  24131. );
  24132. if ($package instanceof RootPackageInterface) {
  24133. $versions['root'] = $versions['versions'][$package->getName()];
  24134. $versions['root']['name'] = $package->getName();
  24135. }
  24136. }
  24137. foreach ($packages as $package) {
  24138. foreach ($package->getReplaces() as $replace) {
  24139. if (PlatformRepository::isPlatformPackage($replace->getTarget())) {
  24140. continue;
  24141. }
  24142. $replaced = $replace->getPrettyConstraint();
  24143. if ($replaced === 'self.version') {
  24144. $replaced = $package->getPrettyVersion();
  24145. }
  24146. if (!isset($versions['versions'][$replace->getTarget()]['replaced']) || !in_array($replaced, $versions['versions'][$replace->getTarget()]['replaced'], true)) {
  24147. $versions['versions'][$replace->getTarget()]['replaced'][] = $replaced;
  24148. }
  24149. }
  24150. foreach ($package->getProvides() as $provide) {
  24151. if (PlatformRepository::isPlatformPackage($provide->getTarget())) {
  24152. continue;
  24153. }
  24154. $provided = $provide->getPrettyConstraint();
  24155. if ($provided === 'self.version') {
  24156. $provided = $package->getPrettyVersion();
  24157. }
  24158. if (!isset($versions['versions'][$provide->getTarget()]['provided']) || !in_array($provided, $versions['versions'][$provide->getTarget()]['provided'], true)) {
  24159. $versions['versions'][$provide->getTarget()]['provided'][] = $provided;
  24160. }
  24161. }
  24162. }
  24163. foreach ($packages as $package) {
  24164. if (!$package instanceof AliasPackage) {
  24165. continue;
  24166. }
  24167. $versions['versions'][$package->getName()]['aliases'][] = $package->getPrettyVersion();
  24168. if ($package instanceof RootPackageInterface) {
  24169. $versions['root']['aliases'][] = $package->getPrettyVersion();
  24170. }
  24171. }
  24172. ksort($versions['versions']);
  24173. ksort($versions);
  24174. $fs->filePutContentsIfModified($repoDir.'/installed.php', '<?php return '.var_export($versions, true).';'."\n");
  24175. $installedVersionsClass = file_get_contents(__DIR__.'/../InstalledVersions.php');
  24176. $installedVersionsClass = str_replace('private static $installed;', 'private static $installed = '.var_export($versions, true).';', $installedVersionsClass);
  24177. $fs->filePutContentsIfModified($repoDir.'/InstalledVersions.php', $installedVersionsClass);
  24178. if (!class_exists('Composer\InstalledVersions', false)) {
  24179. include $repoDir.'/InstalledVersions.php';
  24180. } else {
  24181. \Composer\InstalledVersions::reload($versions);
  24182. }
  24183. }
  24184. }
  24185. }
  24186. <?php
  24187. namespace Composer\Repository;
  24188. use Composer\Package\PackageInterface;
  24189. use Composer\Package\BasePackage;
  24190. class FilterRepository implements RepositoryInterface
  24191. {
  24192. private $only = array();
  24193. private $exclude = array();
  24194. private $canonical = true;
  24195. private $repo;
  24196. public function __construct(RepositoryInterface $repo, array $options)
  24197. {
  24198. if (isset($options['only'])) {
  24199. if (!is_array($options['only'])) {
  24200. throw new \InvalidArgumentException('"only" key for repository '.$repo->getRepoName().' should be an array');
  24201. }
  24202. $this->only = '{^'.implode('|', array_map(function ($val) {
  24203. return BasePackage::packageNameToRegexp($val, '%s');
  24204. }, $options['only'])) .'$}iD';
  24205. }
  24206. if (isset($options['exclude'])) {
  24207. if (!is_array($options['exclude'])) {
  24208. throw new \InvalidArgumentException('"exclude" key for repository '.$repo->getRepoName().' should be an array');
  24209. }
  24210. $this->exclude = '{^'.implode('|', array_map(function ($val) {
  24211. return BasePackage::packageNameToRegexp($val, '%s');
  24212. }, $options['exclude'])) .'$}iD';
  24213. }
  24214. if ($this->exclude && $this->only) {
  24215. throw new \InvalidArgumentException('Only one of "only" and "exclude" can be specified for repository '.$repo->getRepoName());
  24216. }
  24217. if (isset($options['canonical'])) {
  24218. if (!is_bool($options['canonical'])) {
  24219. throw new \InvalidArgumentException('"canonical" key for repository '.$repo->getRepoName().' should be a boolean');
  24220. }
  24221. $this->canonical = $options['canonical'];
  24222. }
  24223. $this->repo = $repo;
  24224. }
  24225. public function getRepoName()
  24226. {
  24227. return $this->repo->getRepoName();
  24228. }
  24229. public function getRepository()
  24230. {
  24231. return $this->repo;
  24232. }
  24233. public function hasPackage(PackageInterface $package)
  24234. {
  24235. return $this->repo->hasPackage($package);
  24236. }
  24237. public function findPackage($name, $constraint)
  24238. {
  24239. if (!$this->isAllowed($name)) {
  24240. return null;
  24241. }
  24242. return $this->repo->findPackage($name, $constraint);
  24243. }
  24244. public function findPackages($name, $constraint = null)
  24245. {
  24246. if (!$this->isAllowed($name)) {
  24247. return array();
  24248. }
  24249. return $this->repo->findPackages($name, $constraint);
  24250. }
  24251. public function loadPackages(array $packageMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array())
  24252. {
  24253. foreach ($packageMap as $name => $constraint) {
  24254. if (!$this->isAllowed($name)) {
  24255. unset($packageMap[$name]);
  24256. }
  24257. }
  24258. if (!$packageMap) {
  24259. return array('namesFound' => array(), 'packages' => array());
  24260. }
  24261. $result = $this->repo->loadPackages($packageMap, $acceptableStabilities, $stabilityFlags, $alreadyLoaded);
  24262. if (!$this->canonical) {
  24263. $result['namesFound'] = array();
  24264. }
  24265. return $result;
  24266. }
  24267. public function search($query, $mode = 0, $type = null)
  24268. {
  24269. $result = array();
  24270. foreach ($this->repo->search($query, $mode, $type) as $package) {
  24271. if ($this->isAllowed($package['name'])) {
  24272. $result[] = $package;
  24273. }
  24274. }
  24275. return $result;
  24276. }
  24277. public function getPackages()
  24278. {
  24279. $result = array();
  24280. foreach ($this->repo->getPackages() as $package) {
  24281. if ($this->isAllowed($package->getName())) {
  24282. $result[] = $package;
  24283. }
  24284. }
  24285. return $result;
  24286. }
  24287. public function getProviders($packageName)
  24288. {
  24289. $result = array();
  24290. foreach ($this->repo->getProviders($packageName) as $provider) {
  24291. if ($this->isAllowed($provider['name'])) {
  24292. $result[] = $provider;
  24293. }
  24294. }
  24295. return $result;
  24296. }
  24297. public function removePackage(PackageInterface $package)
  24298. {
  24299. return $this->repo->removePackage($package);
  24300. }
  24301. public function count()
  24302. {
  24303. if ($this->repo->count() > 0) {
  24304. return count($this->getPackages());
  24305. }
  24306. return 0;
  24307. }
  24308. private function isAllowed($name)
  24309. {
  24310. if (!$this->only && !$this->exclude) {
  24311. return true;
  24312. }
  24313. if ($this->only) {
  24314. return (bool) preg_match($this->only, $name);
  24315. }
  24316. return !preg_match($this->exclude, $name);
  24317. }
  24318. }
  24319. <?php
  24320. namespace Composer\Repository;
  24321. class InstalledArrayRepository extends WritableArrayRepository implements InstalledRepositoryInterface
  24322. {
  24323. public function getRepoName()
  24324. {
  24325. return 'installed '.parent::getRepoName();
  24326. }
  24327. public function isFresh()
  24328. {
  24329. return $this->count() === 0;
  24330. }
  24331. }
  24332. <?php
  24333. namespace Composer\Repository;
  24334. class InstalledFilesystemRepository extends FilesystemRepository implements InstalledRepositoryInterface
  24335. {
  24336. public function getRepoName()
  24337. {
  24338. return 'installed '.parent::getRepoName();
  24339. }
  24340. public function isFresh()
  24341. {
  24342. return !$this->file->exists();
  24343. }
  24344. }
  24345. <?php
  24346. namespace Composer\Repository;
  24347. use Composer\Package\Version\VersionParser;
  24348. use Composer\Semver\Constraint\ConstraintInterface;
  24349. use Composer\Semver\Constraint\Constraint;
  24350. use Composer\Semver\Constraint\MatchAllConstraint;
  24351. use Composer\Package\RootPackageInterface;
  24352. use Composer\Package\Link;
  24353. class InstalledRepository extends CompositeRepository
  24354. {
  24355. public function findPackagesWithReplacersAndProviders($name, $constraint = null)
  24356. {
  24357. $name = strtolower($name);
  24358. if (null !== $constraint && !$constraint instanceof ConstraintInterface) {
  24359. $versionParser = new VersionParser();
  24360. $constraint = $versionParser->parseConstraints($constraint);
  24361. }
  24362. $matches = array();
  24363. foreach ($this->getRepositories() as $repo) {
  24364. foreach ($repo->getPackages() as $candidate) {
  24365. if ($name === $candidate->getName()) {
  24366. if (null === $constraint || $constraint->matches(new Constraint('==', $candidate->getVersion()))) {
  24367. $matches[] = $candidate;
  24368. }
  24369. continue;
  24370. }
  24371. foreach (array_merge($candidate->getProvides(), $candidate->getReplaces()) as $link) {
  24372. if (
  24373. $name === $link->getTarget()
  24374. && ($constraint === null || $link->getConstraint() === null || $constraint->matches($link->getConstraint()))
  24375. ) {
  24376. $matches[] = $candidate;
  24377. continue 2;
  24378. }
  24379. }
  24380. }
  24381. }
  24382. return $matches;
  24383. }
  24384. public function getDependents($needle, $constraint = null, $invert = false, $recurse = true, $packagesFound = null)
  24385. {
  24386. $needles = array_map('strtolower', (array) $needle);
  24387. $results = array();
  24388. if (null === $packagesFound) {
  24389. $packagesFound = $needles;
  24390. }
  24391. $rootPackage = null;
  24392. foreach ($this->getPackages() as $package) {
  24393. if ($package instanceof RootPackageInterface) {
  24394. $rootPackage = $package;
  24395. break;
  24396. }
  24397. }
  24398. foreach ($this->getPackages() as $package) {
  24399. $links = $package->getRequires();
  24400. $packagesInTree = $packagesFound;
  24401. if (!$invert) {
  24402. $links += $package->getReplaces();
  24403. foreach ($package->getReplaces() as $link) {
  24404. foreach ($needles as $needle) {
  24405. if ($link->getSource() === $needle) {
  24406. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  24407. if (in_array($link->getTarget(), $packagesInTree)) {
  24408. $results[] = array($package, $link, false);
  24409. continue;
  24410. }
  24411. $packagesInTree[] = $link->getTarget();
  24412. $dependents = $recurse ? $this->getDependents($link->getTarget(), null, false, true, $packagesInTree) : array();
  24413. $results[] = array($package, $link, $dependents);
  24414. $needles[] = $link->getTarget();
  24415. }
  24416. }
  24417. }
  24418. }
  24419. }
  24420. if ($package instanceof RootPackageInterface) {
  24421. $links += $package->getDevRequires();
  24422. }
  24423. foreach ($links as $link) {
  24424. foreach ($needles as $needle) {
  24425. if ($link->getTarget() === $needle) {
  24426. if ($constraint === null || ($link->getConstraint()->matches($constraint) === !$invert)) {
  24427. if (in_array($link->getSource(), $packagesInTree)) {
  24428. $results[] = array($package, $link, false);
  24429. continue;
  24430. }
  24431. $packagesInTree[] = $link->getSource();
  24432. $dependents = $recurse ? $this->getDependents($link->getSource(), null, false, true, $packagesInTree) : array();
  24433. $results[] = array($package, $link, $dependents);
  24434. }
  24435. }
  24436. }
  24437. }
  24438. if ($invert && in_array($package->getName(), $needles)) {
  24439. foreach ($package->getConflicts() as $link) {
  24440. foreach ($this->findPackages($link->getTarget()) as $pkg) {
  24441. $version = new Constraint('=', $pkg->getVersion());
  24442. if ($link->getConstraint()->matches($version) === $invert) {
  24443. $results[] = array($package, $link, false);
  24444. }
  24445. }
  24446. }
  24447. }
  24448. if ($invert && $constraint && in_array($package->getName(), $needles) && $constraint->matches(new Constraint('=', $package->getVersion()))) {
  24449. foreach ($package->getRequires() as $link) {
  24450. if (PlatformRepository::isPlatformPackage($link->getTarget())) {
  24451. if ($this->findPackage($link->getTarget(), $link->getConstraint())) {
  24452. continue;
  24453. }
  24454. $platformPkg = $this->findPackage($link->getTarget(), '*');
  24455. $description = $platformPkg ? 'but '.$platformPkg->getPrettyVersion().' is installed' : 'but it is missing';
  24456. $results[] = array($package, new Link($package->getName(), $link->getTarget(), new MatchAllConstraint, Link::TYPE_REQUIRE, $link->getPrettyConstraint().' '.$description), false);
  24457. continue;
  24458. }
  24459. foreach ($this->getPackages() as $pkg) {
  24460. if (!in_array($link->getTarget(), $pkg->getNames())) {
  24461. continue;
  24462. }
  24463. $version = new Constraint('=', $pkg->getVersion());
  24464. if ($link->getTarget() !== $pkg->getName()) {
  24465. foreach (array_merge($pkg->getReplaces(), $pkg->getProvides()) as $prov) {
  24466. if ($link->getTarget() === $prov->getTarget()) {
  24467. $version = $prov->getConstraint();
  24468. break;
  24469. }
  24470. }
  24471. }
  24472. if (!$link->getConstraint()->matches($version)) {
  24473. if ($rootPackage) {
  24474. foreach (array_merge($rootPackage->getRequires(), $rootPackage->getDevRequires()) as $rootReq) {
  24475. if (in_array($rootReq->getTarget(), $pkg->getNames()) && !$rootReq->getConstraint()->matches($link->getConstraint())) {
  24476. $results[] = array($package, $link, false);
  24477. $results[] = array($rootPackage, $rootReq, false);
  24478. continue 3;
  24479. }
  24480. }
  24481. $results[] = array($package, $link, false);
  24482. $results[] = array($rootPackage, new Link($rootPackage->getName(), $link->getTarget(), new MatchAllConstraint, 'does not require', 'but ' . $pkg->getPrettyVersion() . ' is installed'), false);
  24483. } else {
  24484. $results[] = array($package, $link, false);
  24485. }
  24486. }
  24487. continue 2;
  24488. }
  24489. }
  24490. }
  24491. }
  24492. ksort($results);
  24493. return $results;
  24494. }
  24495. public function getRepoName()
  24496. {
  24497. return 'installed repo ('.implode(', ', array_map(function ($repo) {
  24498. return $repo->getRepoName();
  24499. }, $this->getRepositories())).')';
  24500. }
  24501. public function addRepository(RepositoryInterface $repository)
  24502. {
  24503. if (
  24504. $repository instanceof LockArrayRepository
  24505. || $repository instanceof InstalledRepositoryInterface
  24506. || $repository instanceof RootPackageRepository
  24507. || $repository instanceof PlatformRepository
  24508. ) {
  24509. return parent::addRepository($repository);
  24510. }
  24511. throw new \LogicException('An InstalledRepository can not contain a repository of type '.get_class($repository).' ('.$repository->getRepoName().')');
  24512. }
  24513. }
  24514. <?php
  24515. namespace Composer\Repository;
  24516. interface InstalledRepositoryInterface extends WritableRepositoryInterface
  24517. {
  24518. public function isFresh();
  24519. }
  24520. <?php
  24521. namespace Composer\Repository;
  24522. class InvalidRepositoryException extends \Exception
  24523. {
  24524. }
  24525. <?php
  24526. namespace Composer\Repository;
  24527. class LockArrayRepository extends ArrayRepository
  24528. {
  24529. public function getRepoName()
  24530. {
  24531. return 'lock repo';
  24532. }
  24533. }
  24534. <?php
  24535. namespace Composer\Repository;
  24536. use Composer\Package\Loader\ArrayLoader;
  24537. use Composer\Package\Loader\ValidatingArrayLoader;
  24538. class PackageRepository extends ArrayRepository
  24539. {
  24540. private $config;
  24541. public function __construct(array $config)
  24542. {
  24543. parent::__construct();
  24544. $this->config = $config['package'];
  24545. if (!is_numeric(key($this->config))) {
  24546. $this->config = array($this->config);
  24547. }
  24548. }
  24549. protected function initialize()
  24550. {
  24551. parent::initialize();
  24552. $loader = new ValidatingArrayLoader(new ArrayLoader(null, true), false);
  24553. foreach ($this->config as $package) {
  24554. try {
  24555. $package = $loader->load($package);
  24556. } catch (\Exception $e) {
  24557. throw new InvalidRepositoryException('A repository of type "package" contains an invalid package definition: '.$e->getMessage()."\n\nInvalid package definition:\n".json_encode($package));
  24558. }
  24559. $this->addPackage($package);
  24560. }
  24561. }
  24562. public function getRepoName()
  24563. {
  24564. return preg_replace('{^array }', 'package ', parent::getRepoName());
  24565. }
  24566. }
  24567. <?php
  24568. namespace Composer\Repository;
  24569. use Composer\Config;
  24570. use Composer\IO\IOInterface;
  24571. use Composer\Json\JsonFile;
  24572. use Composer\Package\Loader\ArrayLoader;
  24573. use Composer\Package\Version\VersionGuesser;
  24574. use Composer\Package\Version\VersionParser;
  24575. use Composer\Util\Platform;
  24576. use Composer\Util\ProcessExecutor;
  24577. use Composer\Util\Filesystem;
  24578. use Composer\Util\Url;
  24579. use Composer\Util\Git as GitUtil;
  24580. class PathRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  24581. {
  24582. private $loader;
  24583. private $versionGuesser;
  24584. private $url;
  24585. private $repoConfig;
  24586. private $process;
  24587. private $options;
  24588. public function __construct(array $repoConfig, IOInterface $io, Config $config)
  24589. {
  24590. if (!isset($repoConfig['url'])) {
  24591. throw new \RuntimeException('You must specify the `url` configuration for the path repository');
  24592. }
  24593. $this->loader = new ArrayLoader(null, true);
  24594. $this->url = Platform::expandPath($repoConfig['url']);
  24595. $this->process = new ProcessExecutor($io);
  24596. $this->versionGuesser = new VersionGuesser($config, $this->process, new VersionParser());
  24597. $this->repoConfig = $repoConfig;
  24598. $this->options = isset($repoConfig['options']) ? $repoConfig['options'] : array();
  24599. if (!isset($this->options['relative'])) {
  24600. $filesystem = new Filesystem();
  24601. $this->options['relative'] = !$filesystem->isAbsolutePath($this->url);
  24602. }
  24603. parent::__construct();
  24604. }
  24605. public function getRepoName()
  24606. {
  24607. return 'path repo ('.Url::sanitize($this->repoConfig['url']).')';
  24608. }
  24609. public function getRepoConfig()
  24610. {
  24611. return $this->repoConfig;
  24612. }
  24613. protected function initialize()
  24614. {
  24615. parent::initialize();
  24616. $urlMatches = $this->getUrlMatches();
  24617. if (empty($urlMatches)) {
  24618. if (preg_match('{[*{}]}', $this->url)) {
  24619. $url = $this->url;
  24620. while (preg_match('{[*{}]}', $url)) {
  24621. $url = dirname($url);
  24622. }
  24623. if (is_dir($url)) {
  24624. return;
  24625. }
  24626. }
  24627. throw new \RuntimeException('The `url` supplied for the path (' . $this->url . ') repository does not exist');
  24628. }
  24629. foreach ($urlMatches as $url) {
  24630. $path = realpath($url) . DIRECTORY_SEPARATOR;
  24631. $composerFilePath = $path.'composer.json';
  24632. if (!file_exists($composerFilePath)) {
  24633. continue;
  24634. }
  24635. $json = file_get_contents($composerFilePath);
  24636. $package = JsonFile::parseJson($json, $composerFilePath);
  24637. $package['dist'] = array(
  24638. 'type' => 'path',
  24639. 'url' => $url,
  24640. 'reference' => sha1($json . serialize($this->options)),
  24641. );
  24642. $package['transport-options'] = $this->options;
  24643. unset($package['transport-options']['versions']);
  24644. if (isset($package['name'], $this->options['versions'][$package['name']])) {
  24645. $package['version'] = $this->options['versions'][$package['name']];
  24646. }
  24647. if (!isset($package['version']) && ($rootVersion = getenv('COMPOSER_ROOT_VERSION'))) {
  24648. if (
  24649. 0 === $this->process->execute('git rev-parse HEAD', $ref1, $path)
  24650. && 0 === $this->process->execute('git rev-parse HEAD', $ref2)
  24651. && $ref1 === $ref2
  24652. ) {
  24653. $package['version'] = $rootVersion;
  24654. }
  24655. }
  24656. $output = '';
  24657. if (is_dir($path . DIRECTORY_SEPARATOR . '.git') && 0 === $this->process->execute('git log -n1 --pretty=%H'.GitUtil::getNoShowSignatureFlag($this->process), $output, $path)) {
  24658. $package['dist']['reference'] = trim($output);
  24659. }
  24660. if (!isset($package['version'])) {
  24661. $versionData = $this->versionGuesser->guessVersion($package, $path);
  24662. if (is_array($versionData) && $versionData['pretty_version']) {
  24663. if (!empty($versionData['feature_pretty_version'])) {
  24664. $package['version'] = $versionData['feature_pretty_version'];
  24665. $this->addPackage($this->loader->load($package));
  24666. }
  24667. $package['version'] = $versionData['pretty_version'];
  24668. } else {
  24669. $package['version'] = 'dev-master';
  24670. }
  24671. }
  24672. $package = $this->loader->load($package);
  24673. $this->addPackage($package);
  24674. }
  24675. }
  24676. private function getUrlMatches()
  24677. {
  24678. $flags = GLOB_MARK | GLOB_ONLYDIR;
  24679. if (defined('GLOB_BRACE')) {
  24680. $flags |= GLOB_BRACE;
  24681. } elseif (strpos($this->url, '{') !== false || strpos($this->url, '}') !== false) {
  24682. throw new \RuntimeException('The operating system does not support GLOB_BRACE which is required for the url '. $this->url);
  24683. }
  24684. return array_map(function ($val) {
  24685. return rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $val), '/');
  24686. }, glob($this->url, $flags));
  24687. }
  24688. }
  24689. <?php
  24690. namespace Composer\Repository;
  24691. class PearRepository extends ArrayRepository
  24692. {
  24693. public function __construct()
  24694. {
  24695. throw new \RuntimeException('The PEAR repository has been removed from Composer 2.0');
  24696. }
  24697. }
  24698. <?php
  24699. namespace Composer\Repository;
  24700. use Composer\Composer;
  24701. use Composer\Package\CompletePackage;
  24702. use Composer\Package\Link;
  24703. use Composer\Package\PackageInterface;
  24704. use Composer\Package\Version\VersionParser;
  24705. use Composer\Platform\HhvmDetector;
  24706. use Composer\Platform\Runtime;
  24707. use Composer\Platform\Version;
  24708. use Composer\Plugin\PluginInterface;
  24709. use Composer\Semver\Constraint\Constraint;
  24710. use Composer\Util\Silencer;
  24711. use Composer\XdebugHandler\XdebugHandler;
  24712. class PlatformRepository extends ArrayRepository
  24713. {
  24714. const PLATFORM_PACKAGE_REGEX = '{^(?:php(?:-64bit|-ipv6|-zts|-debug)?|hhvm|(?:ext|lib)-[a-z0-9](?:[_.-]?[a-z0-9]+)*|composer-(?:plugin|runtime)-api)$}iD';
  24715. private $versionParser;
  24716. private $overrides = array();
  24717. private $runtime;
  24718. private $hhvmDetector;
  24719. public function __construct(array $packages = array(), array $overrides = array(), Runtime $runtime = null, HhvmDetector $hhvmDetector = null)
  24720. {
  24721. $this->runtime = $runtime ?: new Runtime();
  24722. $this->hhvmDetector = $hhvmDetector ?: new HhvmDetector();
  24723. foreach ($overrides as $name => $version) {
  24724. $this->overrides[strtolower($name)] = array('name' => $name, 'version' => $version);
  24725. }
  24726. parent::__construct($packages);
  24727. }
  24728. public function getRepoName()
  24729. {
  24730. return 'platform repo';
  24731. }
  24732. protected function initialize()
  24733. {
  24734. parent::initialize();
  24735. $this->versionParser = new VersionParser();
  24736. foreach ($this->overrides as $override) {
  24737. if (!self::isPlatformPackage($override['name'])) {
  24738. throw new \InvalidArgumentException('Invalid platform package name in config.platform: '.$override['name']);
  24739. }
  24740. $this->addOverriddenPackage($override);
  24741. }
  24742. $prettyVersion = PluginInterface::PLUGIN_API_VERSION;
  24743. $version = $this->versionParser->normalize($prettyVersion);
  24744. $composerPluginApi = new CompletePackage('composer-plugin-api', $version, $prettyVersion);
  24745. $composerPluginApi->setDescription('The Composer Plugin API');
  24746. $this->addPackage($composerPluginApi);
  24747. $prettyVersion = Composer::RUNTIME_API_VERSION;
  24748. $version = $this->versionParser->normalize($prettyVersion);
  24749. $composerRuntimeApi = new CompletePackage('composer-runtime-api', $version, $prettyVersion);
  24750. $composerRuntimeApi->setDescription('The Composer Runtime API');
  24751. $this->addPackage($composerRuntimeApi);
  24752. try {
  24753. $prettyVersion = $this->runtime->getConstant('PHP_VERSION');
  24754. $version = $this->versionParser->normalize($prettyVersion);
  24755. } catch (\UnexpectedValueException $e) {
  24756. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $this->runtime->getConstant('PHP_VERSION'));
  24757. $version = $this->versionParser->normalize($prettyVersion);
  24758. }
  24759. $php = new CompletePackage('php', $version, $prettyVersion);
  24760. $php->setDescription('The PHP interpreter');
  24761. $this->addPackage($php);
  24762. if ($this->runtime->getConstant('PHP_DEBUG')) {
  24763. $phpdebug = new CompletePackage('php-debug', $version, $prettyVersion);
  24764. $phpdebug->setDescription('The PHP interpreter, with debugging symbols');
  24765. $this->addPackage($phpdebug);
  24766. }
  24767. if ($this->runtime->hasConstant('PHP_ZTS') && $this->runtime->getConstant('PHP_ZTS')) {
  24768. $phpzts = new CompletePackage('php-zts', $version, $prettyVersion);
  24769. $phpzts->setDescription('The PHP interpreter, with Zend Thread Safety');
  24770. $this->addPackage($phpzts);
  24771. }
  24772. if ($this->runtime->getConstant('PHP_INT_SIZE') === 8) {
  24773. $php64 = new CompletePackage('php-64bit', $version, $prettyVersion);
  24774. $php64->setDescription('The PHP interpreter, 64bit');
  24775. $this->addPackage($php64);
  24776. }
  24777. if ($this->runtime->hasConstant('AF_INET6') || Silencer::call(array($this->runtime, 'invoke'), 'inet_pton', array('::')) !== false) {
  24778. $phpIpv6 = new CompletePackage('php-ipv6', $version, $prettyVersion);
  24779. $phpIpv6->setDescription('The PHP interpreter, with IPv6 support');
  24780. $this->addPackage($phpIpv6);
  24781. }
  24782. $loadedExtensions = $this->runtime->getExtensions();
  24783. foreach ($loadedExtensions as $name) {
  24784. if (in_array($name, array('standard', 'Core'))) {
  24785. continue;
  24786. }
  24787. $this->addExtension($name, $this->runtime->getExtensionVersion($name));
  24788. }
  24789. if (!in_array('xdebug', $loadedExtensions, true) && ($prettyVersion = XdebugHandler::getSkippedVersion())) {
  24790. $this->addExtension('xdebug', $prettyVersion);
  24791. }
  24792. foreach ($loadedExtensions as $name) {
  24793. switch ($name) {
  24794. case 'amqp':
  24795. $info = $this->runtime->getExtensionInfo($name);
  24796. if (preg_match('/^librabbitmq version => (?<version>.+)$/im', $info, $librabbitmqMatches)) {
  24797. $this->addLibrary($name.'-librabbitmq', $librabbitmqMatches['version'], 'AMQP librabbitmq version');
  24798. }
  24799. if (preg_match('/^AMQP protocol version => (?<version>.+)$/im', $info, $protocolMatches)) {
  24800. $this->addLibrary($name.'-protocol', str_replace('-', '.', $protocolMatches['version']), 'AMQP protocol version');
  24801. }
  24802. break;
  24803. case 'bz2':
  24804. $info = $this->runtime->getExtensionInfo($name);
  24805. if (preg_match('/^BZip2 Version => (?<version>.*),/im', $info, $matches)) {
  24806. $this->addLibrary($name, $matches['version']);
  24807. }
  24808. break;
  24809. case 'curl':
  24810. $curlVersion = $this->runtime->invoke('curl_version');
  24811. $this->addLibrary($name, $curlVersion['version']);
  24812. $info = $this->runtime->getExtensionInfo($name);
  24813. if (preg_match('{^SSL Version => (?<library>[^/]+)/(?<version>.+)$}im', $info, $sslMatches)) {
  24814. $library = strtolower($sslMatches['library']);
  24815. if ($library === 'openssl') {
  24816. $parsedVersion = Version::parseOpenssl($sslMatches['version'], $isFips);
  24817. $this->addLibrary($name.'-openssl'.($isFips ? '-fips' : ''), $parsedVersion, 'curl OpenSSL version ('.$parsedVersion.')', array(), $isFips ? array('curl-openssl') : array());
  24818. } else {
  24819. $this->addLibrary($name.'-'.$library, $sslMatches['version'], 'curl '.$library.' version ('.$sslMatches['version'].')', array('curl-openssl'));
  24820. }
  24821. }
  24822. if (preg_match('{^libSSH Version => (?<library>[^/]+)/(?<version>.+?)(?:/.*)?$}im', $info, $sshMatches)) {
  24823. $this->addLibrary($name.'-'.strtolower($sshMatches['library']), $sshMatches['version'], 'curl '.$sshMatches['library'].' version');
  24824. }
  24825. if (preg_match('{^ZLib Version => (?<version>.+)$}im', $info, $zlibMatches)) {
  24826. $this->addLibrary($name.'-zlib', $zlibMatches['version'], 'curl zlib version');
  24827. }
  24828. break;
  24829. case 'date':
  24830. $info = $this->runtime->getExtensionInfo($name);
  24831. if (preg_match('/^timelib version => (?<version>.+)$/im', $info, $timelibMatches)) {
  24832. $this->addLibrary($name.'-timelib', $timelibMatches['version'], 'date timelib version');
  24833. }
  24834. if (preg_match('/^Timezone Database => (?<source>internal|external)$/im', $info, $zoneinfoSourceMatches)) {
  24835. $external = $zoneinfoSourceMatches['source'] === 'external';
  24836. if (preg_match('/^"Olson" Timezone Database Version => (?<version>.+?)(\.system)?$/im', $info, $zoneinfoMatches)) {
  24837. if ($external && in_array('timezonedb', $loadedExtensions, true)) {
  24838. $this->addLibrary('timezonedb-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date (replaced by timezonedb)', array($name.'-zoneinfo'));
  24839. } else {
  24840. $this->addLibrary($name.'-zoneinfo', $zoneinfoMatches['version'], 'zoneinfo ("Olson") database for date');
  24841. }
  24842. }
  24843. }
  24844. break;
  24845. case 'fileinfo':
  24846. $info = $this->runtime->getExtensionInfo($name);
  24847. if (preg_match('/^libmagic => (?<version>.+)$/im', $info, $magicMatches)) {
  24848. $this->addLibrary($name.'-libmagic', $magicMatches['version'], 'fileinfo libmagic version');
  24849. }
  24850. break;
  24851. case 'gd':
  24852. $this->addLibrary($name, $this->runtime->getConstant('GD_VERSION'));
  24853. $info = $this->runtime->getExtensionInfo($name);
  24854. if (preg_match('/^libJPEG Version => (?<version>.+?)(?: compatible)?$/im', $info, $libjpegMatches)) {
  24855. $this->addLibrary($name.'-libjpeg', Version::parseLibjpeg($libjpegMatches['version']), 'libjpeg version for gd');
  24856. }
  24857. if (preg_match('/^libPNG Version => (?<version>.+)$/im', $info, $libpngMatches)) {
  24858. $this->addLibrary($name.'-libpng', $libpngMatches['version'], 'libpng version for gd');
  24859. }
  24860. if (preg_match('/^FreeType Version => (?<version>.+)$/im', $info, $freetypeMatches)) {
  24861. $this->addLibrary($name.'-freetype', $freetypeMatches['version'], 'freetype version for gd');
  24862. }
  24863. if (preg_match('/^libXpm Version => (?<versionId>\d+)$/im', $info, $libxpmMatches)) {
  24864. $this->addLibrary($name.'-libxpm', Version::convertLibxpmVersionId($libxpmMatches['versionId']), 'libxpm version for gd');
  24865. }
  24866. break;
  24867. case 'gmp':
  24868. $this->addLibrary($name, $this->runtime->getConstant('GMP_VERSION'));
  24869. break;
  24870. case 'iconv':
  24871. $this->addLibrary($name, $this->runtime->getConstant('ICONV_VERSION'));
  24872. break;
  24873. case 'intl':
  24874. $info = $this->runtime->getExtensionInfo($name);
  24875. $description = 'The ICU unicode and globalization support library';
  24876. if ($this->runtime->hasConstant('INTL_ICU_VERSION')) {
  24877. $this->addLibrary('icu', $this->runtime->getConstant('INTL_ICU_VERSION'), $description);
  24878. } elseif (preg_match('/^ICU version => (?<version>.+)$/im', $info, $matches)) {
  24879. $this->addLibrary('icu', $matches['version'], $description);
  24880. }
  24881. if (preg_match('/^ICU TZData version => (?<version>.*)$/im', $info, $zoneinfoMatches)) {
  24882. $this->addLibrary('icu-zoneinfo', Version::parseZoneinfoVersion($zoneinfoMatches['version']), 'zoneinfo ("Olson") database for icu');
  24883. }
  24884. if ($this->runtime->hasClass('ResourceBundle')) {
  24885. $cldrVersion = $this->runtime->invoke(array('ResourceBundle', 'create'), array('root', 'ICUDATA', false))->get('Version');
  24886. $this->addLibrary('icu-cldr', $cldrVersion, 'ICU CLDR project version');
  24887. }
  24888. if ($this->runtime->hasClass('IntlChar')) {
  24889. $this->addLibrary('icu-unicode', implode('.', array_slice($this->runtime->invoke(array('IntlChar', 'getUnicodeVersion')), 0, 3)), 'ICU unicode version');
  24890. }
  24891. break;
  24892. case 'imagick':
  24893. $imageMagickVersion = $this->runtime->construct('Imagick')->getVersion();
  24894. preg_match('/^ImageMagick (?<version>[\d.]+)(?:-(?<patch>\d+))?/', $imageMagickVersion['versionString'], $matches);
  24895. $version = $matches['version'];
  24896. if (isset($matches['patch'])) {
  24897. $version .= '.'.$matches['patch'];
  24898. }
  24899. $this->addLibrary($name.'-imagemagick', $version, null, array('imagick'));
  24900. break;
  24901. case 'ldap':
  24902. $info = $this->runtime->getExtensionInfo($name);
  24903. if (preg_match('/^Vendor Version => (?<versionId>\d+)$/im', $info, $matches) && preg_match('/^Vendor Name => (?<vendor>.+)$/im', $info, $vendorMatches)) {
  24904. $this->addLibrary($name.'-'.strtolower($vendorMatches['vendor']), Version::convertOpenldapVersionId($matches['versionId']), $vendorMatches['vendor'].' version of ldap');
  24905. }
  24906. break;
  24907. case 'libxml':
  24908. $libxmlProvides = array_map(function ($extension) {
  24909. return $extension . '-libxml';
  24910. }, array_intersect($loadedExtensions, array('dom', 'simplexml', 'xml', 'xmlreader', 'xmlwriter')));
  24911. $this->addLibrary($name, $this->runtime->getConstant('LIBXML_DOTTED_VERSION'), 'libxml library version', array(), $libxmlProvides);
  24912. break;
  24913. case 'mbstring':
  24914. $info = $this->runtime->getExtensionInfo($name);
  24915. if (preg_match('/^libmbfl version => (?<version>.+)$/im', $info, $libmbflMatches)) {
  24916. $this->addLibrary($name.'-libmbfl', $libmbflMatches['version'], 'mbstring libmbfl version');
  24917. }
  24918. if ($this->runtime->hasConstant('MB_ONIGURUMA_VERSION')) {
  24919. $this->addLibrary($name.'-oniguruma', $this->runtime->getConstant('MB_ONIGURUMA_VERSION'), 'mbstring oniguruma version');
  24920. } elseif (preg_match('/^(?:oniguruma|Multibyte regex \(oniguruma\)) version => (?<version>.+)$/im', $info, $onigurumaMatches)) {
  24921. $this->addLibrary($name.'-oniguruma', $onigurumaMatches['version'], 'mbstring oniguruma version');
  24922. }
  24923. break;
  24924. case 'memcached':
  24925. $info = $this->runtime->getExtensionInfo($name);
  24926. if (preg_match('/^libmemcached version => (?<version>.+)$/im', $info, $matches)) {
  24927. $this->addLibrary($name.'-libmemcached', $matches['version'], 'libmemcached version');
  24928. }
  24929. break;
  24930. case 'openssl':
  24931. if (preg_match('{^(?:OpenSSL|LibreSSL)?\s*(?<version>\S+)}i', $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), $matches)) {
  24932. $parsedVersion = Version::parseOpenssl($matches['version'], $isFips);
  24933. $this->addLibrary($name.($isFips ? '-fips' : ''), $parsedVersion, $this->runtime->getConstant('OPENSSL_VERSION_TEXT'), array(), $isFips ? array($name) : array());
  24934. }
  24935. break;
  24936. case 'pcre':
  24937. $this->addLibrary($name, preg_replace('{^(\S+).*}', '$1', $this->runtime->getConstant('PCRE_VERSION')));
  24938. $info = $this->runtime->getExtensionInfo($name);
  24939. if (preg_match('/^PCRE Unicode Version => (?<version>.+)$/im', $info, $pcreUnicodeMatches)) {
  24940. $this->addLibrary($name.'-unicode', $pcreUnicodeMatches['version'], 'PCRE Unicode version support');
  24941. }
  24942. break;
  24943. case 'mysqlnd':
  24944. case 'pdo_mysql':
  24945. $info = $this->runtime->getExtensionInfo($name);
  24946. if (preg_match('/^(?:Client API version|Version) => mysqlnd (?<version>.+?) /mi', $info, $matches)) {
  24947. $this->addLibrary($name.'-mysqlnd', $matches['version'], 'mysqlnd library version for '.$name);
  24948. }
  24949. break;
  24950. case 'mongodb':
  24951. $info = $this->runtime->getExtensionInfo($name);
  24952. if (preg_match('/^libmongoc bundled version => (?<version>.+)$/im', $info, $libmongocMatches)) {
  24953. $this->addLibrary($name.'-libmongoc', $libmongocMatches['version'], 'libmongoc version of mongodb');
  24954. }
  24955. if (preg_match('/^libbson bundled version => (?<version>.+)$/im', $info, $libbsonMatches)) {
  24956. $this->addLibrary($name.'-libbson', $libbsonMatches['version'], 'libbson version of mongodb');
  24957. }
  24958. break;
  24959. case 'pgsql':
  24960. case 'pdo_pgsql':
  24961. $info = $this->runtime->getExtensionInfo($name);
  24962. if (preg_match('/^PostgreSQL\(libpq\) Version => (?<version>.*)$/im', $info, $matches)) {
  24963. $this->addLibrary($name.'-libpq', $matches['version'], 'libpq for '.$name);
  24964. }
  24965. break;
  24966. case 'libsodium':
  24967. case 'sodium':
  24968. $this->addLibrary('libsodium', $this->runtime->getConstant('SODIUM_LIBRARY_VERSION'));
  24969. break;
  24970. case 'sqlite3':
  24971. case 'pdo_sqlite':
  24972. $info = $this->runtime->getExtensionInfo($name);
  24973. if (preg_match('/^SQLite Library => (?<version>.+)$/im', $info, $matches)) {
  24974. $this->addLibrary($name.'-sqlite', $matches['version']);
  24975. }
  24976. break;
  24977. case 'ssh2':
  24978. $info = $this->runtime->getExtensionInfo($name);
  24979. if (preg_match('/^libssh2 version => (?<version>.+)$/im', $info, $matches)) {
  24980. $this->addLibrary($name.'-libssh2', $matches['version']);
  24981. }
  24982. break;
  24983. case 'xsl':
  24984. $this->addLibrary('libxslt', $this->runtime->getConstant('LIBXSLT_DOTTED_VERSION'), null, array('xsl'));
  24985. $info = $this->runtime->getExtensionInfo('xsl');
  24986. if (preg_match('/^libxslt compiled against libxml Version => (?<version>.+)$/im', $info, $matches)) {
  24987. $this->addLibrary('libxslt-libxml', $matches['version'], 'libxml version libxslt is compiled against');
  24988. }
  24989. break;
  24990. case 'yaml':
  24991. $info = $this->runtime->getExtensionInfo('yaml');
  24992. if (preg_match('/^LibYAML Version => (?<version>.+)$/im', $info, $matches)) {
  24993. $this->addLibrary($name.'-libyaml', $matches['version'], 'libyaml version of yaml');
  24994. }
  24995. break;
  24996. case 'zip':
  24997. if ($this->runtime->hasConstant('LIBZIP_VERSION', 'ZipArchive')) {
  24998. $this->addLibrary($name.'-libzip', $this->runtime->getConstant('LIBZIP_VERSION', 'ZipArchive'), null, array('zip'));
  24999. }
  25000. break;
  25001. case 'zlib':
  25002. if ($this->runtime->hasConstant('ZLIB_VERSION')) {
  25003. $this->addLibrary($name, $this->runtime->getConstant('ZLIB_VERSION'));
  25004. } elseif (preg_match('/^Linked Version => (?<version>.+)$/im', $this->runtime->getExtensionInfo($name), $matches)) {
  25005. $this->addLibrary($name, $matches['version']);
  25006. }
  25007. break;
  25008. default:
  25009. break;
  25010. }
  25011. }
  25012. $hhvmVersion = $this->hhvmDetector->getVersion();
  25013. if ($hhvmVersion) {
  25014. try {
  25015. $prettyVersion = $hhvmVersion;
  25016. $version = $this->versionParser->normalize($prettyVersion);
  25017. } catch (\UnexpectedValueException $e) {
  25018. $prettyVersion = preg_replace('#^([^~+-]+).*$#', '$1', $hhvmVersion);
  25019. $version = $this->versionParser->normalize($prettyVersion);
  25020. }
  25021. $hhvm = new CompletePackage('hhvm', $version, $prettyVersion);
  25022. $hhvm->setDescription('The HHVM Runtime (64bit)');
  25023. $this->addPackage($hhvm);
  25024. }
  25025. }
  25026. public function addPackage(PackageInterface $package)
  25027. {
  25028. if (isset($this->overrides[$package->getName()])) {
  25029. $overrider = $this->findPackage($package->getName(), '*');
  25030. if ($package->getVersion() === $overrider->getVersion()) {
  25031. $actualText = 'same as actual';
  25032. } else {
  25033. $actualText = 'actual: '.$package->getPrettyVersion();
  25034. }
  25035. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  25036. return;
  25037. }
  25038. if (isset($this->overrides['php']) && 0 === strpos($package->getName(), 'php-')) {
  25039. $overrider = $this->addOverriddenPackage($this->overrides['php'], $package->getPrettyName());
  25040. if ($package->getVersion() === $overrider->getVersion()) {
  25041. $actualText = 'same as actual';
  25042. } else {
  25043. $actualText = 'actual: '.$package->getPrettyVersion();
  25044. }
  25045. $overrider->setDescription($overrider->getDescription().', '.$actualText);
  25046. return;
  25047. }
  25048. parent::addPackage($package);
  25049. }
  25050. private function addOverriddenPackage(array $override, $name = null)
  25051. {
  25052. $version = $this->versionParser->normalize($override['version']);
  25053. $package = new CompletePackage($name ?: $override['name'], $version, $override['version']);
  25054. $package->setDescription('Package overridden via config.platform');
  25055. $package->setExtra(array('config.platform' => true));
  25056. parent::addPackage($package);
  25057. return $package;
  25058. }
  25059. private function addExtension($name, $prettyVersion)
  25060. {
  25061. $extraDescription = null;
  25062. try {
  25063. $version = $this->versionParser->normalize($prettyVersion);
  25064. } catch (\UnexpectedValueException $e) {
  25065. $extraDescription = ' (actual version: '.$prettyVersion.')';
  25066. if (preg_match('{^(\d+\.\d+\.\d+(?:\.\d+)?)}', $prettyVersion, $match)) {
  25067. $prettyVersion = $match[1];
  25068. } else {
  25069. $prettyVersion = '0';
  25070. }
  25071. $version = $this->versionParser->normalize($prettyVersion);
  25072. }
  25073. $packageName = $this->buildPackageName($name);
  25074. $ext = new CompletePackage($packageName, $version, $prettyVersion);
  25075. $ext->setDescription('The '.$name.' PHP extension'.$extraDescription);
  25076. if ($name === 'uuid') {
  25077. $ext->setReplaces(array(
  25078. new Link('ext-uuid', 'lib-uuid', new Constraint('=', $version), Link::TYPE_REPLACE, $ext->getPrettyVersion()),
  25079. ));
  25080. }
  25081. $this->addPackage($ext);
  25082. }
  25083. private function buildPackageName($name)
  25084. {
  25085. return 'ext-' . str_replace(' ', '-', strtolower($name));
  25086. }
  25087. private function addLibrary($name, $prettyVersion, $description = null, array $replaces = array(), array $provides = array())
  25088. {
  25089. try {
  25090. $version = $this->versionParser->normalize($prettyVersion);
  25091. } catch (\UnexpectedValueException $e) {
  25092. return;
  25093. }
  25094. if ($description === null) {
  25095. $description = 'The '.$name.' library';
  25096. }
  25097. $lib = new CompletePackage('lib-'.$name, $version, $prettyVersion);
  25098. $lib->setDescription($description);
  25099. $links = function ($alias) use ($name, $version, $lib) {
  25100. return new Link('lib-'.$name, 'lib-'.$alias, new Constraint('=', $version), Link::TYPE_REPLACE, $lib->getPrettyVersion());
  25101. };
  25102. $lib->setReplaces(array_map($links, $replaces));
  25103. $lib->setProvides(array_map($links, $provides));
  25104. $this->addPackage($lib);
  25105. }
  25106. public static function isPlatformPackage($name)
  25107. {
  25108. static $cache = array();
  25109. if (isset($cache[$name])) {
  25110. return $cache[$name];
  25111. }
  25112. return $cache[$name] = (bool) preg_match(PlatformRepository::PLATFORM_PACKAGE_REGEX, $name);
  25113. }
  25114. }
  25115. <?php
  25116. namespace Composer\Repository;
  25117. use Composer\Factory;
  25118. use Composer\IO\IOInterface;
  25119. use Composer\Config;
  25120. use Composer\EventDispatcher\EventDispatcher;
  25121. use Composer\Util\HttpDownloader;
  25122. use Composer\Util\ProcessExecutor;
  25123. use Composer\Json\JsonFile;
  25124. class RepositoryFactory
  25125. {
  25126. public static function configFromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false)
  25127. {
  25128. if (0 === strpos($repository, 'http')) {
  25129. $repoConfig = array('type' => 'composer', 'url' => $repository);
  25130. } elseif ("json" === pathinfo($repository, PATHINFO_EXTENSION)) {
  25131. $json = new JsonFile($repository, Factory::createHttpDownloader($io, $config));
  25132. $data = $json->read();
  25133. if (!empty($data['packages']) || !empty($data['includes']) || !empty($data['provider-includes'])) {
  25134. $repoConfig = array('type' => 'composer', 'url' => 'file://' . strtr(realpath($repository), '\\', '/'));
  25135. } elseif ($allowFilesystem) {
  25136. $repoConfig = array('type' => 'filesystem', 'json' => $json);
  25137. } else {
  25138. throw new \InvalidArgumentException("Invalid repository URL ($repository) given. This file does not contain a valid composer repository.");
  25139. }
  25140. } elseif (strpos($repository, '{') === 0) {
  25141. $repoConfig = JsonFile::parseJson($repository);
  25142. } else {
  25143. throw new \InvalidArgumentException("Invalid repository url ($repository) given. Has to be a .json file, an http url or a JSON object.");
  25144. }
  25145. return $repoConfig;
  25146. }
  25147. public static function fromString(IOInterface $io, Config $config, $repository, $allowFilesystem = false, RepositoryManager $rm = null)
  25148. {
  25149. $repoConfig = static::configFromString($io, $config, $repository, $allowFilesystem);
  25150. return static::createRepo($io, $config, $repoConfig, $rm);
  25151. }
  25152. public static function createRepo(IOInterface $io, Config $config, array $repoConfig, RepositoryManager $rm = null)
  25153. {
  25154. if (!$rm) {
  25155. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  25156. }
  25157. $repos = static::createRepos($rm, array($repoConfig));
  25158. return reset($repos);
  25159. }
  25160. public static function defaultRepos(IOInterface $io = null, Config $config = null, RepositoryManager $rm = null)
  25161. {
  25162. if (!$config) {
  25163. $config = Factory::createConfig($io);
  25164. }
  25165. if ($io) {
  25166. $io->loadConfiguration($config);
  25167. }
  25168. if (!$rm) {
  25169. if (!$io) {
  25170. throw new \InvalidArgumentException('This function requires either an IOInterface or a RepositoryManager');
  25171. }
  25172. $rm = static::manager($io, $config, Factory::createHttpDownloader($io, $config));
  25173. }
  25174. return static::createRepos($rm, $config->getRepositories());
  25175. }
  25176. public static function manager(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  25177. {
  25178. $rm = new RepositoryManager($io, $config, $httpDownloader, $eventDispatcher, $process);
  25179. $rm->setRepositoryClass('composer', 'Composer\Repository\ComposerRepository');
  25180. $rm->setRepositoryClass('vcs', 'Composer\Repository\VcsRepository');
  25181. $rm->setRepositoryClass('package', 'Composer\Repository\PackageRepository');
  25182. $rm->setRepositoryClass('pear', 'Composer\Repository\PearRepository');
  25183. $rm->setRepositoryClass('git', 'Composer\Repository\VcsRepository');
  25184. $rm->setRepositoryClass('git-bitbucket', 'Composer\Repository\VcsRepository');
  25185. $rm->setRepositoryClass('github', 'Composer\Repository\VcsRepository');
  25186. $rm->setRepositoryClass('gitlab', 'Composer\Repository\VcsRepository');
  25187. $rm->setRepositoryClass('svn', 'Composer\Repository\VcsRepository');
  25188. $rm->setRepositoryClass('fossil', 'Composer\Repository\VcsRepository');
  25189. $rm->setRepositoryClass('perforce', 'Composer\Repository\VcsRepository');
  25190. $rm->setRepositoryClass('hg', 'Composer\Repository\VcsRepository');
  25191. $rm->setRepositoryClass('hg-bitbucket', 'Composer\Repository\VcsRepository');
  25192. $rm->setRepositoryClass('artifact', 'Composer\Repository\ArtifactRepository');
  25193. $rm->setRepositoryClass('path', 'Composer\Repository\PathRepository');
  25194. return $rm;
  25195. }
  25196. private static function createRepos(RepositoryManager $rm, array $repoConfigs)
  25197. {
  25198. $repos = array();
  25199. foreach ($repoConfigs as $index => $repo) {
  25200. if (is_string($repo)) {
  25201. throw new \UnexpectedValueException('"repositories" should be an array of repository definitions, only a single repository was given');
  25202. }
  25203. if (!is_array($repo)) {
  25204. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') should be an array, '.gettype($repo).' given');
  25205. }
  25206. if (!isset($repo['type'])) {
  25207. throw new \UnexpectedValueException('Repository "'.$index.'" ('.json_encode($repo).') must have a type defined');
  25208. }
  25209. $name = self::generateRepositoryName($index, $repo, $repos);
  25210. if ($repo['type'] === 'filesystem') {
  25211. $repos[$name] = new FilesystemRepository($repo['json']);
  25212. } else {
  25213. $repos[$name] = $rm->createRepository($repo['type'], $repo, $index);
  25214. }
  25215. }
  25216. return $repos;
  25217. }
  25218. public static function generateRepositoryName($index, array $repo, array $existingRepos)
  25219. {
  25220. $name = is_int($index) && isset($repo['url']) ? preg_replace('{^https?://}i', '', $repo['url']) : $index;
  25221. while (isset($existingRepos[$name])) {
  25222. $name .= '2';
  25223. }
  25224. return $name;
  25225. }
  25226. }
  25227. <?php
  25228. namespace Composer\Repository;
  25229. use Composer\Package\PackageInterface;
  25230. use Composer\Package\BasePackage;
  25231. use Composer\Semver\Constraint\ConstraintInterface;
  25232. interface RepositoryInterface extends \Countable
  25233. {
  25234. const SEARCH_FULLTEXT = 0;
  25235. const SEARCH_NAME = 1;
  25236. public function hasPackage(PackageInterface $package);
  25237. public function findPackage($name, $constraint);
  25238. public function findPackages($name, $constraint = null);
  25239. public function getPackages();
  25240. public function loadPackages(array $packageNameMap, array $acceptableStabilities, array $stabilityFlags, array $alreadyLoaded = array());
  25241. public function search($query, $mode = 0, $type = null);
  25242. public function getProviders($packageName);
  25243. public function getRepoName();
  25244. }
  25245. <?php
  25246. namespace Composer\Repository;
  25247. use Composer\IO\IOInterface;
  25248. use Composer\Config;
  25249. use Composer\EventDispatcher\EventDispatcher;
  25250. use Composer\Package\PackageInterface;
  25251. use Composer\Util\HttpDownloader;
  25252. use Composer\Util\ProcessExecutor;
  25253. class RepositoryManager
  25254. {
  25255. private $localRepository;
  25256. private $repositories = array();
  25257. private $repositoryClasses = array();
  25258. private $io;
  25259. private $config;
  25260. private $httpDownloader;
  25261. private $eventDispatcher;
  25262. private $process;
  25263. public function __construct(IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $eventDispatcher = null, ProcessExecutor $process = null)
  25264. {
  25265. $this->io = $io;
  25266. $this->config = $config;
  25267. $this->httpDownloader = $httpDownloader;
  25268. $this->eventDispatcher = $eventDispatcher;
  25269. $this->process = $process ?: new ProcessExecutor($io);
  25270. }
  25271. public function findPackage($name, $constraint)
  25272. {
  25273. foreach ($this->repositories as $repository) {
  25274. if ($package = $repository->findPackage($name, $constraint)) {
  25275. return $package;
  25276. }
  25277. }
  25278. return null;
  25279. }
  25280. public function findPackages($name, $constraint)
  25281. {
  25282. $packages = array();
  25283. foreach ($this->getRepositories() as $repository) {
  25284. $packages = array_merge($packages, $repository->findPackages($name, $constraint));
  25285. }
  25286. return $packages;
  25287. }
  25288. public function addRepository(RepositoryInterface $repository)
  25289. {
  25290. $this->repositories[] = $repository;
  25291. }
  25292. public function prependRepository(RepositoryInterface $repository)
  25293. {
  25294. array_unshift($this->repositories, $repository);
  25295. }
  25296. public function createRepository($type, $config, $name = null)
  25297. {
  25298. if (!isset($this->repositoryClasses[$type])) {
  25299. throw new \InvalidArgumentException('Repository type is not registered: '.$type);
  25300. }
  25301. if (isset($config['packagist']) && false === $config['packagist']) {
  25302. $this->io->writeError('<warning>Repository "'.$name.'" ('.json_encode($config).') has a packagist key which should be in its own repository definition</warning>');
  25303. }
  25304. $class = $this->repositoryClasses[$type];
  25305. if (isset($config['only']) || isset($config['exclude']) || isset($config['canonical'])) {
  25306. $filterConfig = $config;
  25307. unset($config['only'], $config['exclude'], $config['canonical']);
  25308. }
  25309. $repository = new $class($config, $this->io, $this->config, $this->httpDownloader, $this->eventDispatcher, $this->process);
  25310. if (isset($filterConfig)) {
  25311. $repository = new FilterRepository($repository, $filterConfig);
  25312. }
  25313. return $repository;
  25314. }
  25315. public function setRepositoryClass($type, $class)
  25316. {
  25317. $this->repositoryClasses[$type] = $class;
  25318. }
  25319. public function getRepositories()
  25320. {
  25321. return $this->repositories;
  25322. }
  25323. public function setLocalRepository(InstalledRepositoryInterface $repository)
  25324. {
  25325. $this->localRepository = $repository;
  25326. }
  25327. public function getLocalRepository()
  25328. {
  25329. return $this->localRepository;
  25330. }
  25331. }
  25332. <?php
  25333. namespace Composer\Repository;
  25334. class RepositorySecurityException extends \Exception
  25335. {
  25336. }
  25337. <?php
  25338. namespace Composer\Repository;
  25339. use Composer\DependencyResolver\Pool;
  25340. use Composer\DependencyResolver\PoolBuilder;
  25341. use Composer\DependencyResolver\Request;
  25342. use Composer\EventDispatcher\EventDispatcher;
  25343. use Composer\IO\IOInterface;
  25344. use Composer\IO\NullIO;
  25345. use Composer\Package\BasePackage;
  25346. use Composer\Package\AliasPackage;
  25347. use Composer\Semver\Constraint\ConstraintInterface;
  25348. use Composer\Package\Version\StabilityFilter;
  25349. class RepositorySet
  25350. {
  25351. const ALLOW_UNACCEPTABLE_STABILITIES = 1;
  25352. const ALLOW_SHADOWED_REPOSITORIES = 2;
  25353. private $rootAliases;
  25354. private $rootReferences;
  25355. private $repositories = array();
  25356. private $acceptableStabilities;
  25357. private $stabilityFlags;
  25358. private $rootRequires;
  25359. private $locked = false;
  25360. private $allowInstalledRepositories = false;
  25361. public function __construct($minimumStability = 'stable', array $stabilityFlags = array(), array $rootAliases = array(), array $rootReferences = array(), array $rootRequires = array())
  25362. {
  25363. $this->rootAliases = self::getRootAliasesPerPackage($rootAliases);
  25364. $this->rootReferences = $rootReferences;
  25365. $this->acceptableStabilities = array();
  25366. foreach (BasePackage::$stabilities as $stability => $value) {
  25367. if ($value <= BasePackage::$stabilities[$minimumStability]) {
  25368. $this->acceptableStabilities[$stability] = $value;
  25369. }
  25370. }
  25371. $this->stabilityFlags = $stabilityFlags;
  25372. $this->rootRequires = $rootRequires;
  25373. foreach ($rootRequires as $name => $constraint) {
  25374. if (PlatformRepository::isPlatformPackage($name)) {
  25375. unset($this->rootRequires[$name]);
  25376. }
  25377. }
  25378. }
  25379. public function allowInstalledRepositories($allow = true)
  25380. {
  25381. $this->allowInstalledRepositories = $allow;
  25382. }
  25383. public function getRootRequires()
  25384. {
  25385. return $this->rootRequires;
  25386. }
  25387. public function addRepository(RepositoryInterface $repo)
  25388. {
  25389. if ($this->locked) {
  25390. throw new \RuntimeException("Pool has already been created from this repository set, it cannot be modified anymore.");
  25391. }
  25392. if ($repo instanceof CompositeRepository) {
  25393. $repos = $repo->getRepositories();
  25394. } else {
  25395. $repos = array($repo);
  25396. }
  25397. foreach ($repos as $repo) {
  25398. $this->repositories[] = $repo;
  25399. }
  25400. }
  25401. public function findPackages($name, ConstraintInterface $constraint = null, $flags = 0)
  25402. {
  25403. $ignoreStability = ($flags & self::ALLOW_UNACCEPTABLE_STABILITIES) !== 0;
  25404. $loadFromAllRepos = ($flags & self::ALLOW_SHADOWED_REPOSITORIES) !== 0;
  25405. $packages = array();
  25406. if ($loadFromAllRepos) {
  25407. foreach ($this->repositories as $repository) {
  25408. $packages[] = $repository->findPackages($name, $constraint) ?: array();
  25409. }
  25410. } else {
  25411. foreach ($this->repositories as $repository) {
  25412. $result = $repository->loadPackages(array($name => $constraint), $ignoreStability ? BasePackage::$stabilities : $this->acceptableStabilities, $ignoreStability ? array() : $this->stabilityFlags);
  25413. $packages[] = $result['packages'];
  25414. foreach ($result['namesFound'] as $nameFound) {
  25415. if ($name === $nameFound) {
  25416. break 2;
  25417. }
  25418. }
  25419. }
  25420. }
  25421. $candidates = $packages ? call_user_func_array('array_merge', $packages) : array();
  25422. if ($ignoreStability || !$loadFromAllRepos) {
  25423. return $candidates;
  25424. }
  25425. $result = array();
  25426. foreach ($candidates as $candidate) {
  25427. if ($this->isPackageAcceptable($candidate->getNames(), $candidate->getStability())) {
  25428. $result[] = $candidate;
  25429. }
  25430. }
  25431. return $result;
  25432. }
  25433. public function getProviders($packageName)
  25434. {
  25435. $providers = array();
  25436. foreach ($this->repositories as $repository) {
  25437. if ($repoProviders = $repository->getProviders($packageName)) {
  25438. $providers = array_merge($providers, $repoProviders);
  25439. }
  25440. }
  25441. return $providers;
  25442. }
  25443. public function isPackageAcceptable($names, $stability)
  25444. {
  25445. return StabilityFilter::isPackageAcceptable($this->acceptableStabilities, $this->stabilityFlags, $names, $stability);
  25446. }
  25447. public function createPool(Request $request, IOInterface $io, EventDispatcher $eventDispatcher = null)
  25448. {
  25449. $poolBuilder = new PoolBuilder($this->acceptableStabilities, $this->stabilityFlags, $this->rootAliases, $this->rootReferences, $io, $eventDispatcher);
  25450. foreach ($this->repositories as $repo) {
  25451. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  25452. throw new \LogicException('The pool can not accept packages from an installed repository');
  25453. }
  25454. }
  25455. $this->locked = true;
  25456. return $poolBuilder->buildPool($this->repositories, $request);
  25457. }
  25458. public function createPoolWithAllPackages()
  25459. {
  25460. foreach ($this->repositories as $repo) {
  25461. if (($repo instanceof InstalledRepositoryInterface || $repo instanceof InstalledRepository) && !$this->allowInstalledRepositories) {
  25462. throw new \LogicException('The pool can not accept packages from an installed repository');
  25463. }
  25464. }
  25465. $this->locked = true;
  25466. $packages = array();
  25467. foreach ($this->repositories as $repository) {
  25468. foreach ($repository->getPackages() as $package) {
  25469. $packages[] = $package;
  25470. if (isset($this->rootAliases[$package->getName()][$package->getVersion()])) {
  25471. $alias = $this->rootAliases[$package->getName()][$package->getVersion()];
  25472. while ($package instanceof AliasPackage) {
  25473. $package = $package->getAliasOf();
  25474. }
  25475. $aliasPackage = new AliasPackage($package, $alias['alias_normalized'], $alias['alias']);
  25476. $aliasPackage->setRootPackageAlias(true);
  25477. $packages[] = $aliasPackage;
  25478. }
  25479. }
  25480. }
  25481. return new Pool($packages);
  25482. }
  25483. public function createPoolForPackage($packageName, LockArrayRepository $lockedRepo = null)
  25484. {
  25485. return $this->createPoolForPackages(array($packageName), $lockedRepo);
  25486. }
  25487. public function createPoolForPackages($packageNames, LockArrayRepository $lockedRepo = null)
  25488. {
  25489. $request = new Request($lockedRepo);
  25490. foreach ($packageNames as $packageName) {
  25491. if (PlatformRepository::isPlatformPackage($packageName)) {
  25492. 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.');
  25493. }
  25494. $request->requireName($packageName);
  25495. }
  25496. return $this->createPool($request, new NullIO());
  25497. }
  25498. private static function getRootAliasesPerPackage(array $aliases)
  25499. {
  25500. $normalizedAliases = array();
  25501. foreach ($aliases as $alias) {
  25502. $normalizedAliases[$alias['package']][$alias['version']] = array(
  25503. 'alias' => $alias['alias'],
  25504. 'alias_normalized' => $alias['alias_normalized'],
  25505. );
  25506. }
  25507. return $normalizedAliases;
  25508. }
  25509. }
  25510. <?php
  25511. namespace Composer\Repository;
  25512. use Composer\Package\RootPackageInterface;
  25513. class RootPackageRepository extends ArrayRepository
  25514. {
  25515. public function __construct(RootPackageInterface $package)
  25516. {
  25517. parent::__construct(array($package));
  25518. }
  25519. public function getRepoName()
  25520. {
  25521. return 'root package repo';
  25522. }
  25523. }
  25524. <?php
  25525. namespace Composer\Repository\Vcs;
  25526. use Composer\Cache;
  25527. use Composer\Downloader\TransportException;
  25528. use Composer\Json\JsonFile;
  25529. use Composer\Util\Bitbucket;
  25530. use Composer\Util\Http\Response;
  25531. abstract class BitbucketDriver extends VcsDriver
  25532. {
  25533. protected $owner;
  25534. protected $repository;
  25535. protected $hasIssues;
  25536. protected $rootIdentifier;
  25537. protected $tags;
  25538. protected $branches;
  25539. protected $branchesUrl = '';
  25540. protected $tagsUrl = '';
  25541. protected $homeUrl = '';
  25542. protected $website = '';
  25543. protected $cloneHttpsUrl = '';
  25544. protected $fallbackDriver;
  25545. protected $vcsType;
  25546. public function initialize()
  25547. {
  25548. preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+?)(\.git|/?)$#i', $this->url, $match);
  25549. $this->owner = $match[1];
  25550. $this->repository = $match[2];
  25551. $this->originUrl = 'bitbucket.org';
  25552. $this->cache = new Cache(
  25553. $this->io,
  25554. implode('/', array(
  25555. $this->config->get('cache-repo-dir'),
  25556. $this->originUrl,
  25557. $this->owner,
  25558. $this->repository,
  25559. ))
  25560. );
  25561. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  25562. }
  25563. public function getUrl()
  25564. {
  25565. if ($this->fallbackDriver) {
  25566. return $this->fallbackDriver->getUrl();
  25567. }
  25568. return $this->cloneHttpsUrl;
  25569. }
  25570. protected function getRepoData()
  25571. {
  25572. $resource = sprintf(
  25573. 'https://api.bitbucket.org/2.0/repositories/%s/%s?%s',
  25574. $this->owner,
  25575. $this->repository,
  25576. http_build_query(
  25577. array('fields' => '-project,-owner'),
  25578. null,
  25579. '&'
  25580. )
  25581. );
  25582. $repoData = $this->fetchWithOAuthCredentials($resource, true)->decodeJson();
  25583. if ($this->fallbackDriver) {
  25584. return false;
  25585. }
  25586. $this->parseCloneUrls($repoData['links']['clone']);
  25587. $this->hasIssues = !empty($repoData['has_issues']);
  25588. $this->branchesUrl = $repoData['links']['branches']['href'];
  25589. $this->tagsUrl = $repoData['links']['tags']['href'];
  25590. $this->homeUrl = $repoData['links']['html']['href'];
  25591. $this->website = $repoData['website'];
  25592. $this->vcsType = $repoData['scm'];
  25593. return true;
  25594. }
  25595. public function getComposerInformation($identifier)
  25596. {
  25597. if ($this->fallbackDriver) {
  25598. return $this->fallbackDriver->getComposerInformation($identifier);
  25599. }
  25600. if (!isset($this->infoCache[$identifier])) {
  25601. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  25602. $composer = JsonFile::parseJson($res);
  25603. } else {
  25604. $composer = $this->getBaseComposerInformation($identifier);
  25605. if ($this->shouldCache($identifier)) {
  25606. $this->cache->write($identifier, json_encode($composer));
  25607. }
  25608. }
  25609. if ($composer) {
  25610. if (!isset($composer['support']['source'])) {
  25611. $label = array_search(
  25612. $identifier,
  25613. $this->getTags()
  25614. ) ?: array_search(
  25615. $identifier,
  25616. $this->getBranches()
  25617. ) ?: $identifier;
  25618. if (array_key_exists($label, $tags = $this->getTags())) {
  25619. $hash = $tags[$label];
  25620. } elseif (array_key_exists($label, $branches = $this->getBranches())) {
  25621. $hash = $branches[$label];
  25622. }
  25623. if (!isset($hash)) {
  25624. $composer['support']['source'] = sprintf(
  25625. 'https://%s/%s/%s/src',
  25626. $this->originUrl,
  25627. $this->owner,
  25628. $this->repository
  25629. );
  25630. } else {
  25631. $composer['support']['source'] = sprintf(
  25632. 'https://%s/%s/%s/src/%s/?at=%s',
  25633. $this->originUrl,
  25634. $this->owner,
  25635. $this->repository,
  25636. $hash,
  25637. $label
  25638. );
  25639. }
  25640. }
  25641. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  25642. $composer['support']['issues'] = sprintf(
  25643. 'https://%s/%s/%s/issues',
  25644. $this->originUrl,
  25645. $this->owner,
  25646. $this->repository
  25647. );
  25648. }
  25649. if (!isset($composer['homepage'])) {
  25650. $composer['homepage'] = empty($this->website) ? $this->homeUrl : $this->website;
  25651. }
  25652. }
  25653. $this->infoCache[$identifier] = $composer;
  25654. }
  25655. return $this->infoCache[$identifier];
  25656. }
  25657. public function getFileContent($file, $identifier)
  25658. {
  25659. if ($this->fallbackDriver) {
  25660. return $this->fallbackDriver->getFileContent($file, $identifier);
  25661. }
  25662. if (strpos($identifier, '/') !== false) {
  25663. $branches = $this->getBranches();
  25664. if (isset($branches[$identifier])) {
  25665. $identifier = $branches[$identifier];
  25666. }
  25667. }
  25668. $resource = sprintf(
  25669. 'https://api.bitbucket.org/2.0/repositories/%s/%s/src/%s/%s',
  25670. $this->owner,
  25671. $this->repository,
  25672. $identifier,
  25673. $file
  25674. );
  25675. return $this->fetchWithOAuthCredentials($resource)->getBody();
  25676. }
  25677. public function getChangeDate($identifier)
  25678. {
  25679. if ($this->fallbackDriver) {
  25680. return $this->fallbackDriver->getChangeDate($identifier);
  25681. }
  25682. if (strpos($identifier, '/') !== false) {
  25683. $branches = $this->getBranches();
  25684. if (isset($branches[$identifier])) {
  25685. $identifier = $branches[$identifier];
  25686. }
  25687. }
  25688. $resource = sprintf(
  25689. 'https://api.bitbucket.org/2.0/repositories/%s/%s/commit/%s?fields=date',
  25690. $this->owner,
  25691. $this->repository,
  25692. $identifier
  25693. );
  25694. $commit = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25695. return new \DateTime($commit['date']);
  25696. }
  25697. public function getSource($identifier)
  25698. {
  25699. if ($this->fallbackDriver) {
  25700. return $this->fallbackDriver->getSource($identifier);
  25701. }
  25702. return array('type' => $this->vcsType, 'url' => $this->getUrl(), 'reference' => $identifier);
  25703. }
  25704. public function getDist($identifier)
  25705. {
  25706. if ($this->fallbackDriver) {
  25707. return $this->fallbackDriver->getDist($identifier);
  25708. }
  25709. $url = sprintf(
  25710. 'https://bitbucket.org/%s/%s/get/%s.zip',
  25711. $this->owner,
  25712. $this->repository,
  25713. $identifier
  25714. );
  25715. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  25716. }
  25717. public function getTags()
  25718. {
  25719. if ($this->fallbackDriver) {
  25720. return $this->fallbackDriver->getTags();
  25721. }
  25722. if (null === $this->tags) {
  25723. $this->tags = array();
  25724. $resource = sprintf(
  25725. '%s?%s',
  25726. $this->tagsUrl,
  25727. http_build_query(
  25728. array(
  25729. 'pagelen' => 100,
  25730. 'fields' => 'values.name,values.target.hash,next',
  25731. 'sort' => '-target.date',
  25732. ),
  25733. null,
  25734. '&'
  25735. )
  25736. );
  25737. $hasNext = true;
  25738. while ($hasNext) {
  25739. $tagsData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25740. foreach ($tagsData['values'] as $data) {
  25741. $this->tags[$data['name']] = $data['target']['hash'];
  25742. }
  25743. if (empty($tagsData['next'])) {
  25744. $hasNext = false;
  25745. } else {
  25746. $resource = $tagsData['next'];
  25747. }
  25748. }
  25749. if ($this->vcsType === 'hg') {
  25750. unset($this->tags['tip']);
  25751. }
  25752. }
  25753. return $this->tags;
  25754. }
  25755. public function getBranches()
  25756. {
  25757. if ($this->fallbackDriver) {
  25758. return $this->fallbackDriver->getBranches();
  25759. }
  25760. if (null === $this->branches) {
  25761. $this->branches = array();
  25762. $resource = sprintf(
  25763. '%s?%s',
  25764. $this->branchesUrl,
  25765. http_build_query(
  25766. array(
  25767. 'pagelen' => 100,
  25768. 'fields' => 'values.name,values.target.hash,values.heads,next',
  25769. 'sort' => '-target.date',
  25770. ),
  25771. null,
  25772. '&'
  25773. )
  25774. );
  25775. $hasNext = true;
  25776. while ($hasNext) {
  25777. $branchData = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25778. foreach ($branchData['values'] as $data) {
  25779. if ($this->vcsType === 'hg' && empty($data['heads'])) {
  25780. continue;
  25781. }
  25782. $this->branches[$data['name']] = $data['target']['hash'];
  25783. }
  25784. if (empty($branchData['next'])) {
  25785. $hasNext = false;
  25786. } else {
  25787. $resource = $branchData['next'];
  25788. }
  25789. }
  25790. }
  25791. return $this->branches;
  25792. }
  25793. protected function fetchWithOAuthCredentials($url, $fetchingRepoData = false)
  25794. {
  25795. try {
  25796. return parent::getContents($url);
  25797. } catch (TransportException $e) {
  25798. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process, $this->httpDownloader);
  25799. if (403 === $e->getCode() || (401 === $e->getCode() && strpos($e->getMessage(), 'Could not authenticate against') === 0)) {
  25800. if (!$this->io->hasAuthentication($this->originUrl)
  25801. && $bitbucketUtil->authorizeOAuth($this->originUrl)
  25802. ) {
  25803. return parent::getContents($url);
  25804. }
  25805. if (!$this->io->isInteractive() && $fetchingRepoData) {
  25806. if ($this->attemptCloneFallback()) {
  25807. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  25808. }
  25809. }
  25810. }
  25811. throw $e;
  25812. }
  25813. }
  25814. abstract protected function generateSshUrl();
  25815. protected function attemptCloneFallback()
  25816. {
  25817. try {
  25818. $this->setupFallbackDriver($this->generateSshUrl());
  25819. return true;
  25820. } catch (\RuntimeException $e) {
  25821. $this->fallbackDriver = null;
  25822. $this->io->writeError(
  25823. '<error>Failed to clone the ' . $this->generateSshUrl() . ' repository, try running in interactive mode'
  25824. . ' so that you can enter your Bitbucket OAuth consumer credentials</error>'
  25825. );
  25826. throw $e;
  25827. }
  25828. }
  25829. abstract protected function setupFallbackDriver($url);
  25830. protected function parseCloneUrls(array $cloneLinks)
  25831. {
  25832. foreach ($cloneLinks as $cloneLink) {
  25833. if ($cloneLink['name'] === 'https') {
  25834. $this->cloneHttpsUrl = preg_replace('/https:\/\/([^@]+@)?/', 'https://', $cloneLink['href']);
  25835. }
  25836. }
  25837. }
  25838. protected function getMainBranchData()
  25839. {
  25840. $resource = sprintf(
  25841. 'https://api.bitbucket.org/2.0/repositories/%s/%s?fields=mainbranch',
  25842. $this->owner,
  25843. $this->repository
  25844. );
  25845. $data = $this->fetchWithOAuthCredentials($resource)->decodeJson();
  25846. if (isset($data['mainbranch'])) {
  25847. return $data['mainbranch'];
  25848. }
  25849. return null;
  25850. }
  25851. }
  25852. <?php
  25853. namespace Composer\Repository\Vcs;
  25854. use Composer\Cache;
  25855. use Composer\Config;
  25856. use Composer\Util\ProcessExecutor;
  25857. use Composer\Util\Filesystem;
  25858. use Composer\IO\IOInterface;
  25859. class FossilDriver extends VcsDriver
  25860. {
  25861. protected $tags;
  25862. protected $branches;
  25863. protected $rootIdentifier;
  25864. protected $repoFile;
  25865. protected $checkoutDir;
  25866. public function initialize()
  25867. {
  25868. $this->checkFossil();
  25869. $this->config->prohibitUrlByConfig($this->url, $this->io);
  25870. if (Filesystem::isLocalPath($this->url) && is_dir($this->url)) {
  25871. $this->checkoutDir = $this->url;
  25872. } else {
  25873. if (!Cache::isUsable($this->config->get('cache-repo-dir')) || !Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  25874. throw new \RuntimeException('FossilDriver requires a usable cache directory, and it looks like you set it to be disabled');
  25875. }
  25876. $localName = preg_replace('{[^a-z0-9]}i', '-', $this->url);
  25877. $this->repoFile = $this->config->get('cache-repo-dir') . '/' . $localName . '.fossil';
  25878. $this->checkoutDir = $this->config->get('cache-vcs-dir') . '/' . $localName . '/';
  25879. $this->updateLocalRepo();
  25880. }
  25881. $this->getTags();
  25882. $this->getBranches();
  25883. }
  25884. protected function checkFossil()
  25885. {
  25886. if (0 !== $this->process->execute('fossil version', $ignoredOutput)) {
  25887. throw new \RuntimeException("fossil was not found, check that it is installed and in your PATH env.\n\n" . $this->process->getErrorOutput());
  25888. }
  25889. }
  25890. protected function updateLocalRepo()
  25891. {
  25892. $fs = new Filesystem();
  25893. $fs->ensureDirectoryExists($this->checkoutDir);
  25894. if (!is_writable(dirname($this->checkoutDir))) {
  25895. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$this->checkoutDir.'" directory is not writable by the current user.');
  25896. }
  25897. if (is_file($this->repoFile) && is_dir($this->checkoutDir) && 0 === $this->process->execute('fossil info', $output, $this->checkoutDir)) {
  25898. if (0 !== $this->process->execute('fossil pull', $output, $this->checkoutDir)) {
  25899. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  25900. }
  25901. } else {
  25902. $fs->removeDirectory($this->checkoutDir);
  25903. $fs->remove($this->repoFile);
  25904. $fs->ensureDirectoryExists($this->checkoutDir);
  25905. if (0 !== $this->process->execute(sprintf('fossil clone %s %s', ProcessExecutor::escape($this->url), ProcessExecutor::escape($this->repoFile)), $output)) {
  25906. $output = $this->process->getErrorOutput();
  25907. throw new \RuntimeException('Failed to clone '.$this->url.' to repository ' . $this->repoFile . "\n\n" .$output);
  25908. }
  25909. if (0 !== $this->process->execute(sprintf('fossil open %s --nested', ProcessExecutor::escape($this->repoFile)), $output, $this->checkoutDir)) {
  25910. $output = $this->process->getErrorOutput();
  25911. throw new \RuntimeException('Failed to open repository '.$this->repoFile.' in ' . $this->checkoutDir . "\n\n" .$output);
  25912. }
  25913. }
  25914. }
  25915. public function getRootIdentifier()
  25916. {
  25917. if (null === $this->rootIdentifier) {
  25918. $this->rootIdentifier = 'trunk';
  25919. }
  25920. return $this->rootIdentifier;
  25921. }
  25922. public function getUrl()
  25923. {
  25924. return $this->url;
  25925. }
  25926. public function getSource($identifier)
  25927. {
  25928. return array('type' => 'fossil', 'url' => $this->getUrl(), 'reference' => $identifier);
  25929. }
  25930. public function getDist($identifier)
  25931. {
  25932. return null;
  25933. }
  25934. public function getFileContent($file, $identifier)
  25935. {
  25936. $command = sprintf('fossil cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  25937. $this->process->execute($command, $content, $this->checkoutDir);
  25938. if (!trim($content)) {
  25939. return null;
  25940. }
  25941. return $content;
  25942. }
  25943. public function getChangeDate($identifier)
  25944. {
  25945. $this->process->execute('fossil finfo -b -n 1 composer.json', $output, $this->checkoutDir);
  25946. list(, $date) = explode(' ', trim($output), 3);
  25947. return new \DateTime($date, new \DateTimeZone('UTC'));
  25948. }
  25949. public function getTags()
  25950. {
  25951. if (null === $this->tags) {
  25952. $tags = array();
  25953. $this->process->execute('fossil tag list', $output, $this->checkoutDir);
  25954. foreach ($this->process->splitLines($output) as $tag) {
  25955. $tags[$tag] = $tag;
  25956. }
  25957. $this->tags = $tags;
  25958. }
  25959. return $this->tags;
  25960. }
  25961. public function getBranches()
  25962. {
  25963. if (null === $this->branches) {
  25964. $branches = array();
  25965. $this->process->execute('fossil branch list', $output, $this->checkoutDir);
  25966. foreach ($this->process->splitLines($output) as $branch) {
  25967. $branch = trim(preg_replace('/^\*/', '', trim($branch)));
  25968. $branches[$branch] = $branch;
  25969. }
  25970. $this->branches = $branches;
  25971. }
  25972. return $this->branches;
  25973. }
  25974. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  25975. {
  25976. if (preg_match('#(^(?:https?|ssh)://(?:[^@]@)?(?:chiselapp\.com|fossil\.))#i', $url)) {
  25977. return true;
  25978. }
  25979. if (preg_match('!/fossil/|\.fossil!', $url)) {
  25980. return true;
  25981. }
  25982. if (Filesystem::isLocalPath($url)) {
  25983. $url = Filesystem::getPlatformPath($url);
  25984. if (!is_dir($url)) {
  25985. return false;
  25986. }
  25987. $process = new ProcessExecutor($io);
  25988. if ($process->execute('fossil info', $output, $url) === 0) {
  25989. return true;
  25990. }
  25991. }
  25992. return false;
  25993. }
  25994. }
  25995. <?php
  25996. namespace Composer\Repository\Vcs;
  25997. use Composer\Config;
  25998. use Composer\IO\IOInterface;
  25999. class GitBitbucketDriver extends BitbucketDriver
  26000. {
  26001. public function getRootIdentifier()
  26002. {
  26003. if ($this->fallbackDriver) {
  26004. return $this->fallbackDriver->getRootIdentifier();
  26005. }
  26006. if (null === $this->rootIdentifier) {
  26007. if (!$this->getRepoData()) {
  26008. return $this->fallbackDriver->getRootIdentifier();
  26009. }
  26010. if ($this->vcsType !== 'git') {
  26011. throw new \RuntimeException(
  26012. $this->url.' does not appear to be a git repository, use '.
  26013. $this->cloneHttpsUrl.' if this is a mercurial bitbucket repository'
  26014. );
  26015. }
  26016. $mainBranchData = $this->getMainBranchData();
  26017. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'master';
  26018. }
  26019. return $this->rootIdentifier;
  26020. }
  26021. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26022. {
  26023. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/(.+?)\.git$#i', $url)) {
  26024. return false;
  26025. }
  26026. if (!extension_loaded('openssl')) {
  26027. $io->writeError('Skipping Bitbucket git driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26028. return false;
  26029. }
  26030. return true;
  26031. }
  26032. protected function setupFallbackDriver($url)
  26033. {
  26034. $this->fallbackDriver = new GitDriver(
  26035. array('url' => $url),
  26036. $this->io,
  26037. $this->config,
  26038. $this->httpDownloader,
  26039. $this->process
  26040. );
  26041. $this->fallbackDriver->initialize();
  26042. }
  26043. protected function generateSshUrl()
  26044. {
  26045. return 'git@' . $this->originUrl . ':' . $this->owner.'/'.$this->repository.'.git';
  26046. }
  26047. }
  26048. <?php
  26049. namespace Composer\Repository\Vcs;
  26050. use Composer\Util\ProcessExecutor;
  26051. use Composer\Util\Filesystem;
  26052. use Composer\Util\Url;
  26053. use Composer\Util\Git as GitUtil;
  26054. use Composer\IO\IOInterface;
  26055. use Composer\Cache;
  26056. use Composer\Config;
  26057. class GitDriver extends VcsDriver
  26058. {
  26059. protected $tags;
  26060. protected $branches;
  26061. protected $rootIdentifier;
  26062. protected $repoDir;
  26063. public function initialize()
  26064. {
  26065. if (Filesystem::isLocalPath($this->url)) {
  26066. $this->url = preg_replace('{[\\/]\.git/?$}', '', $this->url);
  26067. $this->repoDir = $this->url;
  26068. $cacheUrl = realpath($this->url);
  26069. } else {
  26070. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  26071. throw new \RuntimeException('GitDriver requires a usable cache directory, and it looks like you set it to be disabled');
  26072. }
  26073. $this->repoDir = $this->config->get('cache-vcs-dir') . '/' . preg_replace('{[^a-z0-9.]}i', '-', $this->url) . '/';
  26074. GitUtil::cleanEnv();
  26075. $fs = new Filesystem();
  26076. $fs->ensureDirectoryExists(dirname($this->repoDir));
  26077. if (!is_writable(dirname($this->repoDir))) {
  26078. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.dirname($this->repoDir).'" directory is not writable by the current user.');
  26079. }
  26080. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $this->url)) {
  26081. 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.');
  26082. }
  26083. $gitUtil = new GitUtil($this->io, $this->config, $this->process, $fs);
  26084. if (!$gitUtil->syncMirror($this->url, $this->repoDir)) {
  26085. if (!is_dir($this->repoDir)) {
  26086. throw new \RuntimeException('Failed to clone '.$this->url.' to read package information from it');
  26087. }
  26088. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated</error>');
  26089. }
  26090. $cacheUrl = $this->url;
  26091. }
  26092. $this->getTags();
  26093. $this->getBranches();
  26094. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($cacheUrl)));
  26095. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26096. }
  26097. public function getRootIdentifier()
  26098. {
  26099. if (null === $this->rootIdentifier) {
  26100. $this->rootIdentifier = 'master';
  26101. $this->process->execute('git branch --no-color', $output, $this->repoDir);
  26102. $branches = $this->process->splitLines($output);
  26103. if (!in_array('* master', $branches)) {
  26104. foreach ($branches as $branch) {
  26105. if ($branch && preg_match('{^\* +(\S+)}', $branch, $match)) {
  26106. $this->rootIdentifier = $match[1];
  26107. break;
  26108. }
  26109. }
  26110. }
  26111. }
  26112. return $this->rootIdentifier;
  26113. }
  26114. public function getUrl()
  26115. {
  26116. return $this->url;
  26117. }
  26118. public function getSource($identifier)
  26119. {
  26120. return array('type' => 'git', 'url' => $this->getUrl(), 'reference' => $identifier);
  26121. }
  26122. public function getDist($identifier)
  26123. {
  26124. return null;
  26125. }
  26126. public function getFileContent($file, $identifier)
  26127. {
  26128. $resource = sprintf('%s:%s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  26129. $this->process->execute(sprintf('git show %s', $resource), $content, $this->repoDir);
  26130. if (!trim($content)) {
  26131. return null;
  26132. }
  26133. return $content;
  26134. }
  26135. public function getChangeDate($identifier)
  26136. {
  26137. $this->process->execute(sprintf(
  26138. 'git -c log.showSignature=false log -1 --format=%%at %s',
  26139. ProcessExecutor::escape($identifier)
  26140. ), $output, $this->repoDir);
  26141. return new \DateTime('@'.trim($output), new \DateTimeZone('UTC'));
  26142. }
  26143. public function getTags()
  26144. {
  26145. if (null === $this->tags) {
  26146. $this->tags = array();
  26147. $this->process->execute('git show-ref --tags --dereference', $output, $this->repoDir);
  26148. foreach ($output = $this->process->splitLines($output) as $tag) {
  26149. if ($tag && preg_match('{^([a-f0-9]{40}) refs/tags/(\S+?)(\^\{\})?$}', $tag, $match)) {
  26150. $this->tags[$match[2]] = $match[1];
  26151. }
  26152. }
  26153. }
  26154. return $this->tags;
  26155. }
  26156. public function getBranches()
  26157. {
  26158. if (null === $this->branches) {
  26159. $branches = array();
  26160. $this->process->execute('git branch --no-color --no-abbrev -v', $output, $this->repoDir);
  26161. foreach ($this->process->splitLines($output) as $branch) {
  26162. if ($branch && !preg_match('{^ *[^/]+/HEAD }', $branch)) {
  26163. if (preg_match('{^(?:\* )? *(\S+) *([a-f0-9]+)(?: .*)?$}', $branch, $match)) {
  26164. $branches[$match[1]] = $match[2];
  26165. }
  26166. }
  26167. }
  26168. $this->branches = $branches;
  26169. }
  26170. return $this->branches;
  26171. }
  26172. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26173. {
  26174. if (preg_match('#(^git://|\.git/?$|git(?:olite)?@|//git\.|//github.com/)#i', $url)) {
  26175. return true;
  26176. }
  26177. if (Filesystem::isLocalPath($url)) {
  26178. $url = Filesystem::getPlatformPath($url);
  26179. if (!is_dir($url)) {
  26180. return false;
  26181. }
  26182. $process = new ProcessExecutor($io);
  26183. if ($process->execute('git tag', $output, $url) === 0) {
  26184. return true;
  26185. }
  26186. }
  26187. if (!$deep) {
  26188. return false;
  26189. }
  26190. $gitUtil = new GitUtil($io, $config, new ProcessExecutor($io), new Filesystem());
  26191. GitUtil::cleanEnv();
  26192. try {
  26193. $gitUtil->runCommand(function ($url) {
  26194. return 'git ls-remote --heads ' . ProcessExecutor::escape($url);
  26195. }, $url, sys_get_temp_dir());
  26196. } catch (\RuntimeException $e) {
  26197. return false;
  26198. }
  26199. return true;
  26200. }
  26201. }
  26202. <?php
  26203. namespace Composer\Repository\Vcs;
  26204. use Composer\Config;
  26205. use Composer\Downloader\TransportException;
  26206. use Composer\Json\JsonFile;
  26207. use Composer\Cache;
  26208. use Composer\IO\IOInterface;
  26209. use Composer\Util\GitHub;
  26210. use Composer\Util\Http\Response;
  26211. class GitHubDriver extends VcsDriver
  26212. {
  26213. protected $owner;
  26214. protected $repository;
  26215. protected $tags;
  26216. protected $branches;
  26217. protected $rootIdentifier;
  26218. protected $repoData;
  26219. protected $hasIssues;
  26220. protected $isPrivate = false;
  26221. private $isArchived = false;
  26222. private $fundingInfo;
  26223. protected $gitDriver;
  26224. public function initialize()
  26225. {
  26226. preg_match('#^(?:(?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $this->url, $match);
  26227. $this->owner = $match[3];
  26228. $this->repository = $match[4];
  26229. $this->originUrl = strtolower(!empty($match[1]) ? $match[1] : $match[2]);
  26230. if ($this->originUrl === 'www.github.com') {
  26231. $this->originUrl = 'github.com';
  26232. }
  26233. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->owner.'/'.$this->repository);
  26234. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26235. if ($this->config->get('use-github-api') === false || (isset($this->repoConfig['no-api']) && $this->repoConfig['no-api'])) {
  26236. $this->setupGitDriver($this->url);
  26237. return;
  26238. }
  26239. $this->fetchRootIdentifier();
  26240. }
  26241. public function getRepositoryUrl()
  26242. {
  26243. return 'https://'.$this->originUrl.'/'.$this->owner.'/'.$this->repository;
  26244. }
  26245. public function getRootIdentifier()
  26246. {
  26247. if ($this->gitDriver) {
  26248. return $this->gitDriver->getRootIdentifier();
  26249. }
  26250. return $this->rootIdentifier;
  26251. }
  26252. public function getUrl()
  26253. {
  26254. if ($this->gitDriver) {
  26255. return $this->gitDriver->getUrl();
  26256. }
  26257. return 'https://' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  26258. }
  26259. protected function getApiUrl()
  26260. {
  26261. if ('github.com' === $this->originUrl) {
  26262. $apiUrl = 'api.github.com';
  26263. } else {
  26264. $apiUrl = $this->originUrl . '/api/v3';
  26265. }
  26266. return 'https://' . $apiUrl;
  26267. }
  26268. public function getSource($identifier)
  26269. {
  26270. if ($this->gitDriver) {
  26271. return $this->gitDriver->getSource($identifier);
  26272. }
  26273. if ($this->isPrivate) {
  26274. $url = $this->generateSshUrl();
  26275. } else {
  26276. $url = $this->getUrl();
  26277. }
  26278. return array('type' => 'git', 'url' => $url, 'reference' => $identifier);
  26279. }
  26280. public function getDist($identifier)
  26281. {
  26282. $url = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/zipball/'.$identifier;
  26283. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  26284. }
  26285. public function getComposerInformation($identifier)
  26286. {
  26287. if ($this->gitDriver) {
  26288. return $this->gitDriver->getComposerInformation($identifier);
  26289. }
  26290. if (!isset($this->infoCache[$identifier])) {
  26291. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  26292. $composer = JsonFile::parseJson($res);
  26293. } else {
  26294. $composer = $this->getBaseComposerInformation($identifier);
  26295. if ($this->shouldCache($identifier)) {
  26296. $this->cache->write($identifier, json_encode($composer));
  26297. }
  26298. }
  26299. if ($composer) {
  26300. if (!isset($composer['support']['source'])) {
  26301. $label = array_search($identifier, $this->getTags()) ?: array_search($identifier, $this->getBranches()) ?: $identifier;
  26302. $composer['support']['source'] = sprintf('https://%s/%s/%s/tree/%s', $this->originUrl, $this->owner, $this->repository, $label);
  26303. }
  26304. if (!isset($composer['support']['issues']) && $this->hasIssues) {
  26305. $composer['support']['issues'] = sprintf('https://%s/%s/%s/issues', $this->originUrl, $this->owner, $this->repository);
  26306. }
  26307. if (!isset($composer['abandoned']) && $this->isArchived) {
  26308. $composer['abandoned'] = true;
  26309. }
  26310. if (!isset($composer['funding']) && $funding = $this->getFundingInfo()) {
  26311. $composer['funding'] = $funding;
  26312. }
  26313. }
  26314. $this->infoCache[$identifier] = $composer;
  26315. }
  26316. return $this->infoCache[$identifier];
  26317. }
  26318. private function getFundingInfo()
  26319. {
  26320. if (null !== $this->fundingInfo) {
  26321. return $this->fundingInfo;
  26322. }
  26323. if ($this->originUrl !== 'github.com') {
  26324. return $this->fundingInfo = false;
  26325. }
  26326. foreach (array($this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/.github/FUNDING.yml', $this->getApiUrl() . '/repos/'.$this->owner.'/.github/contents/FUNDING.yml') as $file) {
  26327. try {
  26328. $response = $this->httpDownloader->get($file, array(
  26329. 'retry-auth-failure' => false,
  26330. ))->decodeJson();
  26331. } catch (TransportException $e) {
  26332. continue;
  26333. }
  26334. if (empty($response['content']) || $response['encoding'] !== 'base64' || !($funding = base64_decode($response['content']))) {
  26335. continue;
  26336. }
  26337. break;
  26338. }
  26339. if (empty($funding)) {
  26340. return $this->fundingInfo = false;
  26341. }
  26342. $result = array();
  26343. $key = null;
  26344. foreach (preg_split('{\r?\n}', $funding) as $line) {
  26345. $line = trim($line);
  26346. if (preg_match('{^(\w+)\s*:\s*(.+)$}', $line, $match)) {
  26347. if (preg_match('{^\[(.*)\](?:\s*#.*)?$}', $match[2], $match2)) {
  26348. foreach (array_map('trim', preg_split('{[\'"]?\s*,\s*[\'"]?}', $match2[1])) as $item) {
  26349. $result[] = array('type' => $match[1], 'url' => trim($item, '"\' '));
  26350. }
  26351. } elseif (preg_match('{^([^#].*?)(\s+#.*)?$}', $match[2], $match2)) {
  26352. $result[] = array('type' => $match[1], 'url' => trim($match2[1], '"\' '));
  26353. }
  26354. $key = null;
  26355. } elseif (preg_match('{^(\w+)\s*:\s*#\s*$}', $line, $match)) {
  26356. $key = $match[1];
  26357. } elseif ($key && preg_match('{^-\s*(.+)(\s+#.*)?$}', $line, $match)) {
  26358. $result[] = array('type' => $key, 'url' => trim($match[1], '"\' '));
  26359. }
  26360. }
  26361. foreach ($result as $key => $item) {
  26362. switch ($item['type']) {
  26363. case 'tidelift':
  26364. $result[$key]['url'] = 'https://tidelift.com/funding/github/' . $item['url'];
  26365. break;
  26366. case 'github':
  26367. $result[$key]['url'] = 'https://github.com/' . basename($item['url']);
  26368. break;
  26369. case 'patreon':
  26370. $result[$key]['url'] = 'https://www.patreon.com/' . basename($item['url']);
  26371. break;
  26372. case 'otechie':
  26373. $result[$key]['url'] = 'https://otechie.com/' . basename($item['url']);
  26374. break;
  26375. case 'open_collective':
  26376. $result[$key]['url'] = 'https://opencollective.com/' . basename($item['url']);
  26377. break;
  26378. case 'liberapay':
  26379. $result[$key]['url'] = 'https://liberapay.com/' . basename($item['url']);
  26380. break;
  26381. case 'ko_fi':
  26382. $result[$key]['url'] = 'https://ko-fi.com/' . basename($item['url']);
  26383. break;
  26384. case 'issuehunt':
  26385. $result[$key]['url'] = 'https://issuehunt.io/r/' . $item['url'];
  26386. break;
  26387. case 'community_bridge':
  26388. $result[$key]['url'] = 'https://funding.communitybridge.org/projects/' . basename($item['url']);
  26389. break;
  26390. }
  26391. }
  26392. return $this->fundingInfo = $result;
  26393. }
  26394. public function getFileContent($file, $identifier)
  26395. {
  26396. if ($this->gitDriver) {
  26397. return $this->gitDriver->getFileContent($file, $identifier);
  26398. }
  26399. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/contents/' . $file . '?ref='.urlencode($identifier);
  26400. $resource = $this->getContents($resource)->decodeJson();
  26401. if (empty($resource['content']) || $resource['encoding'] !== 'base64' || !($content = base64_decode($resource['content']))) {
  26402. throw new \RuntimeException('Could not retrieve ' . $file . ' for '.$identifier);
  26403. }
  26404. return $content;
  26405. }
  26406. public function getChangeDate($identifier)
  26407. {
  26408. if ($this->gitDriver) {
  26409. return $this->gitDriver->getChangeDate($identifier);
  26410. }
  26411. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/commits/'.urlencode($identifier);
  26412. $commit = $this->getContents($resource)->decodeJson();
  26413. return new \DateTime($commit['commit']['committer']['date']);
  26414. }
  26415. public function getTags()
  26416. {
  26417. if ($this->gitDriver) {
  26418. return $this->gitDriver->getTags();
  26419. }
  26420. if (null === $this->tags) {
  26421. $this->tags = array();
  26422. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/tags?per_page=100';
  26423. do {
  26424. $response = $this->getContents($resource);
  26425. $tagsData = $response->decodeJson();
  26426. foreach ($tagsData as $tag) {
  26427. $this->tags[$tag['name']] = $tag['commit']['sha'];
  26428. }
  26429. $resource = $this->getNextPage($response);
  26430. } while ($resource);
  26431. }
  26432. return $this->tags;
  26433. }
  26434. public function getBranches()
  26435. {
  26436. if ($this->gitDriver) {
  26437. return $this->gitDriver->getBranches();
  26438. }
  26439. if (null === $this->branches) {
  26440. $this->branches = array();
  26441. $resource = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository.'/git/refs/heads?per_page=100';
  26442. do {
  26443. $response = $this->getContents($resource);
  26444. $branchData = $response->decodeJson();
  26445. foreach ($branchData as $branch) {
  26446. $name = substr($branch['ref'], 11);
  26447. if ($name !== 'gh-pages') {
  26448. $this->branches[$name] = $branch['object']['sha'];
  26449. }
  26450. }
  26451. $resource = $this->getNextPage($response);
  26452. } while ($resource);
  26453. }
  26454. return $this->branches;
  26455. }
  26456. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26457. {
  26458. if (!preg_match('#^((?:https?|git)://([^/]+)/|git@([^:]+):/?)([^/]+)/(.+?)(?:\.git|/)?$#', $url, $matches)) {
  26459. return false;
  26460. }
  26461. $originUrl = !empty($matches[2]) ? $matches[2] : $matches[3];
  26462. if (!in_array(strtolower(preg_replace('{^www\.}i', '', $originUrl)), $config->get('github-domains'))) {
  26463. return false;
  26464. }
  26465. if (!extension_loaded('openssl')) {
  26466. $io->writeError('Skipping GitHub driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26467. return false;
  26468. }
  26469. return true;
  26470. }
  26471. public function getRepoData()
  26472. {
  26473. $this->fetchRootIdentifier();
  26474. return $this->repoData;
  26475. }
  26476. protected function generateSshUrl()
  26477. {
  26478. if (false !== strpos($this->originUrl, ':')) {
  26479. return 'ssh://git@' . $this->originUrl . '/'.$this->owner.'/'.$this->repository.'.git';
  26480. }
  26481. return 'git@' . $this->originUrl . ':'.$this->owner.'/'.$this->repository.'.git';
  26482. }
  26483. protected function getContents($url, $fetchingRepoData = false)
  26484. {
  26485. try {
  26486. return parent::getContents($url);
  26487. } catch (TransportException $e) {
  26488. $gitHubUtil = new GitHub($this->io, $this->config, $this->process, $this->httpDownloader);
  26489. switch ($e->getCode()) {
  26490. case 401:
  26491. case 404:
  26492. if (!$fetchingRepoData) {
  26493. throw $e;
  26494. }
  26495. if ($gitHubUtil->authorizeOAuth($this->originUrl)) {
  26496. return parent::getContents($url);
  26497. }
  26498. if (!$this->io->isInteractive()) {
  26499. if ($this->attemptCloneFallback()) {
  26500. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26501. }
  26502. }
  26503. $scopesIssued = array();
  26504. $scopesNeeded = array();
  26505. if ($headers = $e->getHeaders()) {
  26506. if ($scopes = Response::findHeaderValue($headers, 'X-OAuth-Scopes')) {
  26507. $scopesIssued = explode(' ', $scopes);
  26508. }
  26509. if ($scopes = Response::findHeaderValue($headers, 'X-Accepted-OAuth-Scopes')) {
  26510. $scopesNeeded = explode(' ', $scopes);
  26511. }
  26512. }
  26513. $scopesFailed = array_diff($scopesNeeded, $scopesIssued);
  26514. if (!$headers || !count($scopesNeeded) || count($scopesFailed)) {
  26515. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'Your GitHub credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  26516. }
  26517. return parent::getContents($url);
  26518. case 403:
  26519. if (!$this->io->hasAuthentication($this->originUrl) && $gitHubUtil->authorizeOAuth($this->originUrl)) {
  26520. return parent::getContents($url);
  26521. }
  26522. if (!$this->io->isInteractive() && $fetchingRepoData) {
  26523. if ($this->attemptCloneFallback()) {
  26524. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26525. }
  26526. }
  26527. $rateLimited = $gitHubUtil->isRateLimited($e->getHeaders());
  26528. if (!$this->io->hasAuthentication($this->originUrl)) {
  26529. if (!$this->io->isInteractive()) {
  26530. $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>');
  26531. throw $e;
  26532. }
  26533. $gitHubUtil->authorizeOAuthInteractively($this->originUrl, 'API limit exhausted. Enter your GitHub credentials to get a larger API limit (<info>'.$this->url.'</info>)');
  26534. return parent::getContents($url);
  26535. }
  26536. if ($rateLimited) {
  26537. $rateLimit = $gitHubUtil->getRateLimit($e->getHeaders());
  26538. $this->io->writeError(sprintf(
  26539. '<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>',
  26540. $rateLimit['limit'],
  26541. $rateLimit['reset']
  26542. ));
  26543. }
  26544. throw $e;
  26545. default:
  26546. throw $e;
  26547. }
  26548. }
  26549. }
  26550. protected function fetchRootIdentifier()
  26551. {
  26552. if ($this->repoData) {
  26553. return;
  26554. }
  26555. $repoDataUrl = $this->getApiUrl() . '/repos/'.$this->owner.'/'.$this->repository;
  26556. try {
  26557. $this->repoData = $this->getContents($repoDataUrl, true)->decodeJson();
  26558. } catch (TransportException $e) {
  26559. if ($e->getCode() === 499) {
  26560. $this->attemptCloneFallback();
  26561. } else {
  26562. throw $e;
  26563. }
  26564. }
  26565. if (null === $this->repoData && null !== $this->gitDriver) {
  26566. return;
  26567. }
  26568. $this->owner = $this->repoData['owner']['login'];
  26569. $this->repository = $this->repoData['name'];
  26570. $this->isPrivate = !empty($this->repoData['private']);
  26571. if (isset($this->repoData['default_branch'])) {
  26572. $this->rootIdentifier = $this->repoData['default_branch'];
  26573. } elseif (isset($this->repoData['master_branch'])) {
  26574. $this->rootIdentifier = $this->repoData['master_branch'];
  26575. } else {
  26576. $this->rootIdentifier = 'master';
  26577. }
  26578. $this->hasIssues = !empty($this->repoData['has_issues']);
  26579. $this->isArchived = !empty($this->repoData['archived']);
  26580. }
  26581. protected function attemptCloneFallback()
  26582. {
  26583. $this->isPrivate = true;
  26584. try {
  26585. $this->setupGitDriver($this->generateSshUrl());
  26586. return true;
  26587. } catch (\RuntimeException $e) {
  26588. $this->gitDriver = null;
  26589. $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>');
  26590. throw $e;
  26591. }
  26592. }
  26593. protected function setupGitDriver($url)
  26594. {
  26595. $this->gitDriver = new GitDriver(
  26596. array('url' => $url),
  26597. $this->io,
  26598. $this->config,
  26599. $this->httpDownloader,
  26600. $this->process
  26601. );
  26602. $this->gitDriver->initialize();
  26603. }
  26604. protected function getNextPage(Response $response)
  26605. {
  26606. $header = $response->getHeader('link');
  26607. $links = explode(',', $header);
  26608. foreach ($links as $link) {
  26609. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  26610. return $match[1];
  26611. }
  26612. }
  26613. }
  26614. }
  26615. <?php
  26616. namespace Composer\Repository\Vcs;
  26617. use Composer\Config;
  26618. use Composer\Cache;
  26619. use Composer\IO\IOInterface;
  26620. use Composer\Json\JsonFile;
  26621. use Composer\Downloader\TransportException;
  26622. use Composer\Util\HttpDownloader;
  26623. use Composer\Util\GitLab;
  26624. use Composer\Util\Http\Response;
  26625. class GitLabDriver extends VcsDriver
  26626. {
  26627. private $scheme;
  26628. private $namespace;
  26629. private $repository;
  26630. private $project;
  26631. private $commits = array();
  26632. private $tags;
  26633. private $branches;
  26634. protected $gitDriver;
  26635. private $isPrivate = true;
  26636. private $hasNonstandardOrigin = false;
  26637. const URL_REGEX = '#^(?:(?P<scheme>https?)://(?P<domain>.+?)(?::(?P<port>[0-9]+))?/|git@(?P<domain2>[^:]+):)(?P<parts>.+)/(?P<repo>[^/]+?)(?:\.git|/)?$#';
  26638. public function initialize()
  26639. {
  26640. if (!preg_match(self::URL_REGEX, $this->url, $match)) {
  26641. throw new \InvalidArgumentException('The URL provided is invalid. It must be the HTTP URL of a GitLab project.');
  26642. }
  26643. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  26644. $configuredDomains = $this->config->get('gitlab-domains');
  26645. $urlParts = explode('/', $match['parts']);
  26646. $this->scheme = !empty($match['scheme'])
  26647. ? $match['scheme']
  26648. : (isset($this->repoConfig['secure-http']) && $this->repoConfig['secure-http'] === false ? 'http' : 'https')
  26649. ;
  26650. $this->originUrl = self::determineOrigin($configuredDomains, $guessedDomain, $urlParts, $match['port']);
  26651. if (false !== strpos($this->originUrl, ':') || false !== strpos($this->originUrl, '/')) {
  26652. $this->hasNonstandardOrigin = true;
  26653. }
  26654. $this->namespace = implode('/', $urlParts);
  26655. $this->repository = preg_replace('#(\.git)$#', '', $match['repo']);
  26656. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository);
  26657. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  26658. $this->fetchProject();
  26659. }
  26660. public function setHttpDownloader(HttpDownloader $httpDownloader)
  26661. {
  26662. $this->httpDownloader = $httpDownloader;
  26663. }
  26664. public function getComposerInformation($identifier)
  26665. {
  26666. if ($this->gitDriver) {
  26667. return $this->gitDriver->getComposerInformation($identifier);
  26668. }
  26669. if (!isset($this->infoCache[$identifier])) {
  26670. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  26671. $composer = JsonFile::parseJson($res);
  26672. } else {
  26673. $composer = $this->getBaseComposerInformation($identifier);
  26674. if ($this->shouldCache($identifier)) {
  26675. $this->cache->write($identifier, json_encode($composer));
  26676. }
  26677. }
  26678. if ($composer) {
  26679. if (!isset($composer['support']['issues']) && isset($this->project['_links']['issues'])) {
  26680. $composer['support']['issues'] = $this->project['_links']['issues'];
  26681. }
  26682. if (!isset($composer['abandoned']) && !empty($this->project['archived'])) {
  26683. $composer['abandoned'] = true;
  26684. }
  26685. }
  26686. $this->infoCache[$identifier] = $composer;
  26687. }
  26688. return $this->infoCache[$identifier];
  26689. }
  26690. public function getFileContent($file, $identifier)
  26691. {
  26692. if ($this->gitDriver) {
  26693. return $this->gitDriver->getFileContent($file, $identifier);
  26694. }
  26695. if (!preg_match('{[a-f0-9]{40}}i', $identifier)) {
  26696. $branches = $this->getBranches();
  26697. if (isset($branches[$identifier])) {
  26698. $identifier = $branches[$identifier];
  26699. }
  26700. }
  26701. $resource = $this->getApiUrl().'/repository/files/'.$this->urlEncodeAll($file).'/raw?ref='.$identifier;
  26702. try {
  26703. $content = $this->getContents($resource)->getBody();
  26704. } catch (TransportException $e) {
  26705. if ($e->getCode() !== 404) {
  26706. throw $e;
  26707. }
  26708. return null;
  26709. }
  26710. return $content;
  26711. }
  26712. public function getChangeDate($identifier)
  26713. {
  26714. if ($this->gitDriver) {
  26715. return $this->gitDriver->getChangeDate($identifier);
  26716. }
  26717. if (isset($this->commits[$identifier])) {
  26718. return new \DateTime($this->commits[$identifier]['committed_date']);
  26719. }
  26720. return new \DateTime();
  26721. }
  26722. public function getRepositoryUrl()
  26723. {
  26724. return $this->isPrivate ? $this->project['ssh_url_to_repo'] : $this->project['http_url_to_repo'];
  26725. }
  26726. public function getUrl()
  26727. {
  26728. if ($this->gitDriver) {
  26729. return $this->gitDriver->getUrl();
  26730. }
  26731. return $this->project['web_url'];
  26732. }
  26733. public function getDist($identifier)
  26734. {
  26735. $url = $this->getApiUrl().'/repository/archive.zip?sha='.$identifier;
  26736. return array('type' => 'zip', 'url' => $url, 'reference' => $identifier, 'shasum' => '');
  26737. }
  26738. public function getSource($identifier)
  26739. {
  26740. if ($this->gitDriver) {
  26741. return $this->gitDriver->getSource($identifier);
  26742. }
  26743. return array('type' => 'git', 'url' => $this->getRepositoryUrl(), 'reference' => $identifier);
  26744. }
  26745. public function getRootIdentifier()
  26746. {
  26747. if ($this->gitDriver) {
  26748. return $this->gitDriver->getRootIdentifier();
  26749. }
  26750. return $this->project['default_branch'];
  26751. }
  26752. public function getBranches()
  26753. {
  26754. if ($this->gitDriver) {
  26755. return $this->gitDriver->getBranches();
  26756. }
  26757. if (!$this->branches) {
  26758. $this->branches = $this->getReferences('branches');
  26759. }
  26760. return $this->branches;
  26761. }
  26762. public function getTags()
  26763. {
  26764. if ($this->gitDriver) {
  26765. return $this->gitDriver->getTags();
  26766. }
  26767. if (!$this->tags) {
  26768. $this->tags = $this->getReferences('tags');
  26769. }
  26770. return $this->tags;
  26771. }
  26772. public function getApiUrl()
  26773. {
  26774. return $this->scheme.'://'.$this->originUrl.'/api/v4/projects/'.$this->urlEncodeAll($this->namespace).'%2F'.$this->urlEncodeAll($this->repository);
  26775. }
  26776. private function urlEncodeAll($string)
  26777. {
  26778. $encoded = '';
  26779. for ($i = 0; isset($string[$i]); $i++) {
  26780. $character = $string[$i];
  26781. if (!ctype_alnum($character) && !in_array($character, array('-', '_'), true)) {
  26782. $character = '%' . sprintf('%02X', ord($character));
  26783. }
  26784. $encoded .= $character;
  26785. }
  26786. return $encoded;
  26787. }
  26788. protected function getReferences($type)
  26789. {
  26790. $perPage = 100;
  26791. $resource = $this->getApiUrl().'/repository/'.$type.'?per_page='.$perPage;
  26792. $references = array();
  26793. do {
  26794. $response = $this->getContents($resource);
  26795. $data = $response->decodeJson();
  26796. foreach ($data as $datum) {
  26797. $references[$datum['name']] = $datum['commit']['id'];
  26798. $this->commits[$datum['commit']['id']] = $datum['commit'];
  26799. }
  26800. if (count($data) >= $perPage) {
  26801. $resource = $this->getNextPage($response);
  26802. } else {
  26803. $resource = false;
  26804. }
  26805. } while ($resource);
  26806. return $references;
  26807. }
  26808. protected function fetchProject()
  26809. {
  26810. $resource = $this->getApiUrl();
  26811. $this->project = $this->getContents($resource, true)->decodeJson();
  26812. if (isset($this->project['visibility'])) {
  26813. $this->isPrivate = $this->project['visibility'] !== 'public';
  26814. } else {
  26815. $this->isPrivate = false;
  26816. }
  26817. }
  26818. protected function attemptCloneFallback()
  26819. {
  26820. if ($this->isPrivate === false) {
  26821. $url = $this->generatePublicUrl();
  26822. } else {
  26823. $url = $this->generateSshUrl();
  26824. }
  26825. try {
  26826. $this->setupGitDriver($url);
  26827. return true;
  26828. } catch (\RuntimeException $e) {
  26829. $this->gitDriver = null;
  26830. $this->io->writeError('<error>Failed to clone the '.$url.' repository, try running in interactive mode so that you can enter your credentials</error>');
  26831. throw $e;
  26832. }
  26833. }
  26834. protected function generateSshUrl()
  26835. {
  26836. if ($this->hasNonstandardOrigin) {
  26837. return 'ssh://git@'.$this->originUrl.'/'.$this->namespace.'/'.$this->repository.'.git';
  26838. }
  26839. return 'git@' . $this->originUrl . ':'.$this->namespace.'/'.$this->repository.'.git';
  26840. }
  26841. protected function generatePublicUrl()
  26842. {
  26843. return $this->scheme . '://' . $this->originUrl . '/'.$this->namespace.'/'.$this->repository.'.git';
  26844. }
  26845. protected function setupGitDriver($url)
  26846. {
  26847. $this->gitDriver = new GitDriver(
  26848. array('url' => $url),
  26849. $this->io,
  26850. $this->config,
  26851. $this->httpDownloader,
  26852. $this->process
  26853. );
  26854. $this->gitDriver->initialize();
  26855. }
  26856. protected function getContents($url, $fetchingRepoData = false)
  26857. {
  26858. try {
  26859. $response = parent::getContents($url);
  26860. if ($fetchingRepoData) {
  26861. $json = $response->decodeJson();
  26862. if (!isset($json['default_branch']) && isset($json['permissions'])) {
  26863. $this->isPrivate = $json['visibility'] !== 'public';
  26864. $moreThanGuestAccess = false;
  26865. foreach ($json['permissions'] as $permission) {
  26866. if ($permission && $permission['access_level'] > 10) {
  26867. $moreThanGuestAccess = true;
  26868. }
  26869. }
  26870. if (!$moreThanGuestAccess) {
  26871. $this->io->writeError('<warning>GitLab token with Guest only access detected</warning>');
  26872. return $this->attemptCloneFallback();
  26873. }
  26874. }
  26875. if (!isset($json['default_branch'])) {
  26876. if (!empty($json['id'])) {
  26877. $this->isPrivate = false;
  26878. }
  26879. throw new TransportException('GitLab API seems to not be authenticated as it did not return a default_branch', 401);
  26880. }
  26881. }
  26882. return $response;
  26883. } catch (TransportException $e) {
  26884. $gitLabUtil = new GitLab($this->io, $this->config, $this->process, $this->httpDownloader);
  26885. switch ($e->getCode()) {
  26886. case 401:
  26887. case 404:
  26888. if (!$fetchingRepoData) {
  26889. throw $e;
  26890. }
  26891. if ($gitLabUtil->authorizeOAuth($this->originUrl)) {
  26892. return parent::getContents($url);
  26893. }
  26894. if (!$this->io->isInteractive()) {
  26895. if ($this->attemptCloneFallback()) {
  26896. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26897. }
  26898. }
  26899. $this->io->writeError('<warning>Failed to download ' . $this->namespace . '/' . $this->repository . ':' . $e->getMessage() . '</warning>');
  26900. $gitLabUtil->authorizeOAuthInteractively($this->scheme, $this->originUrl, 'Your credentials are required to fetch private repository metadata (<info>'.$this->url.'</info>)');
  26901. return parent::getContents($url);
  26902. case 403:
  26903. if (!$this->io->hasAuthentication($this->originUrl) && $gitLabUtil->authorizeOAuth($this->originUrl)) {
  26904. return parent::getContents($url);
  26905. }
  26906. if (!$this->io->isInteractive() && $fetchingRepoData) {
  26907. if ($this->attemptCloneFallback()) {
  26908. return new Response(array('url' => 'dummy'), 200, array(), 'null');
  26909. }
  26910. }
  26911. throw $e;
  26912. default:
  26913. throw $e;
  26914. }
  26915. }
  26916. }
  26917. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26918. {
  26919. if (!preg_match(self::URL_REGEX, $url, $match)) {
  26920. return false;
  26921. }
  26922. $scheme = !empty($match['scheme']) ? $match['scheme'] : null;
  26923. $guessedDomain = !empty($match['domain']) ? $match['domain'] : $match['domain2'];
  26924. $urlParts = explode('/', $match['parts']);
  26925. if (false === self::determineOrigin((array) $config->get('gitlab-domains'), $guessedDomain, $urlParts, $match['port'])) {
  26926. return false;
  26927. }
  26928. if ('https' === $scheme && !extension_loaded('openssl')) {
  26929. $io->writeError('Skipping GitLab driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26930. return false;
  26931. }
  26932. return true;
  26933. }
  26934. protected function getNextPage(Response $response)
  26935. {
  26936. $header = $response->getHeader('link');
  26937. $links = explode(',', $header);
  26938. foreach ($links as $link) {
  26939. if (preg_match('{<(.+?)>; *rel="next"}', $link, $match)) {
  26940. return $match[1];
  26941. }
  26942. }
  26943. }
  26944. private static function determineOrigin(array $configuredDomains, $guessedDomain, array &$urlParts, $portNumber)
  26945. {
  26946. $guessedDomain = strtolower($guessedDomain);
  26947. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array($guessedDomain.':'.$portNumber, $configuredDomains))) {
  26948. if ($portNumber) {
  26949. return $guessedDomain.':'.$portNumber;
  26950. }
  26951. return $guessedDomain;
  26952. }
  26953. if ($portNumber) {
  26954. $guessedDomain .= ':'.$portNumber;
  26955. }
  26956. while (null !== ($part = array_shift($urlParts))) {
  26957. $guessedDomain .= '/' . $part;
  26958. if (in_array($guessedDomain, $configuredDomains) || ($portNumber && in_array(preg_replace('{:\d+}', '', $guessedDomain), $configuredDomains))) {
  26959. return $guessedDomain;
  26960. }
  26961. }
  26962. return false;
  26963. }
  26964. }
  26965. <?php
  26966. namespace Composer\Repository\Vcs;
  26967. use Composer\Config;
  26968. use Composer\IO\IOInterface;
  26969. class HgBitbucketDriver extends BitbucketDriver
  26970. {
  26971. public function getRootIdentifier()
  26972. {
  26973. if ($this->fallbackDriver) {
  26974. return $this->fallbackDriver->getRootIdentifier();
  26975. }
  26976. if (null === $this->rootIdentifier) {
  26977. if (!$this->getRepoData()) {
  26978. return $this->fallbackDriver->getRootIdentifier();
  26979. }
  26980. if ($this->vcsType !== 'hg') {
  26981. throw new \RuntimeException(
  26982. $this->url.' does not appear to be a mercurial repository, use '.
  26983. $this->cloneHttpsUrl.' if this is a git bitbucket repository'
  26984. );
  26985. }
  26986. $mainBranchData = $this->getMainBranchData();
  26987. $this->rootIdentifier = !empty($mainBranchData['name']) ? $mainBranchData['name'] : 'default';
  26988. }
  26989. return $this->rootIdentifier;
  26990. }
  26991. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  26992. {
  26993. if (!preg_match('#^https?://bitbucket\.org/([^/]+)/([^/]+)/?$#i', $url)) {
  26994. return false;
  26995. }
  26996. if (!extension_loaded('openssl')) {
  26997. $io->writeError('Skipping Bitbucket hg driver for '.$url.' because the OpenSSL PHP extension is missing.', true, IOInterface::VERBOSE);
  26998. return false;
  26999. }
  27000. return true;
  27001. }
  27002. protected function setupFallbackDriver($url)
  27003. {
  27004. $this->fallbackDriver = new HgDriver(
  27005. array('url' => $url),
  27006. $this->io,
  27007. $this->config,
  27008. $this->httpDownloader,
  27009. $this->process
  27010. );
  27011. $this->fallbackDriver->initialize();
  27012. }
  27013. protected function generateSshUrl()
  27014. {
  27015. return 'ssh://hg@' . $this->originUrl . '/' . $this->owner.'/'.$this->repository;
  27016. }
  27017. }
  27018. <?php
  27019. namespace Composer\Repository\Vcs;
  27020. use Composer\Config;
  27021. use Composer\Cache;
  27022. use Composer\Util\Hg as HgUtils;
  27023. use Composer\Util\ProcessExecutor;
  27024. use Composer\Util\Filesystem;
  27025. use Composer\IO\IOInterface;
  27026. class HgDriver extends VcsDriver
  27027. {
  27028. protected $tags;
  27029. protected $branches;
  27030. protected $rootIdentifier;
  27031. protected $repoDir;
  27032. public function initialize()
  27033. {
  27034. if (Filesystem::isLocalPath($this->url)) {
  27035. $this->repoDir = $this->url;
  27036. } else {
  27037. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  27038. throw new \RuntimeException('HgDriver requires a usable cache directory, and it looks like you set it to be disabled');
  27039. }
  27040. $cacheDir = $this->config->get('cache-vcs-dir');
  27041. $this->repoDir = $cacheDir . '/' . preg_replace('{[^a-z0-9]}i', '-', $this->url) . '/';
  27042. $fs = new Filesystem();
  27043. $fs->ensureDirectoryExists($cacheDir);
  27044. if (!is_writable(dirname($this->repoDir))) {
  27045. throw new \RuntimeException('Can not clone '.$this->url.' to access package information. The "'.$cacheDir.'" directory is not writable by the current user.');
  27046. }
  27047. $this->config->prohibitUrlByConfig($this->url, $this->io);
  27048. $hgUtils = new HgUtils($this->io, $this->config, $this->process);
  27049. if (is_dir($this->repoDir) && 0 === $this->process->execute('hg summary', $output, $this->repoDir)) {
  27050. if (0 !== $this->process->execute('hg pull', $output, $this->repoDir)) {
  27051. $this->io->writeError('<error>Failed to update '.$this->url.', package information from this repository may be outdated ('.$this->process->getErrorOutput().')</error>');
  27052. }
  27053. } else {
  27054. $fs->removeDirectory($this->repoDir);
  27055. $repoDir = $this->repoDir;
  27056. $command = function ($url) use ($repoDir) {
  27057. return sprintf('hg clone --noupdate %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($repoDir));
  27058. };
  27059. $hgUtils->runCommand($command, $this->url, null);
  27060. }
  27061. }
  27062. $this->getTags();
  27063. $this->getBranches();
  27064. }
  27065. public function getRootIdentifier()
  27066. {
  27067. if (null === $this->rootIdentifier) {
  27068. $this->process->execute(sprintf('hg tip --template "{node}"'), $output, $this->repoDir);
  27069. $output = $this->process->splitLines($output);
  27070. $this->rootIdentifier = $output[0];
  27071. }
  27072. return $this->rootIdentifier;
  27073. }
  27074. public function getUrl()
  27075. {
  27076. return $this->url;
  27077. }
  27078. public function getSource($identifier)
  27079. {
  27080. return array('type' => 'hg', 'url' => $this->getUrl(), 'reference' => $identifier);
  27081. }
  27082. public function getDist($identifier)
  27083. {
  27084. return null;
  27085. }
  27086. public function getFileContent($file, $identifier)
  27087. {
  27088. $resource = sprintf('hg cat -r %s %s', ProcessExecutor::escape($identifier), ProcessExecutor::escape($file));
  27089. $this->process->execute($resource, $content, $this->repoDir);
  27090. if (!trim($content)) {
  27091. return;
  27092. }
  27093. return $content;
  27094. }
  27095. public function getChangeDate($identifier)
  27096. {
  27097. $this->process->execute(
  27098. sprintf(
  27099. 'hg log --template "{date|rfc3339date}" -r %s',
  27100. ProcessExecutor::escape($identifier)
  27101. ),
  27102. $output,
  27103. $this->repoDir
  27104. );
  27105. return new \DateTime(trim($output), new \DateTimeZone('UTC'));
  27106. }
  27107. public function getTags()
  27108. {
  27109. if (null === $this->tags) {
  27110. $tags = array();
  27111. $this->process->execute('hg tags', $output, $this->repoDir);
  27112. foreach ($this->process->splitLines($output) as $tag) {
  27113. if ($tag && preg_match('(^([^\s]+)\s+\d+:(.*)$)', $tag, $match)) {
  27114. $tags[$match[1]] = $match[2];
  27115. }
  27116. }
  27117. unset($tags['tip']);
  27118. $this->tags = $tags;
  27119. }
  27120. return $this->tags;
  27121. }
  27122. public function getBranches()
  27123. {
  27124. if (null === $this->branches) {
  27125. $branches = array();
  27126. $bookmarks = array();
  27127. $this->process->execute('hg branches', $output, $this->repoDir);
  27128. foreach ($this->process->splitLines($output) as $branch) {
  27129. if ($branch && preg_match('(^([^\s]+)\s+\d+:([a-f0-9]+))', $branch, $match)) {
  27130. $branches[$match[1]] = $match[2];
  27131. }
  27132. }
  27133. $this->process->execute('hg bookmarks', $output, $this->repoDir);
  27134. foreach ($this->process->splitLines($output) as $branch) {
  27135. if ($branch && preg_match('(^(?:[\s*]*)([^\s]+)\s+\d+:(.*)$)', $branch, $match)) {
  27136. $bookmarks[$match[1]] = $match[2];
  27137. }
  27138. }
  27139. $this->branches = array_merge($bookmarks, $branches);
  27140. }
  27141. return $this->branches;
  27142. }
  27143. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27144. {
  27145. if (preg_match('#(^(?:https?|ssh)://(?:[^@]+@)?bitbucket.org|https://(?:.*?)\.kilnhg.com)#i', $url)) {
  27146. return true;
  27147. }
  27148. if (Filesystem::isLocalPath($url)) {
  27149. $url = Filesystem::getPlatformPath($url);
  27150. if (!is_dir($url)) {
  27151. return false;
  27152. }
  27153. $process = new ProcessExecutor($io);
  27154. if ($process->execute('hg summary', $output, $url) === 0) {
  27155. return true;
  27156. }
  27157. }
  27158. if (!$deep) {
  27159. return false;
  27160. }
  27161. $process = new ProcessExecutor($io);
  27162. $exit = $process->execute(sprintf('hg identify %s', ProcessExecutor::escape($url)), $ignored);
  27163. return $exit === 0;
  27164. }
  27165. }
  27166. <?php
  27167. namespace Composer\Repository\Vcs;
  27168. use Composer\Config;
  27169. use Composer\Cache;
  27170. use Composer\IO\IOInterface;
  27171. use Composer\Util\ProcessExecutor;
  27172. use Composer\Util\Perforce;
  27173. class PerforceDriver extends VcsDriver
  27174. {
  27175. protected $depot;
  27176. protected $branch;
  27177. protected $perforce;
  27178. public function initialize()
  27179. {
  27180. $this->depot = $this->repoConfig['depot'];
  27181. $this->branch = '';
  27182. if (!empty($this->repoConfig['branch'])) {
  27183. $this->branch = $this->repoConfig['branch'];
  27184. }
  27185. $this->initPerforce($this->repoConfig);
  27186. $this->perforce->p4Login();
  27187. $this->perforce->checkStream();
  27188. $this->perforce->writeP4ClientSpec();
  27189. $this->perforce->connectClient();
  27190. return true;
  27191. }
  27192. private function initPerforce($repoConfig)
  27193. {
  27194. if (!empty($this->perforce)) {
  27195. return;
  27196. }
  27197. if (!Cache::isUsable($this->config->get('cache-vcs-dir'))) {
  27198. throw new \RuntimeException('PerforceDriver requires a usable cache directory, and it looks like you set it to be disabled');
  27199. }
  27200. $repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
  27201. $this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process, $this->io);
  27202. }
  27203. public function getFileContent($file, $identifier)
  27204. {
  27205. return $this->perforce->getFileContent($file, $identifier);
  27206. }
  27207. public function getChangeDate($identifier)
  27208. {
  27209. return null;
  27210. }
  27211. public function getRootIdentifier()
  27212. {
  27213. return $this->branch;
  27214. }
  27215. public function getBranches()
  27216. {
  27217. return $this->perforce->getBranches();
  27218. }
  27219. public function getTags()
  27220. {
  27221. return $this->perforce->getTags();
  27222. }
  27223. public function getDist($identifier)
  27224. {
  27225. return null;
  27226. }
  27227. public function getSource($identifier)
  27228. {
  27229. return array(
  27230. 'type' => 'perforce',
  27231. 'url' => $this->repoConfig['url'],
  27232. 'reference' => $identifier,
  27233. 'p4user' => $this->perforce->getUser(),
  27234. );
  27235. }
  27236. public function getUrl()
  27237. {
  27238. return $this->url;
  27239. }
  27240. public function hasComposerFile($identifier)
  27241. {
  27242. $composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
  27243. return !empty($composerInfo);
  27244. }
  27245. public function getContents($url)
  27246. {
  27247. return false;
  27248. }
  27249. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27250. {
  27251. if ($deep || preg_match('#\b(perforce|p4)\b#i', $url)) {
  27252. return Perforce::checkServerExists($url, new ProcessExecutor($io));
  27253. }
  27254. return false;
  27255. }
  27256. public function cleanup()
  27257. {
  27258. $this->perforce->cleanupClientSpec();
  27259. $this->perforce = null;
  27260. }
  27261. public function getDepot()
  27262. {
  27263. return $this->depot;
  27264. }
  27265. public function getBranch()
  27266. {
  27267. return $this->branch;
  27268. }
  27269. }
  27270. <?php
  27271. namespace Composer\Repository\Vcs;
  27272. use Composer\Cache;
  27273. use Composer\Config;
  27274. use Composer\Json\JsonFile;
  27275. use Composer\Util\ProcessExecutor;
  27276. use Composer\Util\Filesystem;
  27277. use Composer\Util\Url;
  27278. use Composer\Util\Svn as SvnUtil;
  27279. use Composer\IO\IOInterface;
  27280. use Composer\Downloader\TransportException;
  27281. class SvnDriver extends VcsDriver
  27282. {
  27283. protected $baseUrl;
  27284. protected $tags;
  27285. protected $branches;
  27286. protected $rootIdentifier;
  27287. protected $trunkPath = 'trunk';
  27288. protected $branchesPath = 'branches';
  27289. protected $tagsPath = 'tags';
  27290. protected $packagePath = '';
  27291. protected $cacheCredentials = true;
  27292. private $util;
  27293. public function initialize()
  27294. {
  27295. $this->url = $this->baseUrl = rtrim(self::normalizeUrl($this->url), '/');
  27296. SvnUtil::cleanEnv();
  27297. if (isset($this->repoConfig['trunk-path'])) {
  27298. $this->trunkPath = $this->repoConfig['trunk-path'];
  27299. }
  27300. if (isset($this->repoConfig['branches-path'])) {
  27301. $this->branchesPath = $this->repoConfig['branches-path'];
  27302. }
  27303. if (isset($this->repoConfig['tags-path'])) {
  27304. $this->tagsPath = $this->repoConfig['tags-path'];
  27305. }
  27306. if (array_key_exists('svn-cache-credentials', $this->repoConfig)) {
  27307. $this->cacheCredentials = (bool) $this->repoConfig['svn-cache-credentials'];
  27308. }
  27309. if (isset($this->repoConfig['package-path'])) {
  27310. $this->packagePath = '/' . trim($this->repoConfig['package-path'], '/');
  27311. }
  27312. if (false !== ($pos = strrpos($this->url, '/' . $this->trunkPath))) {
  27313. $this->baseUrl = substr($this->url, 0, $pos);
  27314. }
  27315. $this->cache = new Cache($this->io, $this->config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', Url::sanitize($this->baseUrl)));
  27316. $this->cache->setReadOnly($this->config->get('cache-read-only'));
  27317. $this->getBranches();
  27318. $this->getTags();
  27319. }
  27320. public function getRootIdentifier()
  27321. {
  27322. return $this->rootIdentifier ?: $this->trunkPath;
  27323. }
  27324. public function getUrl()
  27325. {
  27326. return $this->url;
  27327. }
  27328. public function getSource($identifier)
  27329. {
  27330. return array('type' => 'svn', 'url' => $this->baseUrl, 'reference' => $identifier);
  27331. }
  27332. public function getDist($identifier)
  27333. {
  27334. return null;
  27335. }
  27336. protected function shouldCache($identifier)
  27337. {
  27338. return $this->cache && preg_match('{@\d+$}', $identifier);
  27339. }
  27340. public function getComposerInformation($identifier)
  27341. {
  27342. if (!isset($this->infoCache[$identifier])) {
  27343. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier.'.json')) {
  27344. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  27345. }
  27346. try {
  27347. $composer = $this->getBaseComposerInformation($identifier);
  27348. } catch (TransportException $e) {
  27349. $message = $e->getMessage();
  27350. if (stripos($message, 'path not found') === false && stripos($message, 'svn: warning: W160013') === false) {
  27351. throw $e;
  27352. }
  27353. $composer = '';
  27354. }
  27355. if ($this->shouldCache($identifier)) {
  27356. $this->cache->write($identifier.'.json', json_encode($composer));
  27357. }
  27358. $this->infoCache[$identifier] = $composer;
  27359. }
  27360. return $this->infoCache[$identifier];
  27361. }
  27362. public function getFileContent($file, $identifier)
  27363. {
  27364. $identifier = '/' . trim($identifier, '/') . '/';
  27365. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  27366. if (!empty($match[2])) {
  27367. $path = $match[1];
  27368. $rev = $match[2];
  27369. } else {
  27370. $path = $identifier;
  27371. $rev = '';
  27372. }
  27373. try {
  27374. $resource = $path.$file;
  27375. $output = $this->execute('svn cat', $this->baseUrl . $resource . $rev);
  27376. if (!trim($output)) {
  27377. return null;
  27378. }
  27379. } catch (\RuntimeException $e) {
  27380. throw new TransportException($e->getMessage());
  27381. }
  27382. return $output;
  27383. }
  27384. public function getChangeDate($identifier)
  27385. {
  27386. $identifier = '/' . trim($identifier, '/') . '/';
  27387. preg_match('{^(.+?)(@\d+)?/$}', $identifier, $match);
  27388. if (!empty($match[2])) {
  27389. $path = $match[1];
  27390. $rev = $match[2];
  27391. } else {
  27392. $path = $identifier;
  27393. $rev = '';
  27394. }
  27395. $output = $this->execute('svn info', $this->baseUrl . $path . $rev);
  27396. foreach ($this->process->splitLines($output) as $line) {
  27397. if ($line && preg_match('{^Last Changed Date: ([^(]+)}', $line, $match)) {
  27398. return new \DateTime($match[1], new \DateTimeZone('UTC'));
  27399. }
  27400. }
  27401. return null;
  27402. }
  27403. public function getTags()
  27404. {
  27405. if (null === $this->tags) {
  27406. $this->tags = array();
  27407. if ($this->tagsPath !== false) {
  27408. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->tagsPath);
  27409. if ($output) {
  27410. foreach ($this->process->splitLines($output) as $line) {
  27411. $line = trim($line);
  27412. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27413. if (isset($match[1], $match[2]) && $match[2] !== './') {
  27414. $this->tags[rtrim($match[2], '/')] = $this->buildIdentifier(
  27415. '/' . $this->tagsPath . '/' . $match[2],
  27416. $match[1]
  27417. );
  27418. }
  27419. }
  27420. }
  27421. }
  27422. }
  27423. }
  27424. return $this->tags;
  27425. }
  27426. public function getBranches()
  27427. {
  27428. if (null === $this->branches) {
  27429. $this->branches = array();
  27430. if (false === $this->trunkPath) {
  27431. $trunkParent = $this->baseUrl . '/';
  27432. } else {
  27433. $trunkParent = $this->baseUrl . '/' . $this->trunkPath;
  27434. }
  27435. $output = $this->execute('svn ls --verbose', $trunkParent);
  27436. if ($output) {
  27437. foreach ($this->process->splitLines($output) as $line) {
  27438. $line = trim($line);
  27439. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27440. if (isset($match[1], $match[2]) && $match[2] === './') {
  27441. $this->branches['trunk'] = $this->buildIdentifier(
  27442. '/' . $this->trunkPath,
  27443. $match[1]
  27444. );
  27445. $this->rootIdentifier = $this->branches['trunk'];
  27446. break;
  27447. }
  27448. }
  27449. }
  27450. }
  27451. unset($output);
  27452. if ($this->branchesPath !== false) {
  27453. $output = $this->execute('svn ls --verbose', $this->baseUrl . '/' . $this->branchesPath);
  27454. if ($output) {
  27455. foreach ($this->process->splitLines(trim($output)) as $line) {
  27456. $line = trim($line);
  27457. if ($line && preg_match('{^\s*(\S+).*?(\S+)\s*$}', $line, $match)) {
  27458. if (isset($match[1], $match[2]) && $match[2] !== './') {
  27459. $this->branches[rtrim($match[2], '/')] = $this->buildIdentifier(
  27460. '/' . $this->branchesPath . '/' . $match[2],
  27461. $match[1]
  27462. );
  27463. }
  27464. }
  27465. }
  27466. }
  27467. }
  27468. }
  27469. return $this->branches;
  27470. }
  27471. public static function supports(IOInterface $io, Config $config, $url, $deep = false)
  27472. {
  27473. $url = self::normalizeUrl($url);
  27474. if (preg_match('#(^svn://|^svn\+ssh://|svn\.)#i', $url)) {
  27475. return true;
  27476. }
  27477. if (!$deep && !Filesystem::isLocalPath($url)) {
  27478. return false;
  27479. }
  27480. $process = new ProcessExecutor($io);
  27481. $exit = $process->execute(
  27482. "svn info --non-interactive ".ProcessExecutor::escape($url),
  27483. $ignoredOutput
  27484. );
  27485. if ($exit === 0) {
  27486. return true;
  27487. }
  27488. if (false !== stripos($process->getErrorOutput(), 'authorization failed:')) {
  27489. return true;
  27490. }
  27491. if (false !== stripos($process->getErrorOutput(), 'Authentication failed')) {
  27492. return true;
  27493. }
  27494. return false;
  27495. }
  27496. protected static function normalizeUrl($url)
  27497. {
  27498. $fs = new Filesystem();
  27499. if ($fs->isAbsolutePath($url)) {
  27500. return 'file://' . strtr($url, '\\', '/');
  27501. }
  27502. return $url;
  27503. }
  27504. protected function execute($command, $url)
  27505. {
  27506. if (null === $this->util) {
  27507. $this->util = new SvnUtil($this->baseUrl, $this->io, $this->config, $this->process);
  27508. $this->util->setCacheCredentials($this->cacheCredentials);
  27509. }
  27510. try {
  27511. return $this->util->execute($command, $url);
  27512. } catch (\RuntimeException $e) {
  27513. if (null === $this->util->binaryVersion()) {
  27514. 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());
  27515. }
  27516. throw new \RuntimeException(
  27517. 'Repository '.$this->url.' could not be processed, '.$e->getMessage()
  27518. );
  27519. }
  27520. }
  27521. protected function buildIdentifier($baseDir, $revision)
  27522. {
  27523. return rtrim($baseDir, '/') . $this->packagePath . '/@' . $revision;
  27524. }
  27525. }
  27526. <?php
  27527. namespace Composer\Repository\Vcs;
  27528. use Composer\Cache;
  27529. use Composer\Downloader\TransportException;
  27530. use Composer\Config;
  27531. use Composer\IO\IOInterface;
  27532. use Composer\Json\JsonFile;
  27533. use Composer\Util\ProcessExecutor;
  27534. use Composer\Util\HttpDownloader;
  27535. use Composer\Util\Filesystem;
  27536. use Composer\Util\Http\Response;
  27537. abstract class VcsDriver implements VcsDriverInterface
  27538. {
  27539. protected $url;
  27540. protected $originUrl;
  27541. protected $repoConfig;
  27542. protected $io;
  27543. protected $config;
  27544. protected $process;
  27545. protected $httpDownloader;
  27546. protected $infoCache = array();
  27547. protected $cache;
  27548. final public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, ProcessExecutor $process)
  27549. {
  27550. if (Filesystem::isLocalPath($repoConfig['url'])) {
  27551. $repoConfig['url'] = Filesystem::getPlatformPath($repoConfig['url']);
  27552. }
  27553. $this->url = $repoConfig['url'];
  27554. $this->originUrl = $repoConfig['url'];
  27555. $this->repoConfig = $repoConfig;
  27556. $this->io = $io;
  27557. $this->config = $config;
  27558. $this->httpDownloader = $httpDownloader;
  27559. $this->process = $process;
  27560. }
  27561. protected function shouldCache($identifier)
  27562. {
  27563. return $this->cache && preg_match('{^[a-f0-9]{40}$}iD', $identifier);
  27564. }
  27565. public function getComposerInformation($identifier)
  27566. {
  27567. if (!isset($this->infoCache[$identifier])) {
  27568. if ($this->shouldCache($identifier) && $res = $this->cache->read($identifier)) {
  27569. return $this->infoCache[$identifier] = JsonFile::parseJson($res);
  27570. }
  27571. $composer = $this->getBaseComposerInformation($identifier);
  27572. if ($this->shouldCache($identifier)) {
  27573. $this->cache->write($identifier, json_encode($composer));
  27574. }
  27575. $this->infoCache[$identifier] = $composer;
  27576. }
  27577. return $this->infoCache[$identifier];
  27578. }
  27579. protected function getBaseComposerInformation($identifier)
  27580. {
  27581. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  27582. if (!$composerFileContent) {
  27583. return null;
  27584. }
  27585. $composer = JsonFile::parseJson($composerFileContent, $identifier . ':composer.json');
  27586. if (empty($composer['time']) && $changeDate = $this->getChangeDate($identifier)) {
  27587. $composer['time'] = $changeDate->format(DATE_RFC3339);
  27588. }
  27589. return $composer;
  27590. }
  27591. public function hasComposerFile($identifier)
  27592. {
  27593. try {
  27594. return (bool) $this->getComposerInformation($identifier);
  27595. } catch (TransportException $e) {
  27596. }
  27597. return false;
  27598. }
  27599. protected function getScheme()
  27600. {
  27601. if (extension_loaded('openssl')) {
  27602. return 'https';
  27603. }
  27604. return 'http';
  27605. }
  27606. protected function getContents($url)
  27607. {
  27608. $options = isset($this->repoConfig['options']) ? $this->repoConfig['options'] : array();
  27609. return $this->httpDownloader->get($url, $options);
  27610. }
  27611. public function cleanup()
  27612. {
  27613. return;
  27614. }
  27615. }
  27616. <?php
  27617. namespace Composer\Repository\Vcs;
  27618. use Composer\Config;
  27619. use Composer\IO\IOInterface;
  27620. interface VcsDriverInterface
  27621. {
  27622. public function initialize();
  27623. public function getComposerInformation($identifier);
  27624. public function getFileContent($file, $identifier);
  27625. public function getChangeDate($identifier);
  27626. public function getRootIdentifier();
  27627. public function getBranches();
  27628. public function getTags();
  27629. public function getDist($identifier);
  27630. public function getSource($identifier);
  27631. public function getUrl();
  27632. public function hasComposerFile($identifier);
  27633. public function cleanup();
  27634. public static function supports(IOInterface $io, Config $config, $url, $deep = false);
  27635. }
  27636. <?php
  27637. namespace Composer\Repository;
  27638. use Composer\Downloader\TransportException;
  27639. use Composer\Repository\Vcs\VcsDriverInterface;
  27640. use Composer\Package\Version\VersionParser;
  27641. use Composer\Package\Loader\ArrayLoader;
  27642. use Composer\Package\Loader\ValidatingArrayLoader;
  27643. use Composer\Package\Loader\InvalidPackageException;
  27644. use Composer\Package\Loader\LoaderInterface;
  27645. use Composer\EventDispatcher\EventDispatcher;
  27646. use Composer\Util\ProcessExecutor;
  27647. use Composer\Util\HttpDownloader;
  27648. use Composer\Util\Url;
  27649. use Composer\Semver\Constraint\Constraint;
  27650. use Composer\IO\IOInterface;
  27651. use Composer\Config;
  27652. class VcsRepository extends ArrayRepository implements ConfigurableRepositoryInterface
  27653. {
  27654. protected $url;
  27655. protected $packageName;
  27656. protected $isVerbose;
  27657. protected $isVeryVerbose;
  27658. protected $io;
  27659. protected $config;
  27660. protected $versionParser;
  27661. protected $type;
  27662. protected $loader;
  27663. protected $repoConfig;
  27664. protected $httpDownloader;
  27665. protected $processExecutor;
  27666. protected $branchErrorOccurred = false;
  27667. private $drivers;
  27668. private $driver;
  27669. private $versionCache;
  27670. private $emptyReferences = array();
  27671. private $versionTransportExceptions = array();
  27672. public function __construct(array $repoConfig, IOInterface $io, Config $config, HttpDownloader $httpDownloader, EventDispatcher $dispatcher = null, ProcessExecutor $process = null, array $drivers = null, VersionCacheInterface $versionCache = null)
  27673. {
  27674. parent::__construct();
  27675. $this->drivers = $drivers ?: array(
  27676. 'github' => 'Composer\Repository\Vcs\GitHubDriver',
  27677. 'gitlab' => 'Composer\Repository\Vcs\GitLabDriver',
  27678. 'git-bitbucket' => 'Composer\Repository\Vcs\GitBitbucketDriver',
  27679. 'git' => 'Composer\Repository\Vcs\GitDriver',
  27680. 'hg-bitbucket' => 'Composer\Repository\Vcs\HgBitbucketDriver',
  27681. 'hg' => 'Composer\Repository\Vcs\HgDriver',
  27682. 'perforce' => 'Composer\Repository\Vcs\PerforceDriver',
  27683. 'fossil' => 'Composer\Repository\Vcs\FossilDriver',
  27684. 'svn' => 'Composer\Repository\Vcs\SvnDriver',
  27685. );
  27686. $this->url = $repoConfig['url'];
  27687. $this->io = $io;
  27688. $this->type = isset($repoConfig['type']) ? $repoConfig['type'] : 'vcs';
  27689. $this->isVerbose = $io->isVerbose();
  27690. $this->isVeryVerbose = $io->isVeryVerbose();
  27691. $this->config = $config;
  27692. $this->repoConfig = $repoConfig;
  27693. $this->versionCache = $versionCache;
  27694. $this->httpDownloader = $httpDownloader;
  27695. $this->processExecutor = $process ?: new ProcessExecutor($io);
  27696. }
  27697. public function getRepoName()
  27698. {
  27699. $driverClass = get_class($this->getDriver());
  27700. $driverType = array_search($driverClass, $this->drivers);
  27701. if (!$driverType) {
  27702. $driverType = $driverClass;
  27703. }
  27704. return 'vcs repo ('.$driverType.' '.Url::sanitize($this->url).')';
  27705. }
  27706. public function getRepoConfig()
  27707. {
  27708. return $this->repoConfig;
  27709. }
  27710. public function setLoader(LoaderInterface $loader)
  27711. {
  27712. $this->loader = $loader;
  27713. }
  27714. public function getDriver()
  27715. {
  27716. if ($this->driver) {
  27717. return $this->driver;
  27718. }
  27719. if (isset($this->drivers[$this->type])) {
  27720. $class = $this->drivers[$this->type];
  27721. $this->driver = new $class($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27722. $this->driver->initialize();
  27723. return $this->driver;
  27724. }
  27725. foreach ($this->drivers as $driver) {
  27726. if ($driver::supports($this->io, $this->config, $this->url)) {
  27727. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27728. $this->driver->initialize();
  27729. return $this->driver;
  27730. }
  27731. }
  27732. foreach ($this->drivers as $driver) {
  27733. if ($driver::supports($this->io, $this->config, $this->url, true)) {
  27734. $this->driver = new $driver($this->repoConfig, $this->io, $this->config, $this->httpDownloader, $this->processExecutor);
  27735. $this->driver->initialize();
  27736. return $this->driver;
  27737. }
  27738. }
  27739. }
  27740. public function hadInvalidBranches()
  27741. {
  27742. return $this->branchErrorOccurred;
  27743. }
  27744. public function getEmptyReferences()
  27745. {
  27746. return $this->emptyReferences;
  27747. }
  27748. public function getVersionTransportExceptions()
  27749. {
  27750. return $this->versionTransportExceptions;
  27751. }
  27752. protected function initialize()
  27753. {
  27754. parent::initialize();
  27755. $isVerbose = $this->isVerbose;
  27756. $isVeryVerbose = $this->isVeryVerbose;
  27757. $driver = $this->getDriver();
  27758. if (!$driver) {
  27759. throw new \InvalidArgumentException('No driver found to handle VCS repository '.$this->url);
  27760. }
  27761. $this->versionParser = new VersionParser;
  27762. if (!$this->loader) {
  27763. $this->loader = new ArrayLoader($this->versionParser);
  27764. }
  27765. $hasRootIdentifierComposerJson = false;
  27766. try {
  27767. $hasRootIdentifierComposerJson = $driver->hasComposerFile($driver->getRootIdentifier());
  27768. if ($hasRootIdentifierComposerJson) {
  27769. $data = $driver->getComposerInformation($driver->getRootIdentifier());
  27770. $this->packageName = !empty($data['name']) ? $data['name'] : null;
  27771. }
  27772. } catch (\Exception $e) {
  27773. if ($isVeryVerbose) {
  27774. $this->io->writeError('<error>Skipped parsing '.$driver->getRootIdentifier().', '.$e->getMessage().'</error>');
  27775. }
  27776. }
  27777. foreach ($driver->getTags() as $tag => $identifier) {
  27778. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $tag . '</comment>)';
  27779. if ($isVeryVerbose) {
  27780. $this->io->writeError($msg);
  27781. } elseif ($isVerbose) {
  27782. $this->io->overwriteError($msg, false);
  27783. }
  27784. $tag = str_replace('release-', '', $tag);
  27785. $cachedPackage = $this->getCachedPackageVersion($tag, $identifier, $isVerbose, $isVeryVerbose);
  27786. if ($cachedPackage) {
  27787. $this->addPackage($cachedPackage);
  27788. continue;
  27789. }
  27790. if ($cachedPackage === false) {
  27791. $this->emptyReferences[] = $identifier;
  27792. continue;
  27793. }
  27794. if (!$parsedTag = $this->validateTag($tag)) {
  27795. if ($isVeryVerbose) {
  27796. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name</warning>');
  27797. }
  27798. continue;
  27799. }
  27800. try {
  27801. if (!$data = $driver->getComposerInformation($identifier)) {
  27802. if ($isVeryVerbose) {
  27803. $this->io->writeError('<warning>Skipped tag '.$tag.', no composer file</warning>');
  27804. }
  27805. $this->emptyReferences[] = $identifier;
  27806. continue;
  27807. }
  27808. if (isset($data['version'])) {
  27809. $data['version_normalized'] = $this->versionParser->normalize($data['version']);
  27810. } else {
  27811. $data['version'] = $tag;
  27812. $data['version_normalized'] = $parsedTag;
  27813. }
  27814. $data['version'] = preg_replace('{[.-]?dev$}i', '', $data['version']);
  27815. $data['version_normalized'] = preg_replace('{(^dev-|[.-]?dev$)}i', '', $data['version_normalized']);
  27816. unset($data['default-branch']);
  27817. if ($data['version_normalized'] !== $parsedTag) {
  27818. if ($isVeryVerbose) {
  27819. if (preg_match('{(^dev-|[.-]?dev$)}i', $parsedTag)) {
  27820. $this->io->writeError('<warning>Skipped tag '.$tag.', invalid tag name, tags can not use dev prefixes or suffixes</warning>');
  27821. } else {
  27822. $this->io->writeError('<warning>Skipped tag '.$tag.', tag ('.$parsedTag.') does not match version ('.$data['version_normalized'].') in composer.json</warning>');
  27823. }
  27824. }
  27825. continue;
  27826. }
  27827. $tagPackageName = isset($data['name']) ? $data['name'] : $this->packageName;
  27828. if ($existingPackage = $this->findPackage($tagPackageName, $data['version_normalized'])) {
  27829. if ($isVeryVerbose) {
  27830. $this->io->writeError('<warning>Skipped tag '.$tag.', it conflicts with an another tag ('.$existingPackage->getPrettyVersion().') as both resolve to '.$data['version_normalized'].' internally</warning>');
  27831. }
  27832. continue;
  27833. }
  27834. if ($isVeryVerbose) {
  27835. $this->io->writeError('Importing tag '.$tag.' ('.$data['version_normalized'].')');
  27836. }
  27837. $this->addPackage($this->loader->load($this->preProcess($driver, $data, $identifier)));
  27838. } catch (\Exception $e) {
  27839. if ($e instanceof TransportException) {
  27840. $this->versionTransportExceptions['tags'][$tag] = $e;
  27841. if ($e->getCode() === 404) {
  27842. $this->emptyReferences[] = $identifier;
  27843. }
  27844. if ($e->getCode() === 401 || $e->getCode() === 403) {
  27845. throw $e;
  27846. }
  27847. }
  27848. if ($isVeryVerbose) {
  27849. $this->io->writeError('<warning>Skipped tag '.$tag.', '.($e instanceof TransportException ? 'no composer file was found (' . $e->getCode() . ' HTTP status code)' : $e->getMessage()).'</warning>');
  27850. }
  27851. continue;
  27852. }
  27853. }
  27854. if (!$isVeryVerbose) {
  27855. $this->io->overwriteError('', false);
  27856. }
  27857. $branches = $driver->getBranches();
  27858. if ($hasRootIdentifierComposerJson && isset($branches[$driver->getRootIdentifier()])) {
  27859. $branches = array($driver->getRootIdentifier() => $branches[$driver->getRootIdentifier()]) + $branches;
  27860. }
  27861. foreach ($branches as $branch => $identifier) {
  27862. $msg = 'Reading composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $branch . '</comment>)';
  27863. if ($isVeryVerbose) {
  27864. $this->io->writeError($msg);
  27865. } elseif ($isVerbose) {
  27866. $this->io->overwriteError($msg, false);
  27867. }
  27868. if (!$parsedBranch = $this->validateBranch($branch)) {
  27869. if ($isVeryVerbose) {
  27870. $this->io->writeError('<warning>Skipped branch '.$branch.', invalid name</warning>');
  27871. }
  27872. continue;
  27873. }
  27874. if (strpos($parsedBranch, 'dev-') === 0 || VersionParser::DEFAULT_BRANCH_ALIAS === $parsedBranch) {
  27875. $version = 'dev-' . $branch;
  27876. } else {
  27877. $prefix = strpos($branch, 'v') === 0 ? 'v' : '';
  27878. $version = $prefix . preg_replace('{(\.9{7})+}', '.x', $parsedBranch);
  27879. }
  27880. $cachedPackage = $this->getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $driver->getRootIdentifier() === $branch);
  27881. if ($cachedPackage) {
  27882. $this->addPackage($cachedPackage);
  27883. continue;
  27884. }
  27885. if ($cachedPackage === false) {
  27886. $this->emptyReferences[] = $identifier;
  27887. continue;
  27888. }
  27889. try {
  27890. if (!$data = $driver->getComposerInformation($identifier)) {
  27891. if ($isVeryVerbose) {
  27892. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file</warning>');
  27893. }
  27894. $this->emptyReferences[] = $identifier;
  27895. continue;
  27896. }
  27897. $data['version'] = $version;
  27898. $data['version_normalized'] = $parsedBranch;
  27899. unset($data['default-branch']);
  27900. if ($driver->getRootIdentifier() === $branch) {
  27901. $data['default-branch'] = true;
  27902. }
  27903. if ($isVeryVerbose) {
  27904. $this->io->writeError('Importing branch '.$branch.' ('.$data['version'].')');
  27905. }
  27906. $packageData = $this->preProcess($driver, $data, $identifier);
  27907. $package = $this->loader->load($packageData);
  27908. if ($this->loader instanceof ValidatingArrayLoader && $this->loader->getWarnings()) {
  27909. throw new InvalidPackageException($this->loader->getErrors(), $this->loader->getWarnings(), $packageData);
  27910. }
  27911. $this->addPackage($package);
  27912. } catch (TransportException $e) {
  27913. $this->versionTransportExceptions['branches'][$branch] = $e;
  27914. if ($e->getCode() === 404) {
  27915. $this->emptyReferences[] = $identifier;
  27916. }
  27917. if ($e->getCode() === 401 || $e->getCode() === 403) {
  27918. throw $e;
  27919. }
  27920. if ($isVeryVerbose) {
  27921. $this->io->writeError('<warning>Skipped branch '.$branch.', no composer file was found (' . $e->getCode() . ' HTTP status code)</warning>');
  27922. }
  27923. continue;
  27924. } catch (\Exception $e) {
  27925. if (!$isVeryVerbose) {
  27926. $this->io->writeError('');
  27927. }
  27928. $this->branchErrorOccurred = true;
  27929. $this->io->writeError('<error>Skipped branch '.$branch.', '.$e->getMessage().'</error>');
  27930. $this->io->writeError('');
  27931. continue;
  27932. }
  27933. }
  27934. $driver->cleanup();
  27935. if (!$isVeryVerbose) {
  27936. $this->io->overwriteError('', false);
  27937. }
  27938. if (!$this->getPackages()) {
  27939. throw new InvalidRepositoryException('No valid composer.json was found in any branch or tag of '.$this->url.', could not load a package from it.');
  27940. }
  27941. }
  27942. protected function preProcess(VcsDriverInterface $driver, array $data, $identifier)
  27943. {
  27944. $dataPackageName = isset($data['name']) ? $data['name'] : null;
  27945. $data['name'] = $this->packageName ?: $dataPackageName;
  27946. if (!isset($data['dist'])) {
  27947. $data['dist'] = $driver->getDist($identifier);
  27948. }
  27949. if (!isset($data['source'])) {
  27950. $data['source'] = $driver->getSource($identifier);
  27951. }
  27952. return $data;
  27953. }
  27954. private function validateBranch($branch)
  27955. {
  27956. try {
  27957. $normalizedBranch = $this->versionParser->normalizeBranch($branch);
  27958. $this->versionParser->parseConstraints($normalizedBranch);
  27959. return $normalizedBranch;
  27960. } catch (\Exception $e) {
  27961. }
  27962. return false;
  27963. }
  27964. private function validateTag($version)
  27965. {
  27966. try {
  27967. return $this->versionParser->normalize($version);
  27968. } catch (\Exception $e) {
  27969. }
  27970. return false;
  27971. }
  27972. private function getCachedPackageVersion($version, $identifier, $isVerbose, $isVeryVerbose, $isDefaultBranch = false)
  27973. {
  27974. if (!$this->versionCache) {
  27975. return;
  27976. }
  27977. $cachedPackage = $this->versionCache->getVersionPackage($version, $identifier);
  27978. if ($cachedPackage === false) {
  27979. if ($isVeryVerbose) {
  27980. $this->io->writeError('<warning>Skipped '.$version.', no composer file (cached from ref '.$identifier.')</warning>');
  27981. }
  27982. return false;
  27983. }
  27984. if ($cachedPackage) {
  27985. $msg = 'Found cached composer.json of <info>' . ($this->packageName ?: $this->url) . '</info> (<comment>' . $version . '</comment>)';
  27986. if ($isVeryVerbose) {
  27987. $this->io->writeError($msg);
  27988. } elseif ($isVerbose) {
  27989. $this->io->overwriteError($msg, false);
  27990. }
  27991. unset($cachedPackage['default-branch']);
  27992. if ($isDefaultBranch) {
  27993. $cachedPackage['default-branch'] = true;
  27994. }
  27995. if ($existingPackage = $this->findPackage($cachedPackage['name'], new Constraint('=', $cachedPackage['version_normalized']))) {
  27996. if ($isVeryVerbose) {
  27997. $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>');
  27998. }
  27999. $cachedPackage = null;
  28000. }
  28001. }
  28002. if ($cachedPackage) {
  28003. return $this->loader->load($cachedPackage);
  28004. }
  28005. return null;
  28006. }
  28007. }
  28008. <?php
  28009. namespace Composer\Repository;
  28010. interface VersionCacheInterface
  28011. {
  28012. public function getVersionPackage($version, $identifier);
  28013. }
  28014. <?php
  28015. namespace Composer\Repository;
  28016. use Composer\Package\AliasPackage;
  28017. use Composer\Installer\InstallationManager;
  28018. class WritableArrayRepository extends ArrayRepository implements WritableRepositoryInterface
  28019. {
  28020. protected $devPackageNames = array();
  28021. public function setDevPackageNames(array $devPackageNames)
  28022. {
  28023. $this->devPackageNames = $devPackageNames;
  28024. }
  28025. public function getDevPackageNames()
  28026. {
  28027. return $this->devPackageNames;
  28028. }
  28029. public function write($devMode, InstallationManager $installationManager)
  28030. {
  28031. }
  28032. public function reload()
  28033. {
  28034. }
  28035. public function getCanonicalPackages()
  28036. {
  28037. $packages = $this->getPackages();
  28038. $packagesByName = array();
  28039. foreach ($packages as $package) {
  28040. if (!isset($packagesByName[$package->getName()]) || $packagesByName[$package->getName()] instanceof AliasPackage) {
  28041. $packagesByName[$package->getName()] = $package;
  28042. }
  28043. }
  28044. $canonicalPackages = array();
  28045. foreach ($packagesByName as $package) {
  28046. while ($package instanceof AliasPackage) {
  28047. $package = $package->getAliasOf();
  28048. }
  28049. $canonicalPackages[] = $package;
  28050. }
  28051. return $canonicalPackages;
  28052. }
  28053. }
  28054. <?php
  28055. namespace Composer\Repository;
  28056. use Composer\Package\PackageInterface;
  28057. use Composer\Installer\InstallationManager;
  28058. interface WritableRepositoryInterface extends RepositoryInterface
  28059. {
  28060. public function write($devMode, InstallationManager $installationManager);
  28061. public function addPackage(PackageInterface $package);
  28062. public function removePackage(PackageInterface $package);
  28063. public function getCanonicalPackages();
  28064. public function reload();
  28065. public function setDevPackageNames(array $devPackageNames);
  28066. public function getDevPackageNames();
  28067. }
  28068. <?php
  28069. namespace Composer\Script;
  28070. use Composer\Composer;
  28071. use Composer\IO\IOInterface;
  28072. use Composer\EventDispatcher\Event as BaseEvent;
  28073. class Event extends BaseEvent
  28074. {
  28075. private $composer;
  28076. private $io;
  28077. private $devMode;
  28078. private $originatingEvent;
  28079. public function __construct($name, Composer $composer, IOInterface $io, $devMode = false, array $args = array(), array $flags = array())
  28080. {
  28081. parent::__construct($name, $args, $flags);
  28082. $this->composer = $composer;
  28083. $this->io = $io;
  28084. $this->devMode = $devMode;
  28085. }
  28086. public function getComposer()
  28087. {
  28088. return $this->composer;
  28089. }
  28090. public function getIO()
  28091. {
  28092. return $this->io;
  28093. }
  28094. public function isDevMode()
  28095. {
  28096. return $this->devMode;
  28097. }
  28098. public function getOriginatingEvent()
  28099. {
  28100. return $this->originatingEvent;
  28101. }
  28102. public function setOriginatingEvent(BaseEvent $event)
  28103. {
  28104. $this->originatingEvent = $this->calculateOriginatingEvent($event);
  28105. return $this;
  28106. }
  28107. private function calculateOriginatingEvent(BaseEvent $event)
  28108. {
  28109. if ($event instanceof Event && $event->getOriginatingEvent()) {
  28110. return $this->calculateOriginatingEvent($event->getOriginatingEvent());
  28111. }
  28112. return $event;
  28113. }
  28114. }
  28115. <?php
  28116. namespace Composer\Script;
  28117. class ScriptEvents
  28118. {
  28119. const PRE_INSTALL_CMD = 'pre-install-cmd';
  28120. const POST_INSTALL_CMD = 'post-install-cmd';
  28121. const PRE_UPDATE_CMD = 'pre-update-cmd';
  28122. const POST_UPDATE_CMD = 'post-update-cmd';
  28123. const PRE_STATUS_CMD = 'pre-status-cmd';
  28124. const POST_STATUS_CMD = 'post-status-cmd';
  28125. const PRE_AUTOLOAD_DUMP = 'pre-autoload-dump';
  28126. const POST_AUTOLOAD_DUMP = 'post-autoload-dump';
  28127. const POST_ROOT_PACKAGE_INSTALL = 'post-root-package-install';
  28128. const POST_CREATE_PROJECT_CMD = 'post-create-project-cmd';
  28129. const PRE_ARCHIVE_CMD = 'pre-archive-cmd';
  28130. const POST_ARCHIVE_CMD = 'post-archive-cmd';
  28131. }
  28132. <?php
  28133. namespace Composer\SelfUpdate;
  28134. class Keys
  28135. {
  28136. public static function fingerprint($path)
  28137. {
  28138. $hash = strtoupper(hash('sha256', preg_replace('{\s}', '', file_get_contents($path))));
  28139. return implode(' ', array(
  28140. substr($hash, 0, 8),
  28141. substr($hash, 8, 8),
  28142. substr($hash, 16, 8),
  28143. substr($hash, 24, 8),
  28144. '',
  28145. substr($hash, 32, 8),
  28146. substr($hash, 40, 8),
  28147. substr($hash, 48, 8),
  28148. substr($hash, 56, 8),
  28149. ));
  28150. }
  28151. }
  28152. <?php
  28153. namespace Composer\SelfUpdate;
  28154. use Composer\Util\HttpDownloader;
  28155. use Composer\Config;
  28156. class Versions
  28157. {
  28158. public static $channels = array('stable', 'preview', 'snapshot', '1', '2');
  28159. private $httpDownloader;
  28160. private $config;
  28161. private $channel;
  28162. private $versionsData;
  28163. public function __construct(Config $config, HttpDownloader $httpDownloader)
  28164. {
  28165. $this->httpDownloader = $httpDownloader;
  28166. $this->config = $config;
  28167. }
  28168. public function getChannel()
  28169. {
  28170. if ($this->channel) {
  28171. return $this->channel;
  28172. }
  28173. $channelFile = $this->config->get('home').'/update-channel';
  28174. if (file_exists($channelFile)) {
  28175. $channel = trim(file_get_contents($channelFile));
  28176. if (in_array($channel, array('stable', 'preview', 'snapshot'), true)) {
  28177. return $this->channel = $channel;
  28178. }
  28179. }
  28180. return $this->channel = 'stable';
  28181. }
  28182. public function setChannel($channel)
  28183. {
  28184. if (!in_array($channel, self::$channels, true)) {
  28185. throw new \InvalidArgumentException('Invalid channel '.$channel.', must be one of: ' . implode(', ', self::$channels));
  28186. }
  28187. $channelFile = $this->config->get('home').'/update-channel';
  28188. $this->channel = $channel;
  28189. file_put_contents($channelFile, (is_numeric($channel) ? 'stable' : $channel).PHP_EOL);
  28190. }
  28191. public function getLatest($channel = null)
  28192. {
  28193. $versions = $this->getVersionsData();
  28194. foreach ($versions[$channel ?: $this->getChannel()] as $version) {
  28195. if ($version['min-php'] <= PHP_VERSION_ID) {
  28196. return $version;
  28197. }
  28198. }
  28199. throw new \UnexpectedValueException('There is no version of Composer available for your PHP version ('.PHP_VERSION.')');
  28200. }
  28201. private function getVersionsData()
  28202. {
  28203. if (!$this->versionsData) {
  28204. if ($this->config->get('disable-tls') === true) {
  28205. $protocol = 'http';
  28206. } else {
  28207. $protocol = 'https';
  28208. }
  28209. $this->versionsData = $this->httpDownloader->get($protocol . '://getcomposer.org/versions')->decodeJson();
  28210. }
  28211. return $this->versionsData;
  28212. }
  28213. }
  28214. <?php
  28215. namespace Composer\Util;
  28216. use Composer\Config;
  28217. use Composer\IO\IOInterface;
  28218. use Composer\Downloader\TransportException;
  28219. class AuthHelper
  28220. {
  28221. protected $io;
  28222. protected $config;
  28223. private $displayedOriginAuthentications = array();
  28224. public function __construct(IOInterface $io, Config $config)
  28225. {
  28226. $this->io = $io;
  28227. $this->config = $config;
  28228. }
  28229. public function storeAuth($origin, $storeAuth)
  28230. {
  28231. $store = false;
  28232. $configSource = $this->config->getAuthConfigSource();
  28233. if ($storeAuth === true) {
  28234. $store = $configSource;
  28235. } elseif ($storeAuth === 'prompt') {
  28236. $answer = $this->io->askAndValidate(
  28237. 'Do you want to store credentials for '.$origin.' in '.$configSource->getName().' ? [Yn] ',
  28238. function ($value) {
  28239. $input = strtolower(substr(trim($value), 0, 1));
  28240. if (in_array($input, array('y','n'))) {
  28241. return $input;
  28242. }
  28243. throw new \RuntimeException('Please answer (y)es or (n)o');
  28244. },
  28245. null,
  28246. 'y'
  28247. );
  28248. if ($answer === 'y') {
  28249. $store = $configSource;
  28250. }
  28251. }
  28252. if ($store) {
  28253. $store->addConfigSetting(
  28254. 'http-basic.'.$origin,
  28255. $this->io->getAuthentication($origin)
  28256. );
  28257. }
  28258. }
  28259. public function promptAuthIfNeeded($url, $origin, $statusCode, $reason = null, $headers = array())
  28260. {
  28261. $storeAuth = false;
  28262. if (in_array($origin, $this->config->get('github-domains'), true)) {
  28263. $gitHubUtil = new GitHub($this->io, $this->config, null);
  28264. $message = "\n";
  28265. $rateLimited = $gitHubUtil->isRateLimited($headers);
  28266. if ($rateLimited) {
  28267. $rateLimit = $gitHubUtil->getRateLimit($headers);
  28268. if ($this->io->hasAuthentication($origin)) {
  28269. $message = 'Review your configured GitHub OAuth token or enter a new one to go over the API rate limit.';
  28270. } else {
  28271. $message = 'Create a GitHub OAuth token to go over the API rate limit.';
  28272. }
  28273. $message = sprintf(
  28274. '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.',
  28275. $rateLimit['limit'],
  28276. $rateLimit['reset']
  28277. )."\n";
  28278. } else {
  28279. $message .= 'Could not fetch '.$url.', please ';
  28280. if ($this->io->hasAuthentication($origin)) {
  28281. $message .= 'review your configured GitHub OAuth token or enter a new one to access private repos';
  28282. } else {
  28283. $message .= 'create a GitHub OAuth token to access private repos';
  28284. }
  28285. }
  28286. if (!$gitHubUtil->authorizeOAuth($origin)
  28287. && (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($origin, $message))
  28288. ) {
  28289. throw new TransportException('Could not authenticate against '.$origin, 401);
  28290. }
  28291. } elseif (in_array($origin, $this->config->get('gitlab-domains'), true)) {
  28292. $message = "\n".'Could not fetch '.$url.', enter your ' . $origin . ' credentials ' .($statusCode === 401 ? 'to access private repos' : 'to go over the API rate limit');
  28293. $gitLabUtil = new GitLab($this->io, $this->config, null);
  28294. if ($this->io->hasAuthentication($origin) && ($auth = $this->io->getAuthentication($origin)) && in_array($auth['password'], array('gitlab-ci-token', 'private-token', 'oauth2'), true)) {
  28295. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  28296. }
  28297. if (!$gitLabUtil->authorizeOAuth($origin)
  28298. && (!$this->io->isInteractive() || !$gitLabUtil->authorizeOAuthInteractively(parse_url($url, PHP_URL_SCHEME), $origin, $message))
  28299. ) {
  28300. throw new TransportException('Could not authenticate against '.$origin, 401);
  28301. }
  28302. } elseif ($origin === 'bitbucket.org' || $origin === 'api.bitbucket.org') {
  28303. $askForOAuthToken = true;
  28304. $origin = 'bitbucket.org';
  28305. if ($this->io->hasAuthentication($origin)) {
  28306. $auth = $this->io->getAuthentication($origin);
  28307. if ($auth['username'] !== 'x-token-auth') {
  28308. $bitbucketUtil = new Bitbucket($this->io, $this->config);
  28309. $accessToken = $bitbucketUtil->requestToken($origin, $auth['username'], $auth['password']);
  28310. if (!empty($accessToken)) {
  28311. $this->io->setAuthentication($origin, 'x-token-auth', $accessToken);
  28312. $askForOAuthToken = false;
  28313. }
  28314. } else {
  28315. throw new TransportException('Could not authenticate against ' . $origin, 401);
  28316. }
  28317. }
  28318. if ($askForOAuthToken) {
  28319. $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');
  28320. $bitBucketUtil = new Bitbucket($this->io, $this->config);
  28321. if (!$bitBucketUtil->authorizeOAuth($origin)
  28322. && (!$this->io->isInteractive() || !$bitBucketUtil->authorizeOAuthInteractively($origin, $message))
  28323. ) {
  28324. throw new TransportException('Could not authenticate against ' . $origin, 401);
  28325. }
  28326. }
  28327. } else {
  28328. if ($statusCode === 404) {
  28329. return;
  28330. }
  28331. if (!$this->io->isInteractive()) {
  28332. if ($statusCode === 401) {
  28333. $message = "The '" . $url . "' URL required authentication.\nYou must be using the interactive console to authenticate";
  28334. } elseif ($statusCode === 403) {
  28335. $message = "The '" . $url . "' URL could not be accessed: " . $reason;
  28336. } else {
  28337. $message = "Unknown error code '" . $statusCode . "', reason: " . $reason;
  28338. }
  28339. throw new TransportException($message, $statusCode);
  28340. }
  28341. if ($this->io->hasAuthentication($origin)) {
  28342. throw new TransportException("Invalid credentials for '" . $url . "', aborting.", $statusCode);
  28343. }
  28344. $this->io->writeError(' Authentication required (<info>'.$origin.'</info>):');
  28345. $username = $this->io->ask(' Username: ');
  28346. $password = $this->io->askAndHideAnswer(' Password: ');
  28347. $this->io->setAuthentication($origin, $username, $password);
  28348. $storeAuth = $this->config->get('store-auths');
  28349. }
  28350. return array('retry' => true, 'storeAuth' => $storeAuth);
  28351. }
  28352. public function addAuthenticationHeader(array $headers, $origin, $url)
  28353. {
  28354. if ($this->io->hasAuthentication($origin)) {
  28355. $authenticationDisplayMessage = null;
  28356. $auth = $this->io->getAuthentication($origin);
  28357. if ($auth['password'] === 'bearer') {
  28358. $headers[] = 'Authorization: Bearer '.$auth['username'];
  28359. } elseif ('github.com' === $origin && 'x-oauth-basic' === $auth['password']) {
  28360. if (preg_match('{^https?://api\.github\.com/}', $url)) {
  28361. $headers[] = 'Authorization: token '.$auth['username'];
  28362. $authenticationDisplayMessage = 'Using GitHub token authentication';
  28363. }
  28364. } elseif (
  28365. in_array($origin, $this->config->get('gitlab-domains'), true)
  28366. && in_array($auth['password'], array('oauth2', 'private-token', 'gitlab-ci-token'), true)
  28367. ) {
  28368. if ($auth['password'] === 'oauth2') {
  28369. $headers[] = 'Authorization: Bearer '.$auth['username'];
  28370. $authenticationDisplayMessage = 'Using GitLab OAuth token authentication';
  28371. } elseif ($auth['password'] === 'private-token' || $auth['password'] === 'gitlab-ci-token') {
  28372. $headers[] = 'PRIVATE-TOKEN: '.$auth['username'];
  28373. $authenticationDisplayMessage = 'Using GitLab private token authentication';
  28374. }
  28375. } elseif (
  28376. 'bitbucket.org' === $origin
  28377. && $url !== Bitbucket::OAUTH2_ACCESS_TOKEN_URL
  28378. && 'x-token-auth' === $auth['username']
  28379. ) {
  28380. if (!$this->isPublicBitBucketDownload($url)) {
  28381. $headers[] = 'Authorization: Bearer ' . $auth['password'];
  28382. $authenticationDisplayMessage = 'Using Bitbucket OAuth token authentication';
  28383. }
  28384. } else {
  28385. $authStr = base64_encode($auth['username'] . ':' . $auth['password']);
  28386. $headers[] = 'Authorization: Basic '.$authStr;
  28387. $authenticationDisplayMessage = 'Using HTTP basic authentication with username "' . $auth['username'] . '"';
  28388. }
  28389. if ($authenticationDisplayMessage && (!isset($this->displayedOriginAuthentications[$origin]) || $this->displayedOriginAuthentications[$origin] !== $authenticationDisplayMessage)) {
  28390. $this->io->writeError($authenticationDisplayMessage, true, IOInterface::DEBUG);
  28391. $this->displayedOriginAuthentications[$origin] = $authenticationDisplayMessage;
  28392. }
  28393. } elseif (in_array($origin, array('api.bitbucket.org', 'api.github.com'), true)) {
  28394. return $this->addAuthenticationHeader($headers, str_replace('api.', '', $origin), $url);
  28395. }
  28396. return $headers;
  28397. }
  28398. public function isPublicBitBucketDownload($urlToBitBucketFile)
  28399. {
  28400. $domain = parse_url($urlToBitBucketFile, PHP_URL_HOST);
  28401. if (strpos($domain, 'bitbucket.org') === false) {
  28402. return true;
  28403. }
  28404. $path = parse_url($urlToBitBucketFile, PHP_URL_PATH);
  28405. $pathParts = explode('/', $path);
  28406. return count($pathParts) >= 4 && $pathParts[3] == 'downloads';
  28407. }
  28408. }
  28409. <?php
  28410. namespace Composer\Util;
  28411. use Composer\Factory;
  28412. use Composer\IO\IOInterface;
  28413. use Composer\Config;
  28414. use Composer\Downloader\TransportException;
  28415. class Bitbucket
  28416. {
  28417. private $io;
  28418. private $config;
  28419. private $process;
  28420. private $httpDownloader;
  28421. private $token = array();
  28422. private $time;
  28423. const OAUTH2_ACCESS_TOKEN_URL = 'https://bitbucket.org/site/oauth2/access_token';
  28424. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null, $time = null)
  28425. {
  28426. $this->io = $io;
  28427. $this->config = $config;
  28428. $this->process = $process ?: new ProcessExecutor($io);
  28429. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  28430. $this->time = $time;
  28431. }
  28432. public function getToken()
  28433. {
  28434. if (!isset($this->token['access_token'])) {
  28435. return '';
  28436. }
  28437. return $this->token['access_token'];
  28438. }
  28439. public function authorizeOAuth($originUrl)
  28440. {
  28441. if ($originUrl !== 'bitbucket.org') {
  28442. return false;
  28443. }
  28444. if (0 === $this->process->execute('git config bitbucket.accesstoken', $output)) {
  28445. $this->io->setAuthentication($originUrl, 'x-token-auth', trim($output));
  28446. return true;
  28447. }
  28448. return false;
  28449. }
  28450. private function requestAccessToken()
  28451. {
  28452. try {
  28453. $response = $this->httpDownloader->get(self::OAUTH2_ACCESS_TOKEN_URL, array(
  28454. 'retry-auth-failure' => false,
  28455. 'http' => array(
  28456. 'method' => 'POST',
  28457. 'content' => 'grant_type=client_credentials',
  28458. ),
  28459. ));
  28460. $this->token = $response->decodeJson();
  28461. } catch (TransportException $e) {
  28462. if ($e->getCode() === 400) {
  28463. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  28464. $this->io->writeError('This can have two reasons:');
  28465. $this->io->writeError('1. You are authenticating with a bitbucket username/password combination');
  28466. $this->io->writeError('2. You are using an OAuth consumer, but didn\'t configure a (dummy) callback url');
  28467. return false;
  28468. }
  28469. if (in_array($e->getCode(), array(403, 401))) {
  28470. $this->io->writeError('<error>Invalid OAuth consumer provided.</error>');
  28471. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28472. return false;
  28473. }
  28474. throw $e;
  28475. }
  28476. return true;
  28477. }
  28478. public function authorizeOAuthInteractively($originUrl, $message = null)
  28479. {
  28480. if ($message) {
  28481. $this->io->writeError($message);
  28482. }
  28483. $url = 'https://support.atlassian.com/bitbucket-cloud/docs/use-oauth-on-bitbucket-cloud/';
  28484. $this->io->writeError(sprintf('Follow the instructions on %s', $url));
  28485. $this->io->writeError(sprintf('to create a consumer. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  28486. $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)');
  28487. $consumerKey = trim($this->io->askAndHideAnswer('Consumer Key (hidden): '));
  28488. if (!$consumerKey) {
  28489. $this->io->writeError('<warning>No consumer key given, aborting.</warning>');
  28490. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28491. return false;
  28492. }
  28493. $consumerSecret = trim($this->io->askAndHideAnswer('Consumer Secret (hidden): '));
  28494. if (!$consumerSecret) {
  28495. $this->io->writeError('<warning>No consumer secret given, aborting.</warning>');
  28496. $this->io->writeError('You can also add it manually later by using "composer config --global --auth bitbucket-oauth.bitbucket.org <consumer-key> <consumer-secret>"');
  28497. return false;
  28498. }
  28499. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  28500. if (!$this->requestAccessToken()) {
  28501. return false;
  28502. }
  28503. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  28504. $this->config->getAuthConfigSource()->removeConfigSetting('http-basic.' . $originUrl);
  28505. $this->io->writeError('<info>Consumer stored successfully.</info>');
  28506. return true;
  28507. }
  28508. public function requestToken($originUrl, $consumerKey, $consumerSecret)
  28509. {
  28510. if (!empty($this->token) || $this->getTokenFromConfig($originUrl)) {
  28511. return $this->token['access_token'];
  28512. }
  28513. $this->io->setAuthentication($originUrl, $consumerKey, $consumerSecret);
  28514. if (!$this->requestAccessToken()) {
  28515. return '';
  28516. }
  28517. $this->storeInAuthConfig($originUrl, $consumerKey, $consumerSecret);
  28518. return $this->token['access_token'];
  28519. }
  28520. private function storeInAuthConfig($originUrl, $consumerKey, $consumerSecret)
  28521. {
  28522. $this->config->getConfigSource()->removeConfigSetting('bitbucket-oauth.'.$originUrl);
  28523. $time = null === $this->time ? time() : $this->time;
  28524. $consumer = array(
  28525. "consumer-key" => $consumerKey,
  28526. "consumer-secret" => $consumerSecret,
  28527. "access-token" => $this->token['access_token'],
  28528. "access-token-expiration" => $time + $this->token['expires_in'],
  28529. );
  28530. $this->config->getAuthConfigSource()->addConfigSetting('bitbucket-oauth.'.$originUrl, $consumer);
  28531. }
  28532. private function getTokenFromConfig($originUrl)
  28533. {
  28534. $authConfig = $this->config->get('bitbucket-oauth');
  28535. if (
  28536. !isset($authConfig[$originUrl]['access-token'], $authConfig[$originUrl]['access-token-expiration'])
  28537. || time() > $authConfig[$originUrl]['access-token-expiration']
  28538. ) {
  28539. return false;
  28540. }
  28541. $this->token = array(
  28542. 'access_token' => $authConfig[$originUrl]['access-token'],
  28543. );
  28544. return true;
  28545. }
  28546. }
  28547. <?php
  28548. namespace Composer\Util;
  28549. class ComposerMirror
  28550. {
  28551. public static function processUrl($mirrorUrl, $packageName, $version, $reference, $type)
  28552. {
  28553. if ($reference) {
  28554. $reference = preg_match('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference);
  28555. }
  28556. $version = strpos($version, '/') === false ? $version : md5($version);
  28557. return str_replace(
  28558. array('%package%', '%version%', '%reference%', '%type%'),
  28559. array($packageName, $version, $reference, $type),
  28560. $mirrorUrl
  28561. );
  28562. }
  28563. public static function processGitUrl($mirrorUrl, $packageName, $url, $type)
  28564. {
  28565. if (preg_match('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) {
  28566. $url = 'gh-'.$match[1].'/'.$match[2];
  28567. } elseif (preg_match('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) {
  28568. $url = 'bb-'.$match[1].'/'.$match[2];
  28569. } else {
  28570. $url = preg_replace('{[^a-z0-9_.-]}i', '-', trim($url, '/'));
  28571. }
  28572. return str_replace(
  28573. array('%package%', '%normalizedUrl%', '%type%'),
  28574. array($packageName, $url, $type),
  28575. $mirrorUrl
  28576. );
  28577. }
  28578. public static function processHgUrl($mirrorUrl, $packageName, $url, $type)
  28579. {
  28580. return self::processGitUrl($mirrorUrl, $packageName, $url, $type);
  28581. }
  28582. }
  28583. <?php
  28584. namespace Composer\Util;
  28585. use Composer\Package\Loader\ArrayLoader;
  28586. use Composer\Package\Loader\ValidatingArrayLoader;
  28587. use Composer\Package\Loader\InvalidPackageException;
  28588. use Composer\Json\JsonValidationException;
  28589. use Composer\IO\IOInterface;
  28590. use Composer\Json\JsonFile;
  28591. use Composer\Spdx\SpdxLicenses;
  28592. class ConfigValidator
  28593. {
  28594. const CHECK_VERSION = 1;
  28595. private $io;
  28596. public function __construct(IOInterface $io)
  28597. {
  28598. $this->io = $io;
  28599. }
  28600. public function validate($file, $arrayLoaderValidationFlags = ValidatingArrayLoader::CHECK_ALL, $flags = self::CHECK_VERSION)
  28601. {
  28602. $errors = array();
  28603. $publishErrors = array();
  28604. $warnings = array();
  28605. $laxValid = false;
  28606. try {
  28607. $json = new JsonFile($file, null, $this->io);
  28608. $manifest = $json->read();
  28609. $json->validateSchema(JsonFile::LAX_SCHEMA);
  28610. $laxValid = true;
  28611. $json->validateSchema();
  28612. } catch (JsonValidationException $e) {
  28613. foreach ($e->getErrors() as $message) {
  28614. if ($laxValid) {
  28615. $publishErrors[] = $message;
  28616. } else {
  28617. $errors[] = $message;
  28618. }
  28619. }
  28620. } catch (\Exception $e) {
  28621. $errors[] = $e->getMessage();
  28622. return array($errors, $publishErrors, $warnings);
  28623. }
  28624. if (empty($manifest['license'])) {
  28625. $warnings[] = 'No license specified, it is recommended to do so. For closed-source software you may use "proprietary" as license.';
  28626. } else {
  28627. $licenses = (array) $manifest['license'];
  28628. foreach ($licenses as $key => $license) {
  28629. if ('proprietary' === $license) {
  28630. unset($licenses[$key]);
  28631. }
  28632. }
  28633. $licenseValidator = new SpdxLicenses();
  28634. foreach ($licenses as $license) {
  28635. $spdxLicense = $licenseValidator->getLicenseByIdentifier($license);
  28636. if ($spdxLicense && $spdxLicense[3]) {
  28637. if (preg_match('{^[AL]?GPL-[123](\.[01])?\+$}i', $license)) {
  28638. $warnings[] = sprintf(
  28639. 'License "%s" is a deprecated SPDX license identifier, use "'.str_replace('+', '', $license).'-or-later" instead',
  28640. $license
  28641. );
  28642. } elseif (preg_match('{^[AL]?GPL-[123](\.[01])?$}i', $license)) {
  28643. $warnings[] = sprintf(
  28644. 'License "%s" is a deprecated SPDX license identifier, use "'.$license.'-only" or "'.$license.'-or-later" instead',
  28645. $license
  28646. );
  28647. } else {
  28648. $warnings[] = sprintf(
  28649. 'License "%s" is a deprecated SPDX license identifier, see https://spdx.org/licenses/',
  28650. $license
  28651. );
  28652. }
  28653. }
  28654. }
  28655. }
  28656. if (($flags & self::CHECK_VERSION) && isset($manifest['version'])) {
  28657. $warnings[] = 'The version field is present, it is recommended to leave it out if the package is published on Packagist.';
  28658. }
  28659. if (!empty($manifest['name']) && preg_match('{[A-Z]}', $manifest['name'])) {
  28660. $suggestName = preg_replace('{(?:([a-z])([A-Z])|([A-Z])([A-Z][a-z]))}', '\\1\\3-\\2\\4', $manifest['name']);
  28661. $suggestName = strtolower($suggestName);
  28662. $publishErrors[] = sprintf(
  28663. '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.',
  28664. $manifest['name'],
  28665. $suggestName
  28666. );
  28667. }
  28668. if (!empty($manifest['type']) && $manifest['type'] == 'composer-installer') {
  28669. $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.";
  28670. }
  28671. if (isset($manifest['require'], $manifest['require-dev'])) {
  28672. $requireOverrides = array_intersect_key($manifest['require'], $manifest['require-dev']);
  28673. if (!empty($requireOverrides)) {
  28674. $plural = (count($requireOverrides) > 1) ? 'are' : 'is';
  28675. $warnings[] = implode(', ', array_keys($requireOverrides)). " {$plural} required both in require and require-dev, this can lead to unexpected behavior";
  28676. }
  28677. }
  28678. foreach (array('provide', 'replace') as $linkType) {
  28679. if (isset($manifest[$linkType])) {
  28680. foreach (array('require', 'require-dev') as $requireType) {
  28681. if (isset($manifest[$requireType])) {
  28682. foreach ($manifest[$linkType] as $provide => $constraint) {
  28683. if (isset($manifest[$requireType][$provide])) {
  28684. $warnings[] = 'The package ' . $provide . ' in '.$requireType.' is also listed in '.$linkType.' which satisfies the requirement. Remove it from '.$linkType.' if you wish to install it.';
  28685. }
  28686. }
  28687. }
  28688. }
  28689. }
  28690. }
  28691. $require = isset($manifest['require']) ? $manifest['require'] : array();
  28692. $requireDev = isset($manifest['require-dev']) ? $manifest['require-dev'] : array();
  28693. $packages = array_merge($require, $requireDev);
  28694. foreach ($packages as $package => $version) {
  28695. if (preg_match('/#/', $version) === 1) {
  28696. $warnings[] = sprintf(
  28697. 'The package "%s" is pointing to a commit-ref, this is bad practice and can cause unforeseen issues.',
  28698. $package
  28699. );
  28700. }
  28701. }
  28702. $scriptsDescriptions = isset($manifest['scripts-descriptions']) ? $manifest['scripts-descriptions'] : array();
  28703. $scripts = isset($manifest['scripts']) ? $manifest['scripts'] : array();
  28704. foreach ($scriptsDescriptions as $scriptName => $scriptDescription) {
  28705. if (!array_key_exists($scriptName, $scripts)) {
  28706. $warnings[] = sprintf(
  28707. 'Description for non-existent script "%s" found in "scripts-descriptions"',
  28708. $scriptName
  28709. );
  28710. }
  28711. }
  28712. if (isset($manifest['autoload']['psr-0'][''])) {
  28713. $warnings[] = "Defining autoload.psr-0 with an empty namespace prefix is a bad idea for performance";
  28714. }
  28715. if (isset($manifest['autoload']['psr-4'][''])) {
  28716. $warnings[] = "Defining autoload.psr-4 with an empty namespace prefix is a bad idea for performance";
  28717. }
  28718. $loader = new ValidatingArrayLoader(new ArrayLoader(), true, null, $arrayLoaderValidationFlags);
  28719. try {
  28720. if (!isset($manifest['version'])) {
  28721. $manifest['version'] = '1.0.0';
  28722. }
  28723. if (!isset($manifest['name'])) {
  28724. $manifest['name'] = 'dummy/dummy';
  28725. }
  28726. $loader->load($manifest);
  28727. } catch (InvalidPackageException $e) {
  28728. $errors = array_merge($errors, $e->getErrors());
  28729. }
  28730. $warnings = array_merge($warnings, $loader->getWarnings());
  28731. return array($errors, $publishErrors, $warnings);
  28732. }
  28733. }
  28734. <?php
  28735. namespace Composer\Util;
  28736. use Composer\IO\IOInterface;
  28737. class ErrorHandler
  28738. {
  28739. private static $io;
  28740. public static function handle($level, $message, $file, $line)
  28741. {
  28742. if (!(error_reporting() & $level)) {
  28743. return;
  28744. }
  28745. if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
  28746. $message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be".
  28747. "\na legitimately suppressed error that you were not supposed to see.";
  28748. }
  28749. if ($level !== E_DEPRECATED && $level !== E_USER_DEPRECATED) {
  28750. throw new \ErrorException($message, 0, $level, $file, $line);
  28751. }
  28752. if (self::$io) {
  28753. self::$io->writeError('<warning>Deprecation Notice: '.$message.' in '.$file.':'.$line.'</warning>');
  28754. if (self::$io->isVerbose()) {
  28755. self::$io->writeError('<warning>Stack trace:</warning>');
  28756. self::$io->writeError(array_filter(array_map(function ($a) {
  28757. if (isset($a['line'], $a['file'])) {
  28758. return '<warning> '.$a['file'].':'.$a['line'].'</warning>';
  28759. }
  28760. return null;
  28761. }, array_slice(debug_backtrace(), 2))));
  28762. }
  28763. }
  28764. return true;
  28765. }
  28766. public static function register(IOInterface $io = null)
  28767. {
  28768. set_error_handler(array(__CLASS__, 'handle'));
  28769. error_reporting(E_ALL | E_STRICT);
  28770. self::$io = $io;
  28771. }
  28772. }
  28773. <?php
  28774. namespace Composer\Util;
  28775. use RecursiveDirectoryIterator;
  28776. use RecursiveIteratorIterator;
  28777. use Symfony\Component\Filesystem\Exception\IOException;
  28778. use Symfony\Component\Finder\Finder;
  28779. class Filesystem
  28780. {
  28781. private $processExecutor;
  28782. public function __construct(ProcessExecutor $executor = null)
  28783. {
  28784. $this->processExecutor = $executor;
  28785. }
  28786. public function remove($file)
  28787. {
  28788. if (is_dir($file)) {
  28789. return $this->removeDirectory($file);
  28790. }
  28791. if (file_exists($file)) {
  28792. return $this->unlink($file);
  28793. }
  28794. return false;
  28795. }
  28796. public function isDirEmpty($dir)
  28797. {
  28798. $finder = Finder::create()
  28799. ->ignoreVCS(false)
  28800. ->ignoreDotFiles(false)
  28801. ->depth(0)
  28802. ->in($dir);
  28803. return \count($finder) === 0;
  28804. }
  28805. public function emptyDirectory($dir, $ensureDirectoryExists = true)
  28806. {
  28807. if (is_link($dir) && file_exists($dir)) {
  28808. $this->unlink($dir);
  28809. }
  28810. if ($ensureDirectoryExists) {
  28811. $this->ensureDirectoryExists($dir);
  28812. }
  28813. if (is_dir($dir)) {
  28814. $finder = Finder::create()
  28815. ->ignoreVCS(false)
  28816. ->ignoreDotFiles(false)
  28817. ->depth(0)
  28818. ->in($dir);
  28819. foreach ($finder as $path) {
  28820. $this->remove((string) $path);
  28821. }
  28822. }
  28823. }
  28824. public function removeDirectory($directory)
  28825. {
  28826. if ($this->isSymlinkedDirectory($directory)) {
  28827. return $this->unlinkSymlinkedDirectory($directory);
  28828. }
  28829. if ($this->isJunction($directory)) {
  28830. return $this->removeJunction($directory);
  28831. }
  28832. if (is_link($directory)) {
  28833. return unlink($directory);
  28834. }
  28835. if (!is_dir($directory) || !file_exists($directory)) {
  28836. return true;
  28837. }
  28838. if (preg_match('{^(?:[a-z]:)?[/\\\\]+$}i', $directory)) {
  28839. throw new \RuntimeException('Aborting an attempted deletion of '.$directory.', this was probably not intended, if it is a real use case please report it.');
  28840. }
  28841. if (!\function_exists('proc_open')) {
  28842. return $this->removeDirectoryPhp($directory);
  28843. }
  28844. if (Platform::isWindows()) {
  28845. $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape(realpath($directory)));
  28846. } else {
  28847. $cmd = sprintf('rm -rf %s', ProcessExecutor::escape($directory));
  28848. }
  28849. $result = $this->getProcess()->execute($cmd, $output) === 0;
  28850. clearstatcache();
  28851. if ($result && !is_dir($directory)) {
  28852. return true;
  28853. }
  28854. return $this->removeDirectoryPhp($directory);
  28855. }
  28856. public function removeDirectoryPhp($directory)
  28857. {
  28858. try {
  28859. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  28860. } catch (\UnexpectedValueException $e) {
  28861. clearstatcache();
  28862. usleep(100000);
  28863. if (!is_dir($directory)) {
  28864. return true;
  28865. }
  28866. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  28867. }
  28868. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  28869. foreach ($ri as $file) {
  28870. if ($file->isDir()) {
  28871. $this->rmdir($file->getPathname());
  28872. } else {
  28873. $this->unlink($file->getPathname());
  28874. }
  28875. }
  28876. return $this->rmdir($directory);
  28877. }
  28878. public function ensureDirectoryExists($directory)
  28879. {
  28880. if (!is_dir($directory)) {
  28881. if (file_exists($directory)) {
  28882. throw new \RuntimeException(
  28883. $directory.' exists and is not a directory.'
  28884. );
  28885. }
  28886. if (!@mkdir($directory, 0777, true)) {
  28887. throw new \RuntimeException(
  28888. $directory.' does not exist and could not be created.'
  28889. );
  28890. }
  28891. }
  28892. }
  28893. public function unlink($path)
  28894. {
  28895. $unlinked = @$this->unlinkImplementation($path);
  28896. if (!$unlinked) {
  28897. if (Platform::isWindows()) {
  28898. usleep(350000);
  28899. $unlinked = @$this->unlinkImplementation($path);
  28900. }
  28901. if (!$unlinked) {
  28902. $error = error_get_last();
  28903. $message = 'Could not delete '.$path.': ' . @$error['message'];
  28904. if (Platform::isWindows()) {
  28905. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  28906. }
  28907. throw new \RuntimeException($message);
  28908. }
  28909. }
  28910. return true;
  28911. }
  28912. public function rmdir($path)
  28913. {
  28914. $deleted = @rmdir($path);
  28915. if (!$deleted) {
  28916. if (Platform::isWindows()) {
  28917. usleep(350000);
  28918. $deleted = @rmdir($path);
  28919. }
  28920. if (!$deleted) {
  28921. $error = error_get_last();
  28922. $message = 'Could not delete '.$path.': ' . @$error['message'];
  28923. if (Platform::isWindows()) {
  28924. $message .= "\nThis can be due to an antivirus or the Windows Search Indexer locking the file while they are analyzed";
  28925. }
  28926. throw new \RuntimeException($message);
  28927. }
  28928. }
  28929. return true;
  28930. }
  28931. public function copyThenRemove($source, $target)
  28932. {
  28933. $this->copy($source, $target);
  28934. if (!is_dir($source)) {
  28935. $this->unlink($source);
  28936. return;
  28937. }
  28938. $this->removeDirectoryPhp($source);
  28939. }
  28940. public function copy($source, $target)
  28941. {
  28942. if (!is_dir($source)) {
  28943. return copy($source, $target);
  28944. }
  28945. $it = new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS);
  28946. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::SELF_FIRST);
  28947. $this->ensureDirectoryExists($target);
  28948. $result = true;
  28949. foreach ($ri as $file) {
  28950. $targetPath = $target . DIRECTORY_SEPARATOR . $ri->getSubPathname();
  28951. if ($file->isDir()) {
  28952. $this->ensureDirectoryExists($targetPath);
  28953. } else {
  28954. $result = $result && copy($file->getPathname(), $targetPath);
  28955. }
  28956. }
  28957. return $result;
  28958. }
  28959. public function rename($source, $target)
  28960. {
  28961. if (true === @rename($source, $target)) {
  28962. return;
  28963. }
  28964. if (!\function_exists('proc_open')) {
  28965. $this->copyThenRemove($source, $target);
  28966. return;
  28967. }
  28968. if (Platform::isWindows()) {
  28969. $command = sprintf('xcopy %s %s /E /I /Q /Y', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  28970. $result = $this->getProcess()->execute($command, $output);
  28971. clearstatcache();
  28972. if (0 === $result) {
  28973. $this->remove($source);
  28974. return;
  28975. }
  28976. } else {
  28977. $command = sprintf('mv %s %s', ProcessExecutor::escape($source), ProcessExecutor::escape($target));
  28978. $result = $this->getProcess()->execute($command, $output);
  28979. clearstatcache();
  28980. if (0 === $result) {
  28981. return;
  28982. }
  28983. }
  28984. $this->copyThenRemove($source, $target);
  28985. }
  28986. public function findShortestPath($from, $to, $directories = false)
  28987. {
  28988. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  28989. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  28990. }
  28991. $from = lcfirst($this->normalizePath($from));
  28992. $to = lcfirst($this->normalizePath($to));
  28993. if ($directories) {
  28994. $from = rtrim($from, '/') . '/dummy_file';
  28995. }
  28996. if (\dirname($from) === \dirname($to)) {
  28997. return './'.basename($to);
  28998. }
  28999. $commonPath = $to;
  29000. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath)) {
  29001. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  29002. }
  29003. if (0 !== strpos($from, $commonPath) || '/' === $commonPath) {
  29004. return $to;
  29005. }
  29006. $commonPath = rtrim($commonPath, '/') . '/';
  29007. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/');
  29008. $commonPathCode = str_repeat('../', $sourcePathDepth);
  29009. return ($commonPathCode . substr($to, \strlen($commonPath))) ?: './';
  29010. }
  29011. public function findShortestPathCode($from, $to, $directories = false, $staticCode = false)
  29012. {
  29013. if (!$this->isAbsolutePath($from) || !$this->isAbsolutePath($to)) {
  29014. throw new \InvalidArgumentException(sprintf('$from (%s) and $to (%s) must be absolute paths.', $from, $to));
  29015. }
  29016. $from = lcfirst($this->normalizePath($from));
  29017. $to = lcfirst($this->normalizePath($to));
  29018. if ($from === $to) {
  29019. return $directories ? '__DIR__' : '__FILE__';
  29020. }
  29021. $commonPath = $to;
  29022. while (strpos($from.'/', $commonPath.'/') !== 0 && '/' !== $commonPath && !preg_match('{^[a-z]:/?$}i', $commonPath) && '.' !== $commonPath) {
  29023. $commonPath = strtr(\dirname($commonPath), '\\', '/');
  29024. }
  29025. if (0 !== strpos($from, $commonPath) || '/' === $commonPath || '.' === $commonPath) {
  29026. return var_export($to, true);
  29027. }
  29028. $commonPath = rtrim($commonPath, '/') . '/';
  29029. if (strpos($to, $from.'/') === 0) {
  29030. return '__DIR__ . '.var_export(substr($to, \strlen($from)), true);
  29031. }
  29032. $sourcePathDepth = substr_count(substr($from, \strlen($commonPath)), '/') + $directories;
  29033. if ($staticCode) {
  29034. $commonPathCode = "__DIR__ . '".str_repeat('/..', $sourcePathDepth)."'";
  29035. } else {
  29036. $commonPathCode = str_repeat('dirname(', $sourcePathDepth).'__DIR__'.str_repeat(')', $sourcePathDepth);
  29037. }
  29038. $relTarget = substr($to, \strlen($commonPath));
  29039. return $commonPathCode . (\strlen($relTarget) ? '.' . var_export('/' . $relTarget, true) : '');
  29040. }
  29041. public function isAbsolutePath($path)
  29042. {
  29043. return strpos($path, '/') === 0 || substr($path, 1, 1) === ':' || strpos($path, '\\\\') === 0;
  29044. }
  29045. public function size($path)
  29046. {
  29047. if (!file_exists($path)) {
  29048. throw new \RuntimeException("$path does not exist.");
  29049. }
  29050. if (is_dir($path)) {
  29051. return $this->directorySize($path);
  29052. }
  29053. return filesize($path);
  29054. }
  29055. public function normalizePath($path)
  29056. {
  29057. $parts = array();
  29058. $path = strtr($path, '\\', '/');
  29059. $prefix = '';
  29060. $absolute = false;
  29061. if (preg_match('{^( [0-9a-z]{2,}+: (?: // (?: [a-z]: )? )? | [a-z]: )}ix', $path, $match)) {
  29062. $prefix = $match[1];
  29063. $path = substr($path, \strlen($prefix));
  29064. }
  29065. if (strpos($path, '/') === 0) {
  29066. $absolute = true;
  29067. $path = substr($path, 1);
  29068. }
  29069. $up = false;
  29070. foreach (explode('/', $path) as $chunk) {
  29071. if ('..' === $chunk && ($absolute || $up)) {
  29072. array_pop($parts);
  29073. $up = !(empty($parts) || '..' === end($parts));
  29074. } elseif ('.' !== $chunk && '' !== $chunk) {
  29075. $parts[] = $chunk;
  29076. $up = '..' !== $chunk;
  29077. }
  29078. }
  29079. return $prefix.($absolute ? '/' : '').implode('/', $parts);
  29080. }
  29081. public static function trimTrailingSlash($path)
  29082. {
  29083. if (!preg_match('{^[/\\\\]+$}', $path)) {
  29084. $path = rtrim($path, '/\\');
  29085. }
  29086. return $path;
  29087. }
  29088. public static function isLocalPath($path)
  29089. {
  29090. return (bool) preg_match('{^(file://(?!//)|/(?!/)|/?[a-z]:[\\\\/]|\.\.[\\\\/]|[a-z0-9_.-]+[\\\\/])}i', $path);
  29091. }
  29092. public static function getPlatformPath($path)
  29093. {
  29094. if (Platform::isWindows()) {
  29095. $path = preg_replace('{^(?:file:///([a-z]):?/)}i', 'file://$1:/', $path);
  29096. }
  29097. return preg_replace('{^file://}i', '', $path);
  29098. }
  29099. protected function directorySize($directory)
  29100. {
  29101. $it = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS);
  29102. $ri = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
  29103. $size = 0;
  29104. foreach ($ri as $file) {
  29105. if ($file->isFile()) {
  29106. $size += $file->getSize();
  29107. }
  29108. }
  29109. return $size;
  29110. }
  29111. protected function getProcess()
  29112. {
  29113. if (!$this->processExecutor) {
  29114. $this->processExecutor = new ProcessExecutor();
  29115. }
  29116. return $this->processExecutor;
  29117. }
  29118. private function unlinkImplementation($path)
  29119. {
  29120. if (Platform::isWindows() && is_dir($path) && is_link($path)) {
  29121. return rmdir($path);
  29122. }
  29123. return unlink($path);
  29124. }
  29125. public function relativeSymlink($target, $link)
  29126. {
  29127. if (!function_exists('symlink')) {
  29128. return false;
  29129. }
  29130. $cwd = getcwd();
  29131. $relativePath = $this->findShortestPath($link, $target);
  29132. chdir(\dirname($link));
  29133. $result = @symlink($relativePath, $link);
  29134. chdir($cwd);
  29135. return $result;
  29136. }
  29137. public function isSymlinkedDirectory($directory)
  29138. {
  29139. if (!is_dir($directory)) {
  29140. return false;
  29141. }
  29142. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  29143. return is_link($resolved);
  29144. }
  29145. private function unlinkSymlinkedDirectory($directory)
  29146. {
  29147. $resolved = $this->resolveSymlinkedDirectorySymlink($directory);
  29148. return $this->unlink($resolved);
  29149. }
  29150. private function resolveSymlinkedDirectorySymlink($pathname)
  29151. {
  29152. if (!is_dir($pathname)) {
  29153. return $pathname;
  29154. }
  29155. $resolved = rtrim($pathname, '/');
  29156. if (!\strlen($resolved)) {
  29157. return $pathname;
  29158. }
  29159. return $resolved;
  29160. }
  29161. public function junction($target, $junction)
  29162. {
  29163. if (!Platform::isWindows()) {
  29164. throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
  29165. }
  29166. if (!is_dir($target)) {
  29167. throw new IOException(sprintf('Cannot junction to "%s" as it is not a directory.', $target), 0, null, $target);
  29168. }
  29169. $cmd = sprintf(
  29170. 'mklink /J %s %s',
  29171. ProcessExecutor::escape(str_replace('/', DIRECTORY_SEPARATOR, $junction)),
  29172. ProcessExecutor::escape(realpath($target))
  29173. );
  29174. if ($this->getProcess()->execute($cmd, $output) !== 0) {
  29175. throw new IOException(sprintf('Failed to create junction to "%s" at "%s".', $target, $junction), 0, null, $target);
  29176. }
  29177. clearstatcache(true, $junction);
  29178. }
  29179. public function isJunction($junction)
  29180. {
  29181. if (!Platform::isWindows()) {
  29182. return false;
  29183. }
  29184. clearstatcache(true, $junction);
  29185. if (!is_dir($junction) || is_link($junction)) {
  29186. return false;
  29187. }
  29188. $stat = lstat($junction);
  29189. return $stat ? 0x4000 !== ($stat['mode'] & 0xF000) : false;
  29190. }
  29191. public function removeJunction($junction)
  29192. {
  29193. if (!Platform::isWindows()) {
  29194. return false;
  29195. }
  29196. $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
  29197. if (!$this->isJunction($junction)) {
  29198. throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
  29199. }
  29200. return $this->rmdir($junction);
  29201. }
  29202. public function filePutContentsIfModified($path, $content)
  29203. {
  29204. $currentContent = @file_get_contents($path);
  29205. if (!$currentContent || ($currentContent != $content)) {
  29206. return file_put_contents($path, $content);
  29207. }
  29208. return 0;
  29209. }
  29210. public function safeCopy($source, $target)
  29211. {
  29212. if (!file_exists($target) || !file_exists($source) || !$this->filesAreEqual($source, $target)) {
  29213. $source = fopen($source, 'r');
  29214. $target = fopen($target, 'w+');
  29215. stream_copy_to_stream($source, $target);
  29216. fclose($source);
  29217. fclose($target);
  29218. }
  29219. }
  29220. private function filesAreEqual($a, $b)
  29221. {
  29222. if (filesize($a) !== filesize($b)) {
  29223. return false;
  29224. }
  29225. $ah = fopen($a, 'rb');
  29226. $bh = fopen($b, 'rb');
  29227. $result = true;
  29228. while (!feof($ah)) {
  29229. if (fread($ah, 8192) != fread($bh, 8192)) {
  29230. $result = false;
  29231. break;
  29232. }
  29233. }
  29234. fclose($ah);
  29235. fclose($bh);
  29236. return $result;
  29237. }
  29238. }
  29239. <?php
  29240. namespace Composer\Util;
  29241. use Composer\Config;
  29242. use Composer\IO\IOInterface;
  29243. class Git
  29244. {
  29245. private static $version = false;
  29246. protected $io;
  29247. protected $config;
  29248. protected $process;
  29249. protected $filesystem;
  29250. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process, Filesystem $fs)
  29251. {
  29252. $this->io = $io;
  29253. $this->config = $config;
  29254. $this->process = $process;
  29255. $this->filesystem = $fs;
  29256. }
  29257. public function runCommand($commandCallable, $url, $cwd, $initialClone = false)
  29258. {
  29259. $this->config->prohibitUrlByConfig($url, $this->io);
  29260. if ($initialClone) {
  29261. $origCwd = $cwd;
  29262. $cwd = null;
  29263. }
  29264. if (preg_match('{^ssh://[^@]+@[^:]+:[^0-9]+}', $url)) {
  29265. 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.');
  29266. }
  29267. if (!$initialClone) {
  29268. $this->process->execute('git remote -v', $output, $cwd);
  29269. if (preg_match('{^(?:composer|origin)\s+https?://(.+):(.+)@([^/]+)}im', $output, $match) && !$this->io->hasAuthentication($match[3])) {
  29270. $this->io->setAuthentication($match[3], rawurldecode($match[1]), rawurldecode($match[2]));
  29271. }
  29272. }
  29273. $protocols = $this->config->get('github-protocols');
  29274. if (!is_array($protocols)) {
  29275. throw new \RuntimeException('Config value "github-protocols" must be an array, got ' . gettype($protocols));
  29276. }
  29277. if (preg_match('{^(?:https?|git)://' . self::getGitHubDomainsRegex($this->config) . '/(.*)}', $url, $match)) {
  29278. $messages = array();
  29279. foreach ($protocols as $protocol) {
  29280. if ('ssh' === $protocol) {
  29281. $protoUrl = "git@" . $match[1] . ":" . $match[2];
  29282. } else {
  29283. $protoUrl = $protocol . "://" . $match[1] . "/" . $match[2];
  29284. }
  29285. if (0 === $this->process->execute(call_user_func($commandCallable, $protoUrl), $ignoredOutput, $cwd)) {
  29286. return;
  29287. }
  29288. $messages[] = '- ' . $protoUrl . "\n" . preg_replace('#^#m', ' ', $this->process->getErrorOutput());
  29289. if ($initialClone && isset($origCwd)) {
  29290. $this->filesystem->removeDirectory($origCwd);
  29291. }
  29292. }
  29293. if (!$this->io->hasAuthentication($match[1]) && !$this->io->isInteractive()) {
  29294. $this->throwException('Failed to clone ' . $url . ' via ' . implode(', ', $protocols) . ' protocols, aborting.' . "\n\n" . implode("\n", $messages), $url);
  29295. }
  29296. }
  29297. $bypassSshForGitHub = preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url) && !in_array('ssh', $protocols, true);
  29298. $command = call_user_func($commandCallable, $url);
  29299. $auth = null;
  29300. if ($bypassSshForGitHub || 0 !== $this->process->execute($command, $ignoredOutput, $cwd)) {
  29301. $errorMsg = $this->process->getErrorOutput();
  29302. if (preg_match('{^git@' . self::getGitHubDomainsRegex($this->config) . ':(.+?)\.git$}i', $url, $match)
  29303. || preg_match('{^https?://' . self::getGitHubDomainsRegex($this->config) . '/(.*?)(?:\.git)?$}', $url, $match)
  29304. ) {
  29305. if (!$this->io->hasAuthentication($match[1])) {
  29306. $gitHubUtil = new GitHub($this->io, $this->config, $this->process);
  29307. $message = 'Cloning failed using an ssh key for authentication, enter your GitHub credentials to access private repos';
  29308. if (!$gitHubUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  29309. $gitHubUtil->authorizeOAuthInteractively($match[1], $message);
  29310. }
  29311. }
  29312. if ($this->io->hasAuthentication($match[1])) {
  29313. $auth = $this->io->getAuthentication($match[1]);
  29314. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  29315. $command = call_user_func($commandCallable, $authUrl);
  29316. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29317. return;
  29318. }
  29319. $errorMsg = $this->process->getErrorOutput();
  29320. }
  29321. } elseif (preg_match('{^https://(bitbucket\.org)/(.*?)(?:\.git)?$}U', $url, $match)) {
  29322. $bitbucketUtil = new Bitbucket($this->io, $this->config, $this->process);
  29323. if (!$this->io->hasAuthentication($match[1])) {
  29324. $message = 'Enter your Bitbucket credentials to access private repos';
  29325. if (!$bitbucketUtil->authorizeOAuth($match[1]) && $this->io->isInteractive()) {
  29326. $bitbucketUtil->authorizeOAuthInteractively($match[1], $message);
  29327. $accessToken = $bitbucketUtil->getToken();
  29328. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  29329. }
  29330. } else {
  29331. $auth = $this->io->getAuthentication($match[1]);
  29332. if ($auth['username'] !== 'x-token-auth') {
  29333. $accessToken = $bitbucketUtil->requestToken($match[1], $auth['username'], $auth['password']);
  29334. if (!empty($accessToken)) {
  29335. $this->io->setAuthentication($match[1], 'x-token-auth', $accessToken);
  29336. }
  29337. }
  29338. }
  29339. if ($this->io->hasAuthentication($match[1])) {
  29340. $auth = $this->io->getAuthentication($match[1]);
  29341. $authUrl = 'https://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[1] . '/' . $match[2] . '.git';
  29342. $command = call_user_func($commandCallable, $authUrl);
  29343. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29344. return;
  29345. }
  29346. $errorMsg = $this->process->getErrorOutput();
  29347. } else {
  29348. $sshUrl = 'git@bitbucket.org:' . $match[2] . '.git';
  29349. $this->io->writeError(' No bitbucket authentication configured. Falling back to ssh.');
  29350. $command = call_user_func($commandCallable, $sshUrl);
  29351. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29352. return;
  29353. }
  29354. $errorMsg = $this->process->getErrorOutput();
  29355. }
  29356. } elseif (
  29357. preg_match('{^(git)@' . self::getGitLabDomainsRegex($this->config) . ':(.+?\.git)$}i', $url, $match)
  29358. || preg_match('{^(https?)://' . self::getGitLabDomainsRegex($this->config) . '/(.*)}', $url, $match)
  29359. ) {
  29360. if ($match[1] === 'git') {
  29361. $match[1] = 'https';
  29362. }
  29363. if (!$this->io->hasAuthentication($match[2])) {
  29364. $gitLabUtil = new GitLab($this->io, $this->config, $this->process);
  29365. $message = 'Cloning failed, enter your GitLab credentials to access private repos';
  29366. if (!$gitLabUtil->authorizeOAuth($match[2]) && $this->io->isInteractive()) {
  29367. $gitLabUtil->authorizeOAuthInteractively($match[1], $match[2], $message);
  29368. }
  29369. }
  29370. if ($this->io->hasAuthentication($match[2])) {
  29371. $auth = $this->io->getAuthentication($match[2]);
  29372. if ($auth['password'] === 'private-token' || $auth['password'] === 'oauth2' || $auth['password'] === 'gitlab-ci-token') {
  29373. $authUrl = $match[1] . '://' . rawurlencode($auth['password']) . ':' . rawurlencode($auth['username']) . '@' . $match[2] . '/' . $match[3];
  29374. } else {
  29375. $authUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . '/' . $match[3];
  29376. }
  29377. $command = call_user_func($commandCallable, $authUrl);
  29378. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29379. return;
  29380. }
  29381. $errorMsg = $this->process->getErrorOutput();
  29382. }
  29383. } elseif ($this->isAuthenticationFailure($url, $match)) {
  29384. if (strpos($match[2], '@')) {
  29385. list($authParts, $match[2]) = explode('@', $match[2], 2);
  29386. }
  29387. $storeAuth = false;
  29388. if ($this->io->hasAuthentication($match[2])) {
  29389. $auth = $this->io->getAuthentication($match[2]);
  29390. } elseif ($this->io->isInteractive()) {
  29391. $defaultUsername = null;
  29392. if (isset($authParts) && $authParts) {
  29393. if (false !== strpos($authParts, ':')) {
  29394. list($defaultUsername, ) = explode(':', $authParts, 2);
  29395. } else {
  29396. $defaultUsername = $authParts;
  29397. }
  29398. }
  29399. $this->io->writeError(' Authentication required (<info>' . $match[2] . '</info>):');
  29400. $auth = array(
  29401. 'username' => $this->io->ask(' Username: ', $defaultUsername),
  29402. 'password' => $this->io->askAndHideAnswer(' Password: '),
  29403. );
  29404. $storeAuth = $this->config->get('store-auths');
  29405. }
  29406. if ($auth) {
  29407. $authUrl = $match[1] . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[2] . $match[3];
  29408. $command = call_user_func($commandCallable, $authUrl);
  29409. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29410. $this->io->setAuthentication($match[2], $auth['username'], $auth['password']);
  29411. $authHelper = new AuthHelper($this->io, $this->config);
  29412. $authHelper->storeAuth($match[2], $storeAuth);
  29413. return;
  29414. }
  29415. $errorMsg = $this->process->getErrorOutput();
  29416. }
  29417. }
  29418. if ($initialClone && isset($origCwd)) {
  29419. $this->filesystem->removeDirectory($origCwd);
  29420. }
  29421. $this->throwException('Failed to execute ' . $command . "\n\n" . $errorMsg, $url);
  29422. }
  29423. }
  29424. public function syncMirror($url, $dir)
  29425. {
  29426. if (getenv('COMPOSER_DISABLE_NETWORK') && getenv('COMPOSER_DISABLE_NETWORK') !== 'prime') {
  29427. $this->io->writeError('<warning>Aborting git mirror sync of '.$url.' as network is disabled</warning>');
  29428. return false;
  29429. }
  29430. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  29431. try {
  29432. $commandCallable = function ($url) {
  29433. $sanitizedUrl = preg_replace('{://([^@]+?):(.+?)@}', '://', $url);
  29434. return sprintf('git remote set-url origin %s && git remote update --prune origin && git remote set-url origin %s && git gc --auto', ProcessExecutor::escape($url), ProcessExecutor::escape($sanitizedUrl));
  29435. };
  29436. $this->runCommand($commandCallable, $url, $dir);
  29437. } catch (\Exception $e) {
  29438. $this->io->writeError('<error>Sync mirror failed: ' . $e->getMessage() . '</error>', true, IOInterface::DEBUG);
  29439. return false;
  29440. }
  29441. return true;
  29442. }
  29443. $this->filesystem->removeDirectory($dir);
  29444. $commandCallable = function ($url) use ($dir) {
  29445. return sprintf('git clone --mirror %s %s', ProcessExecutor::escape($url), ProcessExecutor::escape($dir));
  29446. };
  29447. $this->runCommand($commandCallable, $url, $dir, true);
  29448. return true;
  29449. }
  29450. public function fetchRefOrSyncMirror($url, $dir, $ref)
  29451. {
  29452. if ($this->checkRefIsInMirror($dir, $ref)) {
  29453. return true;
  29454. }
  29455. if ($this->syncMirror($url, $dir)) {
  29456. return $this->checkRefIsInMirror($dir, $ref);
  29457. }
  29458. return false;
  29459. }
  29460. public static function getNoShowSignatureFlag(ProcessExecutor $process)
  29461. {
  29462. $gitVersion = self::getVersion($process);
  29463. if ($gitVersion && version_compare($gitVersion, '2.10.0-rc0', '>=')) {
  29464. return ' --no-show-signature';
  29465. }
  29466. return '';
  29467. }
  29468. private function checkRefIsInMirror($dir, $ref)
  29469. {
  29470. if (is_dir($dir) && 0 === $this->process->execute('git rev-parse --git-dir', $output, $dir) && trim($output) === '.') {
  29471. $escapedRef = ProcessExecutor::escape($ref.'^{commit}');
  29472. $exitCode = $this->process->execute(sprintf('git rev-parse --quiet --verify %s', $escapedRef), $ignoredOutput, $dir);
  29473. if ($exitCode === 0) {
  29474. return true;
  29475. }
  29476. }
  29477. return false;
  29478. }
  29479. private function isAuthenticationFailure($url, &$match)
  29480. {
  29481. if (!preg_match('{^(https?://)([^/]+)(.*)$}i', $url, $match)) {
  29482. return false;
  29483. }
  29484. $authFailures = array(
  29485. 'fatal: Authentication failed',
  29486. 'remote error: Invalid username or password.',
  29487. 'error: 401 Unauthorized',
  29488. 'fatal: unable to access',
  29489. 'fatal: could not read Username',
  29490. );
  29491. $errorOutput = $this->process->getErrorOutput();
  29492. foreach ($authFailures as $authFailure) {
  29493. if (strpos($errorOutput, $authFailure) !== false) {
  29494. return true;
  29495. }
  29496. }
  29497. return false;
  29498. }
  29499. public static function cleanEnv()
  29500. {
  29501. if (PHP_VERSION_ID < 50400 && ini_get('safe_mode') && false === strpos(ini_get('safe_mode_allowed_env_vars'), 'GIT_ASKPASS')) {
  29502. 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');
  29503. }
  29504. if (getenv('GIT_ASKPASS') !== 'echo') {
  29505. putenv('GIT_ASKPASS=echo');
  29506. $_SERVER['GIT_ASKPASS'] = 'echo';
  29507. }
  29508. if (getenv('GIT_DIR')) {
  29509. putenv('GIT_DIR');
  29510. unset($_SERVER['GIT_DIR']);
  29511. }
  29512. if (getenv('GIT_WORK_TREE')) {
  29513. putenv('GIT_WORK_TREE');
  29514. unset($_SERVER['GIT_WORK_TREE']);
  29515. }
  29516. if (getenv('LANGUAGE') !== 'C') {
  29517. putenv('LANGUAGE=C');
  29518. $_SERVER['LANGUAGE'] = 'C';
  29519. }
  29520. putenv("DYLD_LIBRARY_PATH");
  29521. unset($_SERVER['DYLD_LIBRARY_PATH']);
  29522. }
  29523. public static function getGitHubDomainsRegex(Config $config)
  29524. {
  29525. return '(' . implode('|', array_map('preg_quote', $config->get('github-domains'))) . ')';
  29526. }
  29527. public static function getGitLabDomainsRegex(Config $config)
  29528. {
  29529. return '(' . implode('|', array_map('preg_quote', $config->get('gitlab-domains'))) . ')';
  29530. }
  29531. private function throwException($message, $url)
  29532. {
  29533. clearstatcache();
  29534. if (0 !== $this->process->execute('git --version', $ignoredOutput)) {
  29535. 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()));
  29536. }
  29537. throw new \RuntimeException(Url::sanitize($message));
  29538. }
  29539. public static function getVersion(ProcessExecutor $process)
  29540. {
  29541. if (false === self::$version) {
  29542. self::$version = null;
  29543. if (!$process) {
  29544. $process = new ProcessExecutor;
  29545. }
  29546. if (0 === $process->execute('git --version', $output) && preg_match('/^git version (\d+(?:\.\d+)+)/m', $output, $matches)) {
  29547. self::$version = $matches[1];
  29548. }
  29549. }
  29550. return self::$version;
  29551. }
  29552. }
  29553. <?php
  29554. namespace Composer\Util;
  29555. use Composer\Factory;
  29556. use Composer\IO\IOInterface;
  29557. use Composer\Config;
  29558. use Composer\Downloader\TransportException;
  29559. class GitHub
  29560. {
  29561. protected $io;
  29562. protected $config;
  29563. protected $process;
  29564. protected $httpDownloader;
  29565. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  29566. {
  29567. $this->io = $io;
  29568. $this->config = $config;
  29569. $this->process = $process ?: new ProcessExecutor($io);
  29570. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  29571. }
  29572. public function authorizeOAuth($originUrl)
  29573. {
  29574. if (!in_array($originUrl, $this->config->get('github-domains'))) {
  29575. return false;
  29576. }
  29577. if (0 === $this->process->execute('git config github.accesstoken', $output)) {
  29578. $this->io->setAuthentication($originUrl, trim($output), 'x-oauth-basic');
  29579. return true;
  29580. }
  29581. return false;
  29582. }
  29583. public function authorizeOAuthInteractively($originUrl, $message = null)
  29584. {
  29585. if ($message) {
  29586. $this->io->writeError($message);
  29587. }
  29588. $note = 'Composer';
  29589. if ($this->config->get('github-expose-hostname') === true && 0 === $this->process->execute('hostname', $output)) {
  29590. $note .= ' on ' . trim($output);
  29591. }
  29592. $note .= ' ' . date('Y-m-d Hi');
  29593. $url = 'https://'.$originUrl.'/settings/tokens/new?scopes=repo&description=' . str_replace('%20', '+', rawurlencode($note));
  29594. $this->io->writeError(sprintf('Head to %s', $url));
  29595. $this->io->writeError(sprintf('to retrieve a token. It will be stored in "%s" for future use by Composer.', $this->config->getAuthConfigSource()->getName()));
  29596. $token = trim($this->io->askAndHideAnswer('Token (hidden): '));
  29597. if (!$token) {
  29598. $this->io->writeError('<warning>No token given, aborting.</warning>');
  29599. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  29600. return false;
  29601. }
  29602. $this->io->setAuthentication($originUrl, $token, 'x-oauth-basic');
  29603. try {
  29604. $apiUrl = ('github.com' === $originUrl) ? 'api.github.com/' : $originUrl . '/api/v3/';
  29605. $this->httpDownloader->get('https://'. $apiUrl, array(
  29606. 'retry-auth-failure' => false,
  29607. ));
  29608. } catch (TransportException $e) {
  29609. if (in_array($e->getCode(), array(403, 401))) {
  29610. $this->io->writeError('<error>Invalid token provided.</error>');
  29611. $this->io->writeError('You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"');
  29612. return false;
  29613. }
  29614. throw $e;
  29615. }
  29616. $this->config->getConfigSource()->removeConfigSetting('github-oauth.'.$originUrl);
  29617. $this->config->getAuthConfigSource()->addConfigSetting('github-oauth.'.$originUrl, $token);
  29618. $this->io->writeError('<info>Token stored successfully.</info>');
  29619. return true;
  29620. }
  29621. public function getRateLimit(array $headers)
  29622. {
  29623. $rateLimit = array(
  29624. 'limit' => '?',
  29625. 'reset' => '?',
  29626. );
  29627. foreach ($headers as $header) {
  29628. $header = trim($header);
  29629. if (false === strpos($header, 'X-RateLimit-')) {
  29630. continue;
  29631. }
  29632. list($type, $value) = explode(':', $header, 2);
  29633. switch ($type) {
  29634. case 'X-RateLimit-Limit':
  29635. $rateLimit['limit'] = (int) trim($value);
  29636. break;
  29637. case 'X-RateLimit-Reset':
  29638. $rateLimit['reset'] = date('Y-m-d H:i:s', (int) trim($value));
  29639. break;
  29640. }
  29641. }
  29642. return $rateLimit;
  29643. }
  29644. public function isRateLimited(array $headers)
  29645. {
  29646. foreach ($headers as $header) {
  29647. if (preg_match('{^X-RateLimit-Remaining: *0$}i', trim($header))) {
  29648. return true;
  29649. }
  29650. }
  29651. return false;
  29652. }
  29653. }
  29654. <?php
  29655. namespace Composer\Util;
  29656. use Composer\IO\IOInterface;
  29657. use Composer\Config;
  29658. use Composer\Factory;
  29659. use Composer\Downloader\TransportException;
  29660. class GitLab
  29661. {
  29662. protected $io;
  29663. protected $config;
  29664. protected $process;
  29665. protected $httpDownloader;
  29666. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process = null, HttpDownloader $httpDownloader = null)
  29667. {
  29668. $this->io = $io;
  29669. $this->config = $config;
  29670. $this->process = $process ?: new ProcessExecutor($io);
  29671. $this->httpDownloader = $httpDownloader ?: Factory::createHttpDownloader($this->io, $config);
  29672. }
  29673. public function authorizeOAuth($originUrl)
  29674. {
  29675. $bcOriginUrl = preg_replace('{:\d+}', '', $originUrl);
  29676. if (!in_array($originUrl, $this->config->get('gitlab-domains'), true) && !in_array($bcOriginUrl, $this->config->get('gitlab-domains'), true)) {
  29677. return false;
  29678. }
  29679. if (0 === $this->process->execute('git config gitlab.accesstoken', $output)) {
  29680. $this->io->setAuthentication($originUrl, trim($output), 'oauth2');
  29681. return true;
  29682. }
  29683. if (0 === $this->process->execute('git config gitlab.deploytoken.user', $tokenUser) && 0 === $this->process->execute('git config gitlab.deploytoken.token', $tokenPassword)) {
  29684. $this->io->setAuthentication($originUrl, trim($tokenUser), trim($tokenPassword));
  29685. return true;
  29686. }
  29687. $authTokens = $this->config->get('gitlab-token');
  29688. if (isset($authTokens[$originUrl])) {
  29689. $token = $authTokens[$originUrl];
  29690. }
  29691. if (isset($authTokens[$bcOriginUrl])) {
  29692. $token = $authTokens[$bcOriginUrl];
  29693. }
  29694. if (isset($token)) {
  29695. $username = is_array($token) && array_key_exists("username", $token) ? $token["username"] : $token;
  29696. $password = is_array($token) && array_key_exists("token", $token) ? $token["token"] : 'private-token';
  29697. $this->io->setAuthentication($originUrl, $username, $password);
  29698. return true;
  29699. }
  29700. return false;
  29701. }
  29702. public function authorizeOAuthInteractively($scheme, $originUrl, $message = null)
  29703. {
  29704. if ($message) {
  29705. $this->io->writeError($message);
  29706. }
  29707. $this->io->writeError(sprintf('A token will be created and stored in "%s", your password will never be stored', $this->config->getAuthConfigSource()->getName()));
  29708. $this->io->writeError('To revoke access to this token you can visit '.$scheme.'://'.$originUrl.'/profile/applications');
  29709. $attemptCounter = 0;
  29710. while ($attemptCounter++ < 5) {
  29711. try {
  29712. $response = $this->createToken($scheme, $originUrl);
  29713. } catch (TransportException $e) {
  29714. if (in_array($e->getCode(), array(403, 401))) {
  29715. if (401 === $e->getCode()) {
  29716. $response = json_decode($e->getResponse(), true);
  29717. if (isset($response['error']) && $response['error'] === 'invalid_grant') {
  29718. $this->io->writeError('Bad credentials. If you have two factor authentication enabled you will have to manually create a personal access token');
  29719. } else {
  29720. $this->io->writeError('Bad credentials.');
  29721. }
  29722. } else {
  29723. $this->io->writeError('Maximum number of login attempts exceeded. Please try again later.');
  29724. }
  29725. $this->io->writeError('You can also manually create a personal access token enabling the "read_api" scope at '.$scheme.'://'.$originUrl.'/profile/personal_access_tokens');
  29726. $this->io->writeError('Add it using "composer config --global --auth gitlab-token.'.$originUrl.' <token>"');
  29727. continue;
  29728. }
  29729. throw $e;
  29730. }
  29731. $this->io->setAuthentication($originUrl, $response['access_token'], 'oauth2');
  29732. $this->config->getAuthConfigSource()->addConfigSetting('gitlab-oauth.'.$originUrl, $response['access_token']);
  29733. return true;
  29734. }
  29735. throw new \RuntimeException('Invalid GitLab credentials 5 times in a row, aborting.');
  29736. }
  29737. private function createToken($scheme, $originUrl)
  29738. {
  29739. $username = $this->io->ask('Username: ');
  29740. $password = $this->io->askAndHideAnswer('Password: ');
  29741. $headers = array('Content-Type: application/x-www-form-urlencoded');
  29742. $apiUrl = $originUrl;
  29743. $data = http_build_query(array(
  29744. 'username' => $username,
  29745. 'password' => $password,
  29746. 'grant_type' => 'password',
  29747. ), null, '&');
  29748. $options = array(
  29749. 'retry-auth-failure' => false,
  29750. 'http' => array(
  29751. 'method' => 'POST',
  29752. 'header' => $headers,
  29753. 'content' => $data,
  29754. ),
  29755. );
  29756. $token = $this->httpDownloader->get($scheme.'://'.$apiUrl.'/oauth/token', $options)->decodeJson();
  29757. $this->io->writeError('Token successfully created');
  29758. return $token;
  29759. }
  29760. }
  29761. <?php
  29762. namespace Composer\Util;
  29763. use Composer\Config;
  29764. use Composer\IO\IOInterface;
  29765. class Hg
  29766. {
  29767. private $io;
  29768. private $config;
  29769. private $process;
  29770. public function __construct(IOInterface $io, Config $config, ProcessExecutor $process)
  29771. {
  29772. $this->io = $io;
  29773. $this->config = $config;
  29774. $this->process = $process;
  29775. }
  29776. public function runCommand($commandCallable, $url, $cwd)
  29777. {
  29778. $this->config->prohibitUrlByConfig($url, $this->io);
  29779. $command = call_user_func($commandCallable, $url);
  29780. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29781. return;
  29782. }
  29783. if (preg_match('{^(https?)://((.+)(?:\:(.+))?@)?([^/]+)(/.*)?}mi', $url, $match) && $this->io->hasAuthentication($match[5])) {
  29784. $auth = $this->io->getAuthentication($match[5]);
  29785. $authenticatedUrl = $match[1] . '://' . rawurlencode($auth['username']) . ':' . rawurlencode($auth['password']) . '@' . $match[5] . (!empty($match[6]) ? $match[6] : null);
  29786. $command = call_user_func($commandCallable, $authenticatedUrl);
  29787. if (0 === $this->process->execute($command, $ignoredOutput, $cwd)) {
  29788. return;
  29789. }
  29790. $error = $this->process->getErrorOutput();
  29791. } else {
  29792. $error = 'The given URL (' . $url . ') does not match the required format (http(s)://(username:password@)example.com/path-to-repository)';
  29793. }
  29794. $this->throwException('Failed to clone ' . $url . ', ' . "\n\n" . $error, $url);
  29795. }
  29796. private function throwException($message, $url)
  29797. {
  29798. if (0 !== $this->process->execute('hg --version', $ignoredOutput)) {
  29799. 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()));
  29800. }
  29801. throw new \RuntimeException(Url::sanitize($message));
  29802. }
  29803. }
  29804. <?php
  29805. namespace Composer\Util\Http;
  29806. use Composer\Config;
  29807. use Composer\Downloader\MaxFileSizeExceededException;
  29808. use Composer\IO\IOInterface;
  29809. use Composer\Downloader\TransportException;
  29810. use Composer\Util\StreamContextFactory;
  29811. use Composer\Util\AuthHelper;
  29812. use Composer\Util\Url;
  29813. use Composer\Util\HttpDownloader;
  29814. use React\Promise\Promise;
  29815. class CurlDownloader
  29816. {
  29817. private $multiHandle;
  29818. private $shareHandle;
  29819. private $jobs = array();
  29820. private $io;
  29821. private $config;
  29822. private $authHelper;
  29823. private $selectTimeout = 5.0;
  29824. private $maxRedirects = 20;
  29825. private $proxyManager;
  29826. private $supportsSecureProxy;
  29827. protected $multiErrors = array(
  29828. CURLM_BAD_HANDLE => array('CURLM_BAD_HANDLE', 'The passed-in handle is not a valid CURLM handle.'),
  29829. 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."),
  29830. CURLM_OUT_OF_MEMORY => array('CURLM_OUT_OF_MEMORY', 'You are doomed.'),
  29831. CURLM_INTERNAL_ERROR => array('CURLM_INTERNAL_ERROR', 'This can only be returned if libcurl bugs. Please report it to us!'),
  29832. );
  29833. private static $options = array(
  29834. 'http' => array(
  29835. 'method' => CURLOPT_CUSTOMREQUEST,
  29836. 'content' => CURLOPT_POSTFIELDS,
  29837. 'header' => CURLOPT_HTTPHEADER,
  29838. 'timeout' => CURLOPT_TIMEOUT,
  29839. ),
  29840. 'ssl' => array(
  29841. 'cafile' => CURLOPT_CAINFO,
  29842. 'capath' => CURLOPT_CAPATH,
  29843. 'verify_peer' => CURLOPT_SSL_VERIFYPEER,
  29844. 'verify_peer_name' => CURLOPT_SSL_VERIFYHOST,
  29845. 'local_cert' => CURLOPT_SSLCERT,
  29846. 'local_pk' => CURLOPT_SSLKEY,
  29847. 'passphrase' => CURLOPT_SSLKEYPASSWD,
  29848. ),
  29849. );
  29850. private static $timeInfo = array(
  29851. 'total_time' => true,
  29852. 'namelookup_time' => true,
  29853. 'connect_time' => true,
  29854. 'pretransfer_time' => true,
  29855. 'starttransfer_time' => true,
  29856. 'redirect_time' => true,
  29857. );
  29858. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  29859. {
  29860. $this->io = $io;
  29861. $this->config = $config;
  29862. $this->multiHandle = $mh = curl_multi_init();
  29863. if (function_exists('curl_multi_setopt')) {
  29864. curl_multi_setopt($mh, CURLMOPT_PIPELINING, PHP_VERSION_ID >= 70400 ? 2 : 3);
  29865. if (defined('CURLMOPT_MAX_HOST_CONNECTIONS') && !defined('HHVM_VERSION')) {
  29866. curl_multi_setopt($mh, CURLMOPT_MAX_HOST_CONNECTIONS, 8);
  29867. }
  29868. }
  29869. if (function_exists('curl_share_init')) {
  29870. $this->shareHandle = $sh = curl_share_init();
  29871. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);
  29872. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
  29873. curl_share_setopt($sh, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
  29874. }
  29875. $this->authHelper = new AuthHelper($io, $config);
  29876. $this->proxyManager = ProxyManager::getInstance();
  29877. $version = curl_version();
  29878. $features = $version['features'];
  29879. $this->supportsSecureProxy = defined('CURL_VERSION_HTTPS_PROXY') && ($features & CURL_VERSION_HTTPS_PROXY);
  29880. }
  29881. public function download($resolve, $reject, $origin, $url, $options, $copyTo = null)
  29882. {
  29883. $attributes = array();
  29884. if (isset($options['retry-auth-failure'])) {
  29885. $attributes['retryAuthFailure'] = $options['retry-auth-failure'];
  29886. unset($options['retry-auth-failure']);
  29887. }
  29888. return $this->initDownload($resolve, $reject, $origin, $url, $options, $copyTo, $attributes);
  29889. }
  29890. private function initDownload($resolve, $reject, $origin, $url, $options, $copyTo = null, array $attributes = array())
  29891. {
  29892. $attributes = array_merge(array(
  29893. 'retryAuthFailure' => true,
  29894. 'redirects' => 0,
  29895. 'storeAuth' => false,
  29896. ), $attributes);
  29897. $originalOptions = $options;
  29898. if (!preg_match('{^http://(repo\.)?packagist\.org/p/}', $url) || (false === strpos($url, '$') && false === strpos($url, '%24'))) {
  29899. $this->config->prohibitUrlByConfig($url, $this->io);
  29900. }
  29901. $curlHandle = curl_init();
  29902. $headerHandle = fopen('php://temp/maxmemory:32768', 'w+b');
  29903. if ($copyTo) {
  29904. $errorMessage = '';
  29905. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  29906. if ($errorMessage) {
  29907. $errorMessage .= "\n";
  29908. }
  29909. $errorMessage .= preg_replace('{^fopen\(.*?\): }', '', $msg);
  29910. });
  29911. $bodyHandle = fopen($copyTo.'~', 'w+b');
  29912. restore_error_handler();
  29913. if (!$bodyHandle) {
  29914. throw new TransportException('The "'.$url.'" file could not be written to '.$copyTo.': '.$errorMessage);
  29915. }
  29916. } else {
  29917. $bodyHandle = @fopen('php://temp/maxmemory:524288', 'w+b');
  29918. }
  29919. curl_setopt($curlHandle, CURLOPT_URL, $url);
  29920. curl_setopt($curlHandle, CURLOPT_FOLLOWLOCATION, false);
  29921. curl_setopt($curlHandle, CURLOPT_CONNECTTIMEOUT, 10);
  29922. curl_setopt($curlHandle, CURLOPT_TIMEOUT, 300);
  29923. curl_setopt($curlHandle, CURLOPT_WRITEHEADER, $headerHandle);
  29924. curl_setopt($curlHandle, CURLOPT_FILE, $bodyHandle);
  29925. curl_setopt($curlHandle, CURLOPT_ENCODING, "gzip");
  29926. curl_setopt($curlHandle, CURLOPT_PROTOCOLS, CURLPROTO_HTTP | CURLPROTO_HTTPS);
  29927. if (function_exists('curl_share_init')) {
  29928. curl_setopt($curlHandle, CURLOPT_SHARE, $this->shareHandle);
  29929. }
  29930. if (!isset($options['http']['header'])) {
  29931. $options['http']['header'] = array();
  29932. }
  29933. $options['http']['header'] = array_diff($options['http']['header'], array('Connection: close'));
  29934. $options['http']['header'][] = 'Connection: keep-alive';
  29935. $version = curl_version();
  29936. $features = $version['features'];
  29937. if (0 === strpos($url, 'https://') && \defined('CURL_VERSION_HTTP2') && \defined('CURL_HTTP_VERSION_2_0') && (CURL_VERSION_HTTP2 & $features)) {
  29938. curl_setopt($curlHandle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
  29939. }
  29940. $options['http']['header'] = $this->authHelper->addAuthenticationHeader($options['http']['header'], $origin, $url);
  29941. $options = StreamContextFactory::initOptions($url, $options, true);
  29942. foreach (self::$options as $type => $curlOptions) {
  29943. foreach ($curlOptions as $name => $curlOption) {
  29944. if (isset($options[$type][$name])) {
  29945. if ($type === 'ssl' && $name === 'verify_peer_name') {
  29946. curl_setopt($curlHandle, $curlOption, $options[$type][$name] === true ? 2 : $options[$type][$name]);
  29947. } else {
  29948. curl_setopt($curlHandle, $curlOption, $options[$type][$name]);
  29949. }
  29950. }
  29951. }
  29952. }
  29953. $proxy = $this->proxyManager->getProxyForRequest($url);
  29954. curl_setopt($curlHandle, CURLOPT_PROXY, $proxy->getUrl());
  29955. if ($proxy->isSecure()) {
  29956. if (!$this->supportsSecureProxy) {
  29957. throw new TransportException('Connecting to a secure proxy using curl is not supported on PHP versions below 7.3.0.');
  29958. }
  29959. if (!empty($options['ssl']['cafile'])) {
  29960. curl_setopt($curlHandle, CURLOPT_PROXY_CAINFO, $options['ssl']['cafile']);
  29961. }
  29962. if (!empty($options['ssl']['capath'])) {
  29963. curl_setopt($curlHandle, CURLOPT_PROXY_CAPATH, $options['ssl']['capath']);
  29964. }
  29965. }
  29966. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  29967. $this->jobs[(int) $curlHandle] = array(
  29968. 'url' => $url,
  29969. 'origin' => $origin,
  29970. 'attributes' => $attributes,
  29971. 'options' => $originalOptions,
  29972. 'progress' => $progress,
  29973. 'curlHandle' => $curlHandle,
  29974. 'filename' => $copyTo,
  29975. 'headerHandle' => $headerHandle,
  29976. 'bodyHandle' => $bodyHandle,
  29977. 'resolve' => $resolve,
  29978. 'reject' => $reject,
  29979. );
  29980. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  29981. $ifModified = false !== stripos(implode(',', $options['http']['header']), 'if-modified-since:') ? ' if modified' : '';
  29982. if ($attributes['redirects'] === 0) {
  29983. $this->io->writeError('Downloading ' . Url::sanitize($url) . $usingProxy . $ifModified, true, IOInterface::DEBUG);
  29984. }
  29985. $this->checkCurlResult(curl_multi_add_handle($this->multiHandle, $curlHandle));
  29986. return (int) $curlHandle;
  29987. }
  29988. public function abortRequest($id)
  29989. {
  29990. if (isset($this->jobs[$id], $this->jobs[$id]['handle'])) {
  29991. $job = $this->jobs[$id];
  29992. curl_multi_remove_handle($this->multiHandle, $job['handle']);
  29993. curl_close($job['handle']);
  29994. if (is_resource($job['headerHandle'])) {
  29995. fclose($job['headerHandle']);
  29996. }
  29997. if (is_resource($job['bodyHandle'])) {
  29998. fclose($job['bodyHandle']);
  29999. }
  30000. if ($job['filename']) {
  30001. @unlink($job['filename'].'~');
  30002. }
  30003. unset($this->jobs[$id]);
  30004. }
  30005. }
  30006. public function tick()
  30007. {
  30008. if (!$this->jobs) {
  30009. return;
  30010. }
  30011. $active = true;
  30012. $this->checkCurlResult(curl_multi_exec($this->multiHandle, $active));
  30013. if (-1 === curl_multi_select($this->multiHandle, $this->selectTimeout)) {
  30014. usleep(150);
  30015. }
  30016. while ($progress = curl_multi_info_read($this->multiHandle)) {
  30017. $curlHandle = $progress['handle'];
  30018. $result = $progress['result'];
  30019. $i = (int) $curlHandle;
  30020. if (!isset($this->jobs[$i])) {
  30021. continue;
  30022. }
  30023. $progress = curl_getinfo($curlHandle);
  30024. $job = $this->jobs[$i];
  30025. unset($this->jobs[$i]);
  30026. $error = curl_error($curlHandle);
  30027. $errno = curl_errno($curlHandle);
  30028. curl_multi_remove_handle($this->multiHandle, $curlHandle);
  30029. curl_close($curlHandle);
  30030. $headers = null;
  30031. $statusCode = null;
  30032. $response = null;
  30033. try {
  30034. if (CURLE_OK !== $errno || $error || $result !== CURLE_OK) {
  30035. $errno = $errno ?: $result;
  30036. if (!$error && function_exists('curl_strerror')) {
  30037. $error = curl_strerror($errno);
  30038. }
  30039. throw new TransportException('curl error '.$errno.' while downloading '.Url::sanitize($progress['url']).': '.$error);
  30040. }
  30041. $statusCode = $progress['http_code'];
  30042. rewind($job['headerHandle']);
  30043. $headers = explode("\r\n", rtrim(stream_get_contents($job['headerHandle'])));
  30044. fclose($job['headerHandle']);
  30045. if ($statusCode === 0) {
  30046. throw new \LogicException('Received unexpected http status code 0 without error for '.Url::sanitize($progress['url']).': headers '.var_export($headers, true).' curl info '.var_export($progress, true));
  30047. }
  30048. if ($job['filename']) {
  30049. $contents = $job['filename'].'~';
  30050. if ($statusCode >= 300) {
  30051. rewind($job['bodyHandle']);
  30052. $contents = stream_get_contents($job['bodyHandle']);
  30053. }
  30054. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  30055. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  30056. } else {
  30057. rewind($job['bodyHandle']);
  30058. $contents = stream_get_contents($job['bodyHandle']);
  30059. $response = new CurlResponse(array('url' => $progress['url']), $statusCode, $headers, $contents, $progress);
  30060. $this->io->writeError('['.$statusCode.'] '.Url::sanitize($progress['url']), true, IOInterface::DEBUG);
  30061. }
  30062. fclose($job['bodyHandle']);
  30063. if ($response->getStatusCode() >= 400 && $response->getHeader('content-type') === 'application/json') {
  30064. HttpDownloader::outputWarnings($this->io, $job['origin'], json_decode($response->getBody(), true));
  30065. }
  30066. $result = $this->isAuthenticatedRetryNeeded($job, $response);
  30067. if ($result['retry']) {
  30068. $this->restartJob($job, $job['url'], array('storeAuth' => $result['storeAuth']));
  30069. continue;
  30070. }
  30071. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $job['attributes']['redirects'] < $this->maxRedirects) {
  30072. $location = $this->handleRedirect($job, $response);
  30073. if ($location) {
  30074. $this->restartJob($job, $location, array('redirects' => $job['attributes']['redirects'] + 1));
  30075. continue;
  30076. }
  30077. }
  30078. if ($statusCode >= 400 && $statusCode <= 599) {
  30079. throw $this->failResponse($job, $response, $response->getStatusMessage());
  30080. }
  30081. if ($job['attributes']['storeAuth']) {
  30082. $this->authHelper->storeAuth($job['origin'], $job['attributes']['storeAuth']);
  30083. }
  30084. if ($job['filename']) {
  30085. rename($job['filename'].'~', $job['filename']);
  30086. call_user_func($job['resolve'], $response);
  30087. } else {
  30088. call_user_func($job['resolve'], $response);
  30089. }
  30090. } catch (\Exception $e) {
  30091. if ($e instanceof TransportException && $headers) {
  30092. $e->setHeaders($headers);
  30093. $e->setStatusCode($statusCode);
  30094. }
  30095. if ($e instanceof TransportException && $response) {
  30096. $e->setResponse($response->getBody());
  30097. }
  30098. if ($e instanceof TransportException && $progress) {
  30099. $e->setResponseInfo($progress);
  30100. }
  30101. if (is_resource($job['headerHandle'])) {
  30102. fclose($job['headerHandle']);
  30103. }
  30104. if (is_resource($job['bodyHandle'])) {
  30105. fclose($job['bodyHandle']);
  30106. }
  30107. if ($job['filename']) {
  30108. @unlink($job['filename'].'~');
  30109. }
  30110. call_user_func($job['reject'], $e);
  30111. }
  30112. }
  30113. foreach ($this->jobs as $i => $curlHandle) {
  30114. if (!isset($this->jobs[$i])) {
  30115. continue;
  30116. }
  30117. $curlHandle = $this->jobs[$i]['curlHandle'];
  30118. $progress = array_diff_key(curl_getinfo($curlHandle), self::$timeInfo);
  30119. if ($this->jobs[$i]['progress'] !== $progress) {
  30120. $this->jobs[$i]['progress'] = $progress;
  30121. if (isset($this->jobs[$i]['options']['max_file_size'])) {
  30122. if ($this->jobs[$i]['options']['max_file_size'] < $progress['download_content_length']) {
  30123. 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');
  30124. }
  30125. if ($this->jobs[$i]['options']['max_file_size'] < $progress['size_download']) {
  30126. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . $progress['size_download'] . ' of allowed ' . $this->jobs[$i]['options']['max_file_size'] . ' bytes');
  30127. }
  30128. }
  30129. }
  30130. }
  30131. }
  30132. private function handleRedirect(array $job, Response $response)
  30133. {
  30134. if ($locationHeader = $response->getHeader('location')) {
  30135. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  30136. $targetUrl = $locationHeader;
  30137. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  30138. $targetUrl = parse_url($job['url'], PHP_URL_SCHEME).':'.$locationHeader;
  30139. } elseif ('/' === $locationHeader[0]) {
  30140. $urlHost = parse_url($job['url'], PHP_URL_HOST);
  30141. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $job['url']);
  30142. } else {
  30143. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $job['url']);
  30144. }
  30145. }
  30146. if (!empty($targetUrl)) {
  30147. $this->io->writeError(sprintf('Following redirect (%u) %s', $job['attributes']['redirects'] + 1, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  30148. return $targetUrl;
  30149. }
  30150. throw new TransportException('The "'.$job['url'].'" file could not be downloaded, got redirect without Location ('.$response->getStatusMessage().')');
  30151. }
  30152. private function isAuthenticatedRetryNeeded(array $job, Response $response)
  30153. {
  30154. if (in_array($response->getStatusCode(), array(401, 403)) && $job['attributes']['retryAuthFailure']) {
  30155. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], $response->getStatusCode(), $response->getStatusMessage(), $response->getHeaders());
  30156. if ($result['retry']) {
  30157. return $result;
  30158. }
  30159. }
  30160. $locationHeader = $response->getHeader('location');
  30161. $needsAuthRetry = false;
  30162. if (
  30163. $job['origin'] === 'bitbucket.org'
  30164. && !$this->authHelper->isPublicBitBucketDownload($job['url'])
  30165. && substr($job['url'], -4) === '.zip'
  30166. && (!$locationHeader || substr($locationHeader, -4) !== '.zip')
  30167. && preg_match('{^text/html\b}i', $response->getHeader('content-type'))
  30168. ) {
  30169. $needsAuthRetry = 'Bitbucket requires authentication and it was not provided';
  30170. }
  30171. if (
  30172. $response->getStatusCode() === 404
  30173. && $this->config && in_array($job['origin'], $this->config->get('gitlab-domains'), true)
  30174. && false !== strpos($job['url'], 'archive.zip')
  30175. ) {
  30176. $needsAuthRetry = 'GitLab requires authentication and it was not provided';
  30177. }
  30178. if ($needsAuthRetry) {
  30179. if ($job['attributes']['retryAuthFailure']) {
  30180. $result = $this->authHelper->promptAuthIfNeeded($job['url'], $job['origin'], 401);
  30181. if ($result['retry']) {
  30182. return $result;
  30183. }
  30184. }
  30185. throw $this->failResponse($job, $response, $needsAuthRetry);
  30186. }
  30187. return array('retry' => false, 'storeAuth' => false);
  30188. }
  30189. private function restartJob(array $job, $url, array $attributes = array())
  30190. {
  30191. if ($job['filename']) {
  30192. @unlink($job['filename'].'~');
  30193. }
  30194. $attributes = array_merge($job['attributes'], $attributes);
  30195. $origin = Url::getOrigin($this->config, $url);
  30196. $this->initDownload($job['resolve'], $job['reject'], $origin, $url, $job['options'], $job['filename'], $attributes);
  30197. }
  30198. private function failResponse(array $job, Response $response, $errorMessage)
  30199. {
  30200. if ($job['filename']) {
  30201. @unlink($job['filename'].'~');
  30202. }
  30203. $details = '';
  30204. if ($response->getHeader('content-type') === 'application/json') {
  30205. $details = ':'.PHP_EOL.substr($response->getBody(), 0, 200).(strlen($response->getBody()) > 200 ? '...' : '');
  30206. }
  30207. return new TransportException('The "'.$job['url'].'" file could not be downloaded ('.$errorMessage.')' . $details, $response->getStatusCode());
  30208. }
  30209. private function checkCurlResult($code)
  30210. {
  30211. if ($code != CURLM_OK && $code != CURLM_CALL_MULTI_PERFORM) {
  30212. throw new \RuntimeException(
  30213. isset($this->multiErrors[$code])
  30214. ? "cURL error: {$code} ({$this->multiErrors[$code][0]}): cURL message: {$this->multiErrors[$code][1]}"
  30215. : 'Unexpected cURL error: ' . $code
  30216. );
  30217. }
  30218. }
  30219. }
  30220. <?php
  30221. namespace Composer\Util\Http;
  30222. class CurlResponse extends Response
  30223. {
  30224. private $curlInfo;
  30225. public function __construct(array $request, $code, array $headers, $body, array $curlInfo)
  30226. {
  30227. parent::__construct($request, $code, $headers, $body);
  30228. $this->curlInfo = $curlInfo;
  30229. }
  30230. public function getCurlInfo()
  30231. {
  30232. return $this->curlInfo;
  30233. }
  30234. }
  30235. <?php
  30236. namespace Composer\Util\Http;
  30237. class ProxyHelper
  30238. {
  30239. public static function getProxyData()
  30240. {
  30241. $httpProxy = null;
  30242. $httpsProxy = null;
  30243. if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
  30244. if ($env = self::getProxyEnv(array('http_proxy', 'HTTP_PROXY'), $name)) {
  30245. $httpProxy = self::checkProxy($env, $name);
  30246. }
  30247. }
  30248. if ($env = self::getProxyEnv(array('CGI_HTTP_PROXY'), $name)) {
  30249. $httpProxy = self::checkProxy($env, $name);
  30250. }
  30251. if ($env = self::getProxyEnv(array('https_proxy', 'HTTPS_PROXY'), $name)) {
  30252. $httpsProxy = self::checkProxy($env, $name);
  30253. } else {
  30254. $httpsProxy = $httpProxy;
  30255. }
  30256. $noProxy = self::getProxyEnv(array('no_proxy', 'NO_PROXY'), $name);
  30257. return array($httpProxy, $httpsProxy, $noProxy);
  30258. }
  30259. public static function getContextOptions($proxyUrl)
  30260. {
  30261. $proxy = parse_url($proxyUrl);
  30262. $proxyUrl = self::formatParsedUrl($proxy, false);
  30263. $proxyUrl = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyUrl);
  30264. $options['http']['proxy'] = $proxyUrl;
  30265. if (isset($proxy['user'])) {
  30266. $auth = rawurldecode($proxy['user']);
  30267. if (isset($proxy['pass'])) {
  30268. $auth .= ':' . rawurldecode($proxy['pass']);
  30269. }
  30270. $auth = base64_encode($auth);
  30271. $options['http']['header'] = "Proxy-Authorization: Basic {$auth}";
  30272. }
  30273. return $options;
  30274. }
  30275. public static function setRequestFullUri($requestUrl, array &$options)
  30276. {
  30277. if ('http' === parse_url($requestUrl, PHP_URL_SCHEME)) {
  30278. $options['http']['request_fulluri'] = true;
  30279. } else {
  30280. unset($options['http']['request_fulluri']);
  30281. }
  30282. }
  30283. private static function getProxyEnv(array $names, &$name)
  30284. {
  30285. foreach ($names as $name) {
  30286. if (!empty($_SERVER[$name])) {
  30287. return $_SERVER[$name];
  30288. }
  30289. }
  30290. }
  30291. private static function checkProxy($proxyUrl, $envName)
  30292. {
  30293. $error = sprintf('malformed %s url', $envName);
  30294. $proxy = parse_url($proxyUrl);
  30295. if (!isset($proxy['host'])) {
  30296. throw new \RuntimeException($error);
  30297. }
  30298. $proxyUrl = self::formatParsedUrl($proxy, true);
  30299. if (!parse_url($proxyUrl, PHP_URL_PORT)) {
  30300. throw new \RuntimeException($error);
  30301. }
  30302. return $proxyUrl;
  30303. }
  30304. private static function formatParsedUrl(array $proxy, $includeAuth)
  30305. {
  30306. $proxyUrl = isset($proxy['scheme']) ? strtolower($proxy['scheme']) . '://' : '';
  30307. if ($includeAuth && isset($proxy['user'])) {
  30308. $proxyUrl .= $proxy['user'];
  30309. if (isset($proxy['pass'])) {
  30310. $proxyUrl .= ':' . $proxy['pass'];
  30311. }
  30312. $proxyUrl .= '@';
  30313. }
  30314. $proxyUrl .= $proxy['host'];
  30315. if (isset($proxy['port'])) {
  30316. $proxyUrl .= ':' . $proxy['port'];
  30317. } elseif (strpos($proxyUrl, 'http://') === 0) {
  30318. $proxyUrl .= ':80';
  30319. } elseif (strpos($proxyUrl, 'https://') === 0) {
  30320. $proxyUrl .= ':443';
  30321. }
  30322. return $proxyUrl;
  30323. }
  30324. }
  30325. <?php
  30326. namespace Composer\Util\Http;
  30327. use Composer\Downloader\TransportException;
  30328. use Composer\Util\NoProxyPattern;
  30329. use Composer\Util\Url;
  30330. class ProxyManager
  30331. {
  30332. private $error;
  30333. private $fullProxy;
  30334. private $safeProxy;
  30335. private $streams;
  30336. private $hasProxy;
  30337. private $info;
  30338. private $lastProxy;
  30339. private $noProxyHandler;
  30340. private static $instance;
  30341. private function __construct()
  30342. {
  30343. $this->fullProxy = $this->safeProxy = array(
  30344. 'http' => null,
  30345. 'https' => null,
  30346. );
  30347. $this->streams['http'] = $this->streams['https'] = array(
  30348. 'options' => null,
  30349. );
  30350. $this->hasProxy = false;
  30351. $this->initProxyData();
  30352. }
  30353. public static function getInstance()
  30354. {
  30355. if (!self::$instance) {
  30356. self::$instance = new self();
  30357. }
  30358. return self::$instance;
  30359. }
  30360. public static function reset()
  30361. {
  30362. self::$instance = null;
  30363. }
  30364. public function getProxyForRequest($requestUrl)
  30365. {
  30366. if ($this->error) {
  30367. throw new TransportException('Unable to use a proxy: '.$this->error);
  30368. }
  30369. $scheme = parse_url($requestUrl, PHP_URL_SCHEME) ?: 'http';
  30370. $proxyUrl = '';
  30371. $options = array();
  30372. $formattedProxyUrl = '';
  30373. if ($this->hasProxy && $this->fullProxy[$scheme]) {
  30374. if ($this->noProxy($requestUrl)) {
  30375. $formattedProxyUrl = 'excluded by no_proxy';
  30376. } else {
  30377. $proxyUrl = $this->fullProxy[$scheme];
  30378. $options = $this->streams[$scheme]['options'];
  30379. ProxyHelper::setRequestFullUri($requestUrl, $options);
  30380. $formattedProxyUrl = $this->safeProxy[$scheme];
  30381. }
  30382. }
  30383. return new RequestProxy($proxyUrl, $options, $formattedProxyUrl);
  30384. }
  30385. public function isProxying()
  30386. {
  30387. return $this->hasProxy;
  30388. }
  30389. public function getFormattedProxy()
  30390. {
  30391. return $this->hasProxy ? $this->info : $this->error;
  30392. }
  30393. private function initProxyData()
  30394. {
  30395. try {
  30396. list($httpProxy, $httpsProxy, $noProxy) = ProxyHelper::getProxyData();
  30397. } catch (\RuntimeException $e) {
  30398. $this->error = $e->getMessage();
  30399. return;
  30400. }
  30401. $info = array();
  30402. if ($httpProxy) {
  30403. $info[] = $this->setData($httpProxy, 'http');
  30404. }
  30405. if ($httpsProxy) {
  30406. $info[] = $this->setData($httpsProxy, 'https');
  30407. }
  30408. if ($this->hasProxy) {
  30409. $this->info = implode(', ', $info);
  30410. if ($noProxy) {
  30411. $this->noProxyHandler = array(new NoProxyPattern($noProxy), 'test');
  30412. }
  30413. }
  30414. }
  30415. private function setData($url, $scheme)
  30416. {
  30417. $safeProxy = Url::sanitize($url);
  30418. $this->fullProxy[$scheme] = $url;
  30419. $this->safeProxy[$scheme] = $safeProxy;
  30420. $this->streams[$scheme]['options'] = ProxyHelper::getContextOptions($url);
  30421. $this->hasProxy = true;
  30422. return sprintf('%s=%s', $scheme, $safeProxy);
  30423. }
  30424. private function noProxy($requestUrl)
  30425. {
  30426. if ($this->noProxyHandler) {
  30427. if (call_user_func($this->noProxyHandler, $requestUrl)) {
  30428. $this->lastProxy = 'excluded by no_proxy';
  30429. return true;
  30430. }
  30431. }
  30432. return false;
  30433. }
  30434. }
  30435. <?php
  30436. namespace Composer\Util\Http;
  30437. use Composer\Util\Url;
  30438. class RequestProxy
  30439. {
  30440. private $contextOptions;
  30441. private $isSecure;
  30442. private $formattedUrl;
  30443. private $url;
  30444. public function __construct($url, array $contextOptions, $formattedUrl)
  30445. {
  30446. $this->url = $url;
  30447. $this->contextOptions = $contextOptions;
  30448. $this->formattedUrl = $formattedUrl;
  30449. $this->isSecure = 0 === strpos($url, 'https://');
  30450. }
  30451. public function getContextOptions()
  30452. {
  30453. return $this->contextOptions;
  30454. }
  30455. public function getFormattedUrl($format = '')
  30456. {
  30457. $result = '';
  30458. if ($this->formattedUrl) {
  30459. $format = $format ?: '%s';
  30460. $result = sprintf($format, $this->formattedUrl);
  30461. }
  30462. return $result;
  30463. }
  30464. public function getUrl()
  30465. {
  30466. return $this->url;
  30467. }
  30468. public function isSecure()
  30469. {
  30470. return $this->isSecure;
  30471. }
  30472. }
  30473. <?php
  30474. namespace Composer\Util\Http;
  30475. use Composer\Json\JsonFile;
  30476. class Response
  30477. {
  30478. private $request;
  30479. private $code;
  30480. private $headers;
  30481. private $body;
  30482. public function __construct(array $request, $code, array $headers, $body)
  30483. {
  30484. if (!isset($request['url'])) {
  30485. throw new \LogicException('url key missing from request array');
  30486. }
  30487. $this->request = $request;
  30488. $this->code = (int) $code;
  30489. $this->headers = $headers;
  30490. $this->body = $body;
  30491. }
  30492. public function getStatusCode()
  30493. {
  30494. return $this->code;
  30495. }
  30496. public function getStatusMessage()
  30497. {
  30498. $value = null;
  30499. foreach ($this->headers as $header) {
  30500. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  30501. $value = $header;
  30502. }
  30503. }
  30504. return $value;
  30505. }
  30506. public function getHeaders()
  30507. {
  30508. return $this->headers;
  30509. }
  30510. public function getHeader($name)
  30511. {
  30512. return self::findHeaderValue($this->headers, $name);
  30513. }
  30514. public function getBody()
  30515. {
  30516. return $this->body;
  30517. }
  30518. public function decodeJson()
  30519. {
  30520. return JsonFile::parseJson($this->body, $this->request['url']);
  30521. }
  30522. public function collect()
  30523. {
  30524. $this->request = $this->code = $this->headers = $this->body = null;
  30525. }
  30526. public static function findHeaderValue(array $headers, $name)
  30527. {
  30528. $value = null;
  30529. foreach ($headers as $header) {
  30530. if (preg_match('{^'.preg_quote($name).':\s*(.+?)\s*$}i', $header, $match)) {
  30531. $value = $match[1];
  30532. }
  30533. }
  30534. return $value;
  30535. }
  30536. }
  30537. <?php
  30538. namespace Composer\Util;
  30539. use Composer\Config;
  30540. use Composer\IO\IOInterface;
  30541. use Composer\Downloader\TransportException;
  30542. use Composer\Util\Http\Response;
  30543. use Composer\Composer;
  30544. use Composer\Package\Version\VersionParser;
  30545. use Composer\Semver\Constraint\Constraint;
  30546. use React\Promise\Promise;
  30547. class HttpDownloader
  30548. {
  30549. const STATUS_QUEUED = 1;
  30550. const STATUS_STARTED = 2;
  30551. const STATUS_COMPLETED = 3;
  30552. const STATUS_FAILED = 4;
  30553. const STATUS_ABORTED = 5;
  30554. private $io;
  30555. private $config;
  30556. private $jobs = array();
  30557. private $options = array();
  30558. private $runningJobs = 0;
  30559. private $maxJobs = 10;
  30560. private $curl;
  30561. private $rfs;
  30562. private $idGen = 0;
  30563. private $disabled;
  30564. private $allowAsync = false;
  30565. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false)
  30566. {
  30567. $this->io = $io;
  30568. $this->disabled = (bool) getenv('COMPOSER_DISABLE_NETWORK');
  30569. if ($disableTls === false) {
  30570. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  30571. }
  30572. $this->options = array_replace_recursive($this->options, $options);
  30573. $this->config = $config;
  30574. if (self::isCurlEnabled()) {
  30575. $this->curl = new Http\CurlDownloader($io, $config, $options, $disableTls);
  30576. }
  30577. $this->rfs = new RemoteFilesystem($io, $config, $options, $disableTls);
  30578. }
  30579. public function get($url, $options = array())
  30580. {
  30581. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
  30582. $this->wait($job['id']);
  30583. $response = $this->getResponse($job['id']);
  30584. if (
  30585. $this->curl
  30586. && PHP_VERSION_ID < 70000
  30587. && $response->getBody() === null
  30588. && $response->getStatusCode() === 200
  30589. && $response->getHeader('content-length') !== '0'
  30590. ) {
  30591. $this->io->writeError('<warning>cURL downloader failed to return a response, disabling it and proceeding in slow mode.</warning>');
  30592. $this->curl = null;
  30593. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false), true);
  30594. $this->wait($job['id']);
  30595. $response = $this->getResponse($job['id']);
  30596. }
  30597. return $response;
  30598. }
  30599. public function add($url, $options = array())
  30600. {
  30601. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => false));
  30602. return $promise;
  30603. }
  30604. public function copy($url, $to, $options = array())
  30605. {
  30606. list($job) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to), true);
  30607. $this->wait($job['id']);
  30608. return $this->getResponse($job['id']);
  30609. }
  30610. public function addCopy($url, $to, $options = array())
  30611. {
  30612. list(, $promise) = $this->addJob(array('url' => $url, 'options' => $options, 'copyTo' => $to));
  30613. return $promise;
  30614. }
  30615. public function getOptions()
  30616. {
  30617. return $this->options;
  30618. }
  30619. public function setOptions(array $options)
  30620. {
  30621. $this->options = array_replace_recursive($this->options, $options);
  30622. }
  30623. private function addJob($request, $sync = false)
  30624. {
  30625. $request['options'] = array_replace_recursive($this->options, $request['options']);
  30626. $job = array(
  30627. 'id' => $this->idGen++,
  30628. 'status' => self::STATUS_QUEUED,
  30629. 'request' => $request,
  30630. 'sync' => $sync,
  30631. 'origin' => Url::getOrigin($this->config, $request['url']),
  30632. );
  30633. if (!$sync && !$this->allowAsync) {
  30634. 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');
  30635. }
  30636. if (preg_match('{^https?://([^:/]+):([^@/]+)@([^/]+)}i', $request['url'], $match)) {
  30637. $this->io->setAuthentication($job['origin'], rawurldecode($match[1]), rawurldecode($match[2]));
  30638. }
  30639. $rfs = $this->rfs;
  30640. if ($this->canUseCurl($job)) {
  30641. $resolver = function ($resolve, $reject) use (&$job) {
  30642. $job['status'] = HttpDownloader::STATUS_QUEUED;
  30643. $job['resolve'] = $resolve;
  30644. $job['reject'] = $reject;
  30645. };
  30646. } else {
  30647. $resolver = function ($resolve, $reject) use (&$job, $rfs) {
  30648. $url = $job['request']['url'];
  30649. $options = $job['request']['options'];
  30650. $job['status'] = HttpDownloader::STATUS_STARTED;
  30651. if ($job['request']['copyTo']) {
  30652. $rfs->copy($job['origin'], $url, $job['request']['copyTo'], false , $options);
  30653. $headers = $rfs->getLastHeaders();
  30654. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $job['request']['copyTo'].'~');
  30655. $resolve($response);
  30656. } else {
  30657. $body = $rfs->getContents($job['origin'], $url, false , $options);
  30658. $headers = $rfs->getLastHeaders();
  30659. $response = new Http\Response($job['request'], $rfs->findStatusCode($headers), $headers, $body);
  30660. $resolve($response);
  30661. }
  30662. };
  30663. }
  30664. $downloader = $this;
  30665. $curl = $this->curl;
  30666. $canceler = function () use (&$job, $curl) {
  30667. if ($job['status'] === HttpDownloader::STATUS_QUEUED) {
  30668. $job['status'] = HttpDownloader::STATUS_ABORTED;
  30669. }
  30670. if ($job['status'] !== HttpDownloader::STATUS_STARTED) {
  30671. return;
  30672. }
  30673. $job['status'] = HttpDownloader::STATUS_ABORTED;
  30674. if (isset($job['curl_id'])) {
  30675. $curl->abortRequest($job['curl_id']);
  30676. }
  30677. };
  30678. $promise = new Promise($resolver, $canceler);
  30679. $promise->then(function ($response) use (&$job, $downloader) {
  30680. $job['status'] = HttpDownloader::STATUS_COMPLETED;
  30681. $job['response'] = $response;
  30682. $downloader->markJobDone();
  30683. return $response;
  30684. }, function ($e) use (&$job, $downloader) {
  30685. $job['status'] = HttpDownloader::STATUS_FAILED;
  30686. $job['exception'] = $e;
  30687. $downloader->markJobDone();
  30688. throw $e;
  30689. });
  30690. $this->jobs[$job['id']] = &$job;
  30691. if ($this->runningJobs < $this->maxJobs) {
  30692. $this->startJob($job['id']);
  30693. }
  30694. return array($job, $promise);
  30695. }
  30696. private function startJob($id)
  30697. {
  30698. $job = &$this->jobs[$id];
  30699. if ($job['status'] !== self::STATUS_QUEUED) {
  30700. return;
  30701. }
  30702. $job['status'] = self::STATUS_STARTED;
  30703. $this->runningJobs++;
  30704. $resolve = $job['resolve'];
  30705. $reject = $job['reject'];
  30706. $url = $job['request']['url'];
  30707. $options = $job['request']['options'];
  30708. $origin = $job['origin'];
  30709. if ($this->disabled) {
  30710. if (isset($job['request']['options']['http']['header']) && false !== stripos(implode('', $job['request']['options']['http']['header']), 'if-modified-since')) {
  30711. $resolve(new Response(array('url' => $url), 304, array(), ''));
  30712. } else {
  30713. $e = new TransportException('Network disabled, request canceled: '.$url, 499);
  30714. $e->setStatusCode(499);
  30715. $reject($e);
  30716. }
  30717. return;
  30718. }
  30719. try {
  30720. if ($job['request']['copyTo']) {
  30721. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options, $job['request']['copyTo']);
  30722. } else {
  30723. $job['curl_id'] = $this->curl->download($resolve, $reject, $origin, $url, $options);
  30724. }
  30725. } catch (\Exception $exception) {
  30726. $reject($exception);
  30727. }
  30728. }
  30729. public function markJobDone()
  30730. {
  30731. $this->runningJobs--;
  30732. }
  30733. public function wait($index = null)
  30734. {
  30735. do {
  30736. $jobCount = $this->countActiveJobs($index);
  30737. } while ($jobCount);
  30738. }
  30739. public function enableAsync()
  30740. {
  30741. $this->allowAsync = true;
  30742. }
  30743. public function countActiveJobs($index = null)
  30744. {
  30745. if ($this->runningJobs < $this->maxJobs) {
  30746. foreach ($this->jobs as $job) {
  30747. if ($job['status'] === self::STATUS_QUEUED && $this->runningJobs < $this->maxJobs) {
  30748. $this->startJob($job['id']);
  30749. }
  30750. }
  30751. }
  30752. if ($this->curl) {
  30753. $this->curl->tick();
  30754. }
  30755. if (null !== $index) {
  30756. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  30757. }
  30758. $active = 0;
  30759. foreach ($this->jobs as $job) {
  30760. if ($job['status'] < self::STATUS_COMPLETED) {
  30761. $active++;
  30762. } elseif (!$job['sync']) {
  30763. unset($this->jobs[$job['id']]);
  30764. }
  30765. }
  30766. return $active;
  30767. }
  30768. private function getResponse($index)
  30769. {
  30770. if (!isset($this->jobs[$index])) {
  30771. throw new \LogicException('Invalid request id');
  30772. }
  30773. if ($this->jobs[$index]['status'] === self::STATUS_FAILED) {
  30774. throw $this->jobs[$index]['exception'];
  30775. }
  30776. if (!isset($this->jobs[$index]['response'])) {
  30777. throw new \LogicException('Response not available yet, call wait() first');
  30778. }
  30779. $resp = $this->jobs[$index]['response'];
  30780. unset($this->jobs[$index]);
  30781. return $resp;
  30782. }
  30783. public static function outputWarnings(IOInterface $io, $url, $data)
  30784. {
  30785. foreach (array('warning', 'info') as $type) {
  30786. if (empty($data[$type])) {
  30787. continue;
  30788. }
  30789. if (!empty($data[$type . '-versions'])) {
  30790. $versionParser = new VersionParser();
  30791. $constraint = $versionParser->parseConstraints($data[$type . '-versions']);
  30792. $composer = new Constraint('==', $versionParser->normalize(Composer::getVersion()));
  30793. if (!$constraint->matches($composer)) {
  30794. continue;
  30795. }
  30796. }
  30797. $io->writeError('<'.$type.'>'.ucfirst($type).' from '.$url.': '.$data[$type].'</'.$type.'>');
  30798. }
  30799. }
  30800. public static function getExceptionHints(\Exception $e)
  30801. {
  30802. if (!$e instanceof TransportException) {
  30803. return;
  30804. }
  30805. if (
  30806. false !== strpos($e->getMessage(), 'Resolving timed out')
  30807. || false !== strpos($e->getMessage(), 'Could not resolve host')
  30808. ) {
  30809. Silencer::suppress();
  30810. $testConnectivity = file_get_contents('https://8.8.8.8', false, stream_context_create(array(
  30811. 'ssl' => array('verify_peer' => false),
  30812. 'http' => array('follow_location' => false, 'ignore_errors' => true),
  30813. )));
  30814. Silencer::restore();
  30815. if (false !== $testConnectivity) {
  30816. return array(
  30817. '<error>The following exception probably indicates you have misconfigured DNS resolver(s)</error>',
  30818. );
  30819. }
  30820. return array(
  30821. '<error>The following exception probably indicates you are offline or have misconfigured DNS resolver(s)</error>',
  30822. );
  30823. }
  30824. }
  30825. private function canUseCurl(array $job)
  30826. {
  30827. if (!$this->curl) {
  30828. return false;
  30829. }
  30830. if (!preg_match('{^https?://}i', $job['request']['url'])) {
  30831. return false;
  30832. }
  30833. if (!empty($job['request']['options']['ssl']['allow_self_signed'])) {
  30834. return false;
  30835. }
  30836. return true;
  30837. }
  30838. public static function isCurlEnabled()
  30839. {
  30840. return \extension_loaded('curl') && \function_exists('curl_multi_exec') && \function_exists('curl_multi_init');
  30841. }
  30842. }
  30843. <?php
  30844. namespace Composer\Util;
  30845. use Composer\XdebugHandler\XdebugHandler;
  30846. class IniHelper
  30847. {
  30848. public static function getAll()
  30849. {
  30850. return XdebugHandler::getAllIniFiles();
  30851. }
  30852. public static function getMessage()
  30853. {
  30854. $paths = self::getAll();
  30855. if (empty($paths[0])) {
  30856. array_shift($paths);
  30857. }
  30858. $ini = array_shift($paths);
  30859. if (empty($ini)) {
  30860. return 'A php.ini file does not exist. You will have to create one.';
  30861. }
  30862. if (!empty($paths)) {
  30863. return 'Your command-line PHP is using multiple ini files. Run `php --ini` to show them.';
  30864. }
  30865. return 'The php.ini used by your command-line PHP is: '.$ini;
  30866. }
  30867. }
  30868. <?php
  30869. namespace Composer\Util;
  30870. use React\Promise\Promise;
  30871. use Symfony\Component\Console\Helper\ProgressBar;
  30872. class Loop
  30873. {
  30874. private $httpDownloader;
  30875. private $processExecutor;
  30876. private $currentPromises = array();
  30877. private $waitIndex = 0;
  30878. public function __construct(HttpDownloader $httpDownloader, ProcessExecutor $processExecutor = null)
  30879. {
  30880. $this->httpDownloader = $httpDownloader;
  30881. $this->httpDownloader->enableAsync();
  30882. $this->processExecutor = $processExecutor;
  30883. if ($this->processExecutor) {
  30884. $this->processExecutor->enableAsync();
  30885. }
  30886. }
  30887. public function getHttpDownloader()
  30888. {
  30889. return $this->httpDownloader;
  30890. }
  30891. public function getProcessExecutor()
  30892. {
  30893. return $this->processExecutor;
  30894. }
  30895. public function wait(array $promises, ProgressBar $progress = null)
  30896. {
  30897. $uncaught = null;
  30898. \React\Promise\all($promises)->then(
  30899. function () {
  30900. },
  30901. function ($e) use (&$uncaught) {
  30902. $uncaught = $e;
  30903. }
  30904. );
  30905. $waitIndex = $this->waitIndex++;
  30906. $this->currentPromises[$waitIndex] = $promises;
  30907. if ($progress) {
  30908. $totalJobs = 0;
  30909. if ($this->httpDownloader) {
  30910. $totalJobs += $this->httpDownloader->countActiveJobs();
  30911. }
  30912. if ($this->processExecutor) {
  30913. $totalJobs += $this->processExecutor->countActiveJobs();
  30914. }
  30915. $progress->start($totalJobs);
  30916. }
  30917. $lastUpdate = 0;
  30918. while (true) {
  30919. $activeJobs = 0;
  30920. if ($this->httpDownloader) {
  30921. $activeJobs += $this->httpDownloader->countActiveJobs();
  30922. }
  30923. if ($this->processExecutor) {
  30924. $activeJobs += $this->processExecutor->countActiveJobs();
  30925. }
  30926. if ($progress && microtime(true) - $lastUpdate > 0.1) {
  30927. $lastUpdate = microtime(true);
  30928. $progress->setProgress($progress->getMaxSteps() - $activeJobs);
  30929. }
  30930. if (!$activeJobs) {
  30931. break;
  30932. }
  30933. }
  30934. if ($progress) {
  30935. $progress->setProgress($progress->getMaxSteps());
  30936. }
  30937. unset($this->currentPromises[$waitIndex]);
  30938. if ($uncaught) {
  30939. throw $uncaught;
  30940. }
  30941. }
  30942. public function abortJobs()
  30943. {
  30944. foreach ($this->currentPromises as $promiseGroup) {
  30945. foreach ($promiseGroup as $promise) {
  30946. $promise->cancel();
  30947. }
  30948. }
  30949. }
  30950. }
  30951. <?php
  30952. namespace Composer\Util;
  30953. class MetadataMinifier
  30954. {
  30955. public static function expand(array $versions)
  30956. {
  30957. $expanded = array();
  30958. $expandedVersion = null;
  30959. foreach ($versions as $versionData) {
  30960. if (!$expandedVersion) {
  30961. $expandedVersion = $versionData;
  30962. $expanded[] = $expandedVersion;
  30963. continue;
  30964. }
  30965. foreach ($versionData as $key => $val) {
  30966. if ($val === '__unset') {
  30967. unset($expandedVersion[$key]);
  30968. } else {
  30969. $expandedVersion[$key] = $val;
  30970. }
  30971. }
  30972. $expanded[] = $expandedVersion;
  30973. }
  30974. return $expanded;
  30975. }
  30976. public static function minify(array $versions)
  30977. {
  30978. $minifiedVersions = array();
  30979. $lastKnownVersionData = null;
  30980. foreach ($versions as $version) {
  30981. if (!$lastKnownVersionData) {
  30982. $lastKnownVersionData = $version;
  30983. $minifiedVersions[] = $version;
  30984. continue;
  30985. }
  30986. $minifiedVersion = array();
  30987. foreach ($version as $key => $val) {
  30988. if (!isset($lastKnownVersionData[$key]) || $lastKnownVersionData[$key] !== $val) {
  30989. $minifiedVersion[$key] = $val;
  30990. $lastKnownVersionData[$key] = $val;
  30991. }
  30992. }
  30993. foreach ($lastKnownVersionData as $key => $val) {
  30994. if (!isset($version[$key])) {
  30995. $minifiedVersion[$key] = "__unset";
  30996. unset($lastKnownVersionData[$key]);
  30997. }
  30998. }
  30999. $minifiedVersions[] = $minifiedVersion;
  31000. }
  31001. return $minifiedVersions;
  31002. }
  31003. }
  31004. <?php
  31005. namespace Composer\Util;
  31006. use stdClass;
  31007. class NoProxyPattern
  31008. {
  31009. protected $hostNames = array();
  31010. protected $rules = array();
  31011. protected $noproxy;
  31012. public function __construct($pattern)
  31013. {
  31014. $this->hostNames = preg_split('{[\s,]+}', $pattern, null, PREG_SPLIT_NO_EMPTY);
  31015. $this->noproxy = empty($this->hostNames) || '*' === $this->hostNames[0];
  31016. }
  31017. public function test($url)
  31018. {
  31019. if ($this->noproxy) {
  31020. return true;
  31021. }
  31022. if (!$urlData = $this->getUrlData($url)) {
  31023. return false;
  31024. }
  31025. foreach ($this->hostNames as $index => $hostName) {
  31026. if ($this->match($index, $hostName, $urlData)) {
  31027. return true;
  31028. }
  31029. }
  31030. return false;
  31031. }
  31032. protected function getUrlData($url)
  31033. {
  31034. if (!$host = parse_url($url, PHP_URL_HOST)) {
  31035. return false;
  31036. }
  31037. $port = parse_url($url, PHP_URL_PORT);
  31038. if (empty($port)) {
  31039. switch (parse_url($url, PHP_URL_SCHEME)) {
  31040. case 'http':
  31041. $port = 80;
  31042. break;
  31043. case 'https':
  31044. $port = 443;
  31045. break;
  31046. }
  31047. }
  31048. $hostName = $host . ($port ? ':' . $port : '');
  31049. list($host, $port, $err) = $this->splitHostPort($hostName);
  31050. if ($err || !$this->ipCheckData($host, $ipdata)) {
  31051. return false;
  31052. }
  31053. return $this->makeData($host, $port, $ipdata);
  31054. }
  31055. protected function match($index, $hostName, $url)
  31056. {
  31057. if (!$rule = $this->getRule($index, $hostName)) {
  31058. return false;
  31059. }
  31060. if ($rule->ipdata) {
  31061. if (!$url->ipdata) {
  31062. return false;
  31063. }
  31064. if ($rule->ipdata->netmask) {
  31065. return $this->matchRange($rule->ipdata, $url->ipdata);
  31066. }
  31067. $match = $rule->ipdata->ip === $url->ipdata->ip;
  31068. } else {
  31069. $haystack = substr($url->name, -strlen($rule->name));
  31070. $match = stripos($haystack, $rule->name) === 0;
  31071. }
  31072. if ($match && $rule->port) {
  31073. $match = $rule->port === $url->port;
  31074. }
  31075. return $match;
  31076. }
  31077. protected function matchRange(stdClass $network, stdClass $target)
  31078. {
  31079. $net = unpack('C*', $network->ip);
  31080. $mask = unpack('C*', $network->netmask);
  31081. $ip = unpack('C*', $target->ip);
  31082. for ($i = 1; $i < 17; ++$i) {
  31083. if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
  31084. return false;
  31085. }
  31086. }
  31087. return true;
  31088. }
  31089. private function getRule($index, $hostName)
  31090. {
  31091. if (array_key_exists($index, $this->rules)) {
  31092. return $this->rules[$index];
  31093. }
  31094. $this->rules[$index] = null;
  31095. list($host, $port, $err) = $this->splitHostPort($hostName);
  31096. if ($err || !$this->ipCheckData($host, $ipdata, true)) {
  31097. return null;
  31098. }
  31099. $this->rules[$index] = $this->makeData($host, $port, $ipdata);
  31100. return $this->rules[$index];
  31101. }
  31102. private function ipCheckData($host, &$ipdata, $allowPrefix = false)
  31103. {
  31104. $ipdata = null;
  31105. $netmask = null;
  31106. $prefix = null;
  31107. $modified = false;
  31108. if (strpos($host, '/') !== false) {
  31109. list($host, $prefix) = explode('/', $host);
  31110. if (!$allowPrefix || !$this->validateInt($prefix, 0, 128)) {
  31111. return false;
  31112. }
  31113. $prefix = (int) $prefix;
  31114. $modified = true;
  31115. }
  31116. if (!filter_var($host, FILTER_VALIDATE_IP)) {
  31117. return !$modified;
  31118. }
  31119. list($ip, $size) = $this->ipGetAddr($host);
  31120. if ($prefix !== null) {
  31121. if ($prefix > $size * 8) {
  31122. return false;
  31123. }
  31124. list($ip, $netmask) = $this->ipGetNetwork($ip, $size, $prefix);
  31125. }
  31126. $ipdata = $this->makeIpData($ip, $size, $netmask);
  31127. return true;
  31128. }
  31129. private function ipGetAddr($host)
  31130. {
  31131. $ip = inet_pton($host);
  31132. $size = strlen($ip);
  31133. $mapped = $this->ipMapTo6($ip, $size);
  31134. return array($mapped, $size);
  31135. }
  31136. private function ipGetMask($prefix, $size)
  31137. {
  31138. $mask = '';
  31139. if ($ones = floor($prefix / 8)) {
  31140. $mask = str_repeat(chr(255), $ones);
  31141. }
  31142. if ($remainder = $prefix % 8) {
  31143. $mask .= chr(0xff ^ (0xff >> $remainder));
  31144. }
  31145. $mask = str_pad($mask, $size, chr(0));
  31146. return $this->ipMapTo6($mask, $size);
  31147. }
  31148. private function ipGetNetwork($rangeIp, $size, $prefix)
  31149. {
  31150. $netmask = $this->ipGetMask($prefix, $size);
  31151. $mask = unpack('C*', $netmask);
  31152. $ip = unpack('C*', $rangeIp);
  31153. $net = '';
  31154. for ($i = 1; $i < 17; ++$i) {
  31155. $net .= chr($ip[$i] & $mask[$i]);
  31156. }
  31157. return array($net, $netmask);
  31158. }
  31159. private function ipMapTo6($binary, $size)
  31160. {
  31161. if ($size === 4) {
  31162. $prefix = str_repeat(chr(0), 10) . str_repeat(chr(255), 2);
  31163. $binary = $prefix . $binary;
  31164. }
  31165. return $binary;
  31166. }
  31167. private function makeData($host, $port, $ipdata)
  31168. {
  31169. return (object) array(
  31170. 'host' => $host,
  31171. 'name' => '.' . ltrim($host, '.'),
  31172. 'port' => $port,
  31173. 'ipdata' => $ipdata,
  31174. );
  31175. }
  31176. private function makeIpData($ip, $size, $netmask)
  31177. {
  31178. return (object) array(
  31179. 'ip' => $ip,
  31180. 'size' => $size,
  31181. 'netmask' => $netmask,
  31182. );
  31183. }
  31184. private function splitHostPort($hostName)
  31185. {
  31186. $error = array('', '', true);
  31187. $port = 0;
  31188. $ip6 = '';
  31189. if ($hostName[0] === '[') {
  31190. $index = strpos($hostName, ']');
  31191. if (false === $index || $index < 3) {
  31192. return $error;
  31193. }
  31194. $ip6 = substr($hostName, 1, $index - 1);
  31195. $hostName = substr($hostName, $index + 1);
  31196. if (strpbrk($hostName, '[]') !== false || substr_count($hostName, ':') > 1) {
  31197. return $error;
  31198. }
  31199. }
  31200. if (substr_count($hostName, ':') === 1) {
  31201. $index = strpos($hostName, ':');
  31202. $port = substr($hostName, $index + 1);
  31203. $hostName = substr($hostName, 0, $index);
  31204. if (!$this->validateInt($port, 1, 65535)) {
  31205. return $error;
  31206. }
  31207. $port = (int) $port;
  31208. }
  31209. $host = $ip6 . $hostName;
  31210. return array($host, $port, false);
  31211. }
  31212. private function validateInt($int, $min, $max)
  31213. {
  31214. $options = array(
  31215. 'options' => array(
  31216. 'min_range' => $min,
  31217. 'max_range' => $max,
  31218. ),
  31219. );
  31220. return false !== filter_var($int, FILTER_VALIDATE_INT, $options);
  31221. }
  31222. }
  31223. <?php
  31224. namespace Composer\Util;
  31225. use Composer\Package\Link;
  31226. use Composer\Package\PackageInterface;
  31227. class PackageSorter
  31228. {
  31229. public static function sortPackages(array $packages)
  31230. {
  31231. $usageList = array();
  31232. foreach ($packages as $package) {
  31233. foreach (array_merge($package->getRequires(), $package->getDevRequires()) as $link) {
  31234. $target = $link->getTarget();
  31235. $usageList[$target][] = $package->getName();
  31236. }
  31237. }
  31238. $computing = array();
  31239. $computed = array();
  31240. $computeImportance = function ($name) use (&$computeImportance, &$computing, &$computed, $usageList) {
  31241. if (isset($computed[$name])) {
  31242. return $computed[$name];
  31243. }
  31244. if (isset($computing[$name])) {
  31245. return 0;
  31246. }
  31247. $computing[$name] = true;
  31248. $weight = 0;
  31249. if (isset($usageList[$name])) {
  31250. foreach ($usageList[$name] as $user) {
  31251. $weight -= 1 - $computeImportance($user);
  31252. }
  31253. }
  31254. unset($computing[$name]);
  31255. $computed[$name] = $weight;
  31256. return $weight;
  31257. };
  31258. $weightList = array();
  31259. foreach ($packages as $index => $package) {
  31260. $weight = $computeImportance($package->getName());
  31261. $weightList[$index] = $weight;
  31262. }
  31263. $stable_sort = function (&$array) {
  31264. static $transform, $restore;
  31265. $i = 0;
  31266. if (!$transform) {
  31267. $transform = function (&$v, $k) use (&$i) {
  31268. $v = array($v, ++$i, $k, $v);
  31269. };
  31270. $restore = function (&$v) {
  31271. $v = $v[3];
  31272. };
  31273. }
  31274. array_walk($array, $transform);
  31275. asort($array);
  31276. array_walk($array, $restore);
  31277. };
  31278. $stable_sort($weightList);
  31279. $sortedPackages = array();
  31280. foreach (array_keys($weightList) as $index) {
  31281. $sortedPackages[] = $packages[$index];
  31282. }
  31283. return $sortedPackages;
  31284. }
  31285. }
  31286. <?php
  31287. namespace Composer\Util;
  31288. use Composer\IO\IOInterface;
  31289. use Symfony\Component\Process\Process;
  31290. class Perforce
  31291. {
  31292. protected $path;
  31293. protected $p4Depot;
  31294. protected $p4Client;
  31295. protected $p4User;
  31296. protected $p4Password;
  31297. protected $p4Port;
  31298. protected $p4Stream;
  31299. protected $p4ClientSpec;
  31300. protected $p4DepotType;
  31301. protected $p4Branch;
  31302. protected $process;
  31303. protected $uniquePerforceClientName;
  31304. protected $windowsFlag;
  31305. protected $commandResult;
  31306. protected $io;
  31307. protected $filesystem;
  31308. public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows, IOInterface $io)
  31309. {
  31310. $this->windowsFlag = $isWindows;
  31311. $this->p4Port = $port;
  31312. $this->initializePath($path);
  31313. $this->process = $process;
  31314. $this->initialize($repoConfig);
  31315. $this->io = $io;
  31316. }
  31317. public static function create($repoConfig, $port, $path, ProcessExecutor $process, IOInterface $io)
  31318. {
  31319. return new Perforce($repoConfig, $port, $path, $process, Platform::isWindows(), $io);
  31320. }
  31321. public static function checkServerExists($url, ProcessExecutor $processExecutor)
  31322. {
  31323. $output = null;
  31324. return 0 === $processExecutor->execute('p4 -p ' . ProcessExecutor::escape($url) . ' info -s', $output);
  31325. }
  31326. public function initialize($repoConfig)
  31327. {
  31328. $this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
  31329. if (!$repoConfig) {
  31330. return;
  31331. }
  31332. if (isset($repoConfig['unique_perforce_client_name'])) {
  31333. $this->uniquePerforceClientName = $repoConfig['unique_perforce_client_name'];
  31334. }
  31335. if (isset($repoConfig['depot'])) {
  31336. $this->p4Depot = $repoConfig['depot'];
  31337. }
  31338. if (isset($repoConfig['branch'])) {
  31339. $this->p4Branch = $repoConfig['branch'];
  31340. }
  31341. if (isset($repoConfig['p4user'])) {
  31342. $this->p4User = $repoConfig['p4user'];
  31343. } else {
  31344. $this->p4User = $this->getP4variable('P4USER');
  31345. }
  31346. if (isset($repoConfig['p4password'])) {
  31347. $this->p4Password = $repoConfig['p4password'];
  31348. }
  31349. }
  31350. public function initializeDepotAndBranch($depot, $branch)
  31351. {
  31352. if (isset($depot)) {
  31353. $this->p4Depot = $depot;
  31354. }
  31355. if (isset($branch)) {
  31356. $this->p4Branch = $branch;
  31357. }
  31358. }
  31359. public function generateUniquePerforceClientName()
  31360. {
  31361. return gethostname() . "_" . time();
  31362. }
  31363. public function cleanupClientSpec()
  31364. {
  31365. $client = $this->getClient();
  31366. $task = 'client -d ' . ProcessExecutor::escape($client);
  31367. $useP4Client = false;
  31368. $command = $this->generateP4Command($task, $useP4Client);
  31369. $this->executeCommand($command);
  31370. $clientSpec = $this->getP4ClientSpec();
  31371. $fileSystem = $this->getFilesystem();
  31372. $fileSystem->remove($clientSpec);
  31373. }
  31374. protected function executeCommand($command)
  31375. {
  31376. $this->commandResult = '';
  31377. return $this->process->execute($command, $this->commandResult);
  31378. }
  31379. public function getClient()
  31380. {
  31381. if (!isset($this->p4Client)) {
  31382. $cleanStreamName = str_replace(array('//', '/', '@'), array('', '_', ''), $this->getStream());
  31383. $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
  31384. }
  31385. return $this->p4Client;
  31386. }
  31387. protected function getPath()
  31388. {
  31389. return $this->path;
  31390. }
  31391. public function initializePath($path)
  31392. {
  31393. $this->path = $path;
  31394. $fs = $this->getFilesystem();
  31395. $fs->ensureDirectoryExists($path);
  31396. }
  31397. protected function getPort()
  31398. {
  31399. return $this->p4Port;
  31400. }
  31401. public function setStream($stream)
  31402. {
  31403. $this->p4Stream = $stream;
  31404. $index = strrpos($stream, '/');
  31405. if ($index > 2) {
  31406. $this->p4DepotType = 'stream';
  31407. }
  31408. }
  31409. public function isStream()
  31410. {
  31411. return (strcmp($this->p4DepotType, 'stream') === 0);
  31412. }
  31413. public function getStream()
  31414. {
  31415. if (!isset($this->p4Stream)) {
  31416. if ($this->isStream()) {
  31417. $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
  31418. } else {
  31419. $this->p4Stream = '//' . $this->p4Depot;
  31420. }
  31421. }
  31422. return $this->p4Stream;
  31423. }
  31424. public function getStreamWithoutLabel($stream)
  31425. {
  31426. $index = strpos($stream, '@');
  31427. if ($index === false) {
  31428. return $stream;
  31429. }
  31430. return substr($stream, 0, $index);
  31431. }
  31432. public function getP4ClientSpec()
  31433. {
  31434. return $this->path . '/' . $this->getClient() . '.p4.spec';
  31435. }
  31436. public function getUser()
  31437. {
  31438. return $this->p4User;
  31439. }
  31440. public function setUser($user)
  31441. {
  31442. $this->p4User = $user;
  31443. }
  31444. public function queryP4User()
  31445. {
  31446. $this->getUser();
  31447. if (strlen($this->p4User) > 0) {
  31448. return;
  31449. }
  31450. $this->p4User = $this->getP4variable('P4USER');
  31451. if (strlen($this->p4User) > 0) {
  31452. return;
  31453. }
  31454. $this->p4User = $this->io->ask('Enter P4 User:');
  31455. if ($this->windowsFlag) {
  31456. $command = 'p4 set P4USER=' . $this->p4User;
  31457. } else {
  31458. $command = 'export P4USER=' . $this->p4User;
  31459. }
  31460. $this->executeCommand($command);
  31461. }
  31462. protected function getP4variable($name)
  31463. {
  31464. if ($this->windowsFlag) {
  31465. $command = 'p4 set';
  31466. $this->executeCommand($command);
  31467. $result = trim($this->commandResult);
  31468. $resArray = explode(PHP_EOL, $result);
  31469. foreach ($resArray as $line) {
  31470. $fields = explode('=', $line);
  31471. if (strcmp($name, $fields[0]) == 0) {
  31472. $index = strpos($fields[1], ' ');
  31473. if ($index === false) {
  31474. $value = $fields[1];
  31475. } else {
  31476. $value = substr($fields[1], 0, $index);
  31477. }
  31478. $value = trim($value);
  31479. return $value;
  31480. }
  31481. }
  31482. return null;
  31483. }
  31484. $command = 'echo $' . $name;
  31485. $this->executeCommand($command);
  31486. $result = trim($this->commandResult);
  31487. return $result;
  31488. }
  31489. public function queryP4Password()
  31490. {
  31491. if (isset($this->p4Password)) {
  31492. return $this->p4Password;
  31493. }
  31494. $password = $this->getP4variable('P4PASSWD');
  31495. if (strlen($password) <= 0) {
  31496. $password = $this->io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
  31497. }
  31498. $this->p4Password = $password;
  31499. return $password;
  31500. }
  31501. public function generateP4Command($command, $useClient = true)
  31502. {
  31503. $p4Command = 'p4 ';
  31504. $p4Command .= '-u ' . $this->getUser() . ' ';
  31505. if ($useClient) {
  31506. $p4Command .= '-c ' . $this->getClient() . ' ';
  31507. }
  31508. $p4Command .= '-p ' . $this->getPort() . ' ' . $command;
  31509. return $p4Command;
  31510. }
  31511. public function isLoggedIn()
  31512. {
  31513. $command = $this->generateP4Command('login -s', false);
  31514. $exitCode = $this->executeCommand($command);
  31515. if ($exitCode) {
  31516. $errorOutput = $this->process->getErrorOutput();
  31517. $index = strpos($errorOutput, $this->getUser());
  31518. if ($index === false) {
  31519. $index = strpos($errorOutput, 'p4');
  31520. if ($index === false) {
  31521. return false;
  31522. }
  31523. throw new \Exception('p4 command not found in path: ' . $errorOutput);
  31524. }
  31525. throw new \Exception('Invalid user name: ' . $this->getUser());
  31526. }
  31527. return true;
  31528. }
  31529. public function connectClient()
  31530. {
  31531. $p4CreateClientCommand = $this->generateP4Command(
  31532. 'client -i < ' . str_replace(" ", "\\ ", $this->getP4ClientSpec())
  31533. );
  31534. $this->executeCommand($p4CreateClientCommand);
  31535. }
  31536. public function syncCodeBase($sourceReference)
  31537. {
  31538. $prevDir = getcwd();
  31539. chdir($this->path);
  31540. $p4SyncCommand = $this->generateP4Command('sync -f ');
  31541. if (null !== $sourceReference) {
  31542. $p4SyncCommand .= '@' . $sourceReference;
  31543. }
  31544. $this->executeCommand($p4SyncCommand);
  31545. chdir($prevDir);
  31546. }
  31547. public function writeClientSpecToFile($spec)
  31548. {
  31549. fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
  31550. fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
  31551. fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL);
  31552. fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
  31553. fwrite($spec, 'Description:' . PHP_EOL);
  31554. fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
  31555. fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
  31556. fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
  31557. fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
  31558. fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
  31559. if ($this->isStream()) {
  31560. fwrite($spec, 'Stream:' . PHP_EOL);
  31561. fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
  31562. } else {
  31563. fwrite(
  31564. $spec,
  31565. 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/... ' . PHP_EOL
  31566. );
  31567. }
  31568. }
  31569. public function writeP4ClientSpec()
  31570. {
  31571. $clientSpec = $this->getP4ClientSpec();
  31572. $spec = fopen($clientSpec, 'w');
  31573. try {
  31574. $this->writeClientSpecToFile($spec);
  31575. } catch (\Exception $e) {
  31576. fclose($spec);
  31577. throw $e;
  31578. }
  31579. fclose($spec);
  31580. }
  31581. protected function read($pipe, $name)
  31582. {
  31583. if (feof($pipe)) {
  31584. return;
  31585. }
  31586. $line = fgets($pipe);
  31587. while ($line !== false) {
  31588. $line = fgets($pipe);
  31589. }
  31590. }
  31591. public function windowsLogin($password)
  31592. {
  31593. $command = $this->generateP4Command(' login -a');
  31594. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  31595. $process = Process::fromShellCommandline($command, null, null, $password);
  31596. } else {
  31597. $process = new Process($command, null, null, $password);
  31598. }
  31599. return $process->run();
  31600. }
  31601. public function p4Login()
  31602. {
  31603. $this->queryP4User();
  31604. if (!$this->isLoggedIn()) {
  31605. $password = $this->queryP4Password();
  31606. if ($this->windowsFlag) {
  31607. $this->windowsLogin($password);
  31608. } else {
  31609. $command = 'echo ' . ProcessExecutor::escape($password) . ' | ' . $this->generateP4Command(' login -a', false);
  31610. $exitCode = $this->executeCommand($command);
  31611. if ($exitCode) {
  31612. throw new \Exception("Error logging in:" . $this->process->getErrorOutput());
  31613. }
  31614. }
  31615. }
  31616. }
  31617. public function getComposerInformation($identifier)
  31618. {
  31619. $composerFileContent = $this->getFileContent('composer.json', $identifier);
  31620. if (!$composerFileContent) {
  31621. return;
  31622. }
  31623. return json_decode($composerFileContent, true);
  31624. }
  31625. public function getFileContent($file, $identifier)
  31626. {
  31627. $path = $this->getFilePath($file, $identifier);
  31628. $command = $this->generateP4Command(' print ' . ProcessExecutor::escape($path));
  31629. $this->executeCommand($command);
  31630. $result = $this->commandResult;
  31631. if (!trim($result)) {
  31632. return null;
  31633. }
  31634. return $result;
  31635. }
  31636. public function getFilePath($file, $identifier)
  31637. {
  31638. $index = strpos($identifier, '@');
  31639. if ($index === false) {
  31640. return $identifier. '/' . $file;
  31641. }
  31642. $path = substr($identifier, 0, $index) . '/' . $file . substr($identifier, $index);
  31643. $command = $this->generateP4Command(' files ' . ProcessExecutor::escape($path), false);
  31644. $this->executeCommand($command);
  31645. $result = $this->commandResult;
  31646. $index2 = strpos($result, 'no such file(s).');
  31647. if ($index2 === false) {
  31648. $index3 = strpos($result, 'change');
  31649. if ($index3 !== false) {
  31650. $phrase = trim(substr($result, $index3));
  31651. $fields = explode(' ', $phrase);
  31652. return substr($identifier, 0, $index) . '/' . $file . '@' . $fields[1];
  31653. }
  31654. }
  31655. return null;
  31656. }
  31657. public function getBranches()
  31658. {
  31659. $possibleBranches = array();
  31660. if (!$this->isStream()) {
  31661. $possibleBranches[$this->p4Branch] = $this->getStream();
  31662. } else {
  31663. $command = $this->generateP4Command('streams '.ProcessExecutor::escape('//' . $this->p4Depot . '/...'));
  31664. $this->executeCommand($command);
  31665. $result = $this->commandResult;
  31666. $resArray = explode(PHP_EOL, $result);
  31667. foreach ($resArray as $line) {
  31668. $resBits = explode(' ', $line);
  31669. if (count($resBits) > 4) {
  31670. $branch = preg_replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
  31671. $possibleBranches[$branch] = $resBits[1];
  31672. }
  31673. }
  31674. }
  31675. $command = $this->generateP4Command('changes '. ProcessExecutor::escape($this->getStream() . '/...'), false);
  31676. $this->executeCommand($command);
  31677. $result = $this->commandResult;
  31678. $resArray = explode(PHP_EOL, $result);
  31679. $lastCommit = $resArray[0];
  31680. $lastCommitArr = explode(' ', $lastCommit);
  31681. $lastCommitNum = $lastCommitArr[1];
  31682. return array('master' => $possibleBranches[$this->p4Branch] . '@'. $lastCommitNum);
  31683. }
  31684. public function getTags()
  31685. {
  31686. $command = $this->generateP4Command('labels');
  31687. $this->executeCommand($command);
  31688. $result = $this->commandResult;
  31689. $resArray = explode(PHP_EOL, $result);
  31690. $tags = array();
  31691. foreach ($resArray as $line) {
  31692. if (strpos($line, 'Label') !== false) {
  31693. $fields = explode(' ', $line);
  31694. $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
  31695. }
  31696. }
  31697. return $tags;
  31698. }
  31699. public function checkStream()
  31700. {
  31701. $command = $this->generateP4Command('depots', false);
  31702. $this->executeCommand($command);
  31703. $result = $this->commandResult;
  31704. $resArray = explode(PHP_EOL, $result);
  31705. foreach ($resArray as $line) {
  31706. if (strpos($line, 'Depot') !== false) {
  31707. $fields = explode(' ', $line);
  31708. if (strcmp($this->p4Depot, $fields[1]) === 0) {
  31709. $this->p4DepotType = $fields[3];
  31710. return $this->isStream();
  31711. }
  31712. }
  31713. }
  31714. return false;
  31715. }
  31716. protected function getChangeList($reference)
  31717. {
  31718. $index = strpos($reference, '@');
  31719. if ($index === false) {
  31720. return null;
  31721. }
  31722. $label = substr($reference, $index);
  31723. $command = $this->generateP4Command(' changes -m1 ' . ProcessExecutor::escape($label));
  31724. $this->executeCommand($command);
  31725. $changes = $this->commandResult;
  31726. if (strpos($changes, 'Change') !== 0) {
  31727. return null;
  31728. }
  31729. $fields = explode(' ', $changes);
  31730. return $fields[1];
  31731. }
  31732. public function getCommitLogs($fromReference, $toReference)
  31733. {
  31734. $fromChangeList = $this->getChangeList($fromReference);
  31735. if ($fromChangeList === null) {
  31736. return null;
  31737. }
  31738. $toChangeList = $this->getChangeList($toReference);
  31739. if ($toChangeList === null) {
  31740. return null;
  31741. }
  31742. $index = strpos($fromReference, '@');
  31743. $main = substr($fromReference, 0, $index) . '/...';
  31744. $command = $this->generateP4Command('filelog ' . ProcessExecutor::escape($main . '@' . $fromChangeList. ',' . $toChangeList));
  31745. $this->executeCommand($command);
  31746. return $this->commandResult;
  31747. }
  31748. public function getFilesystem()
  31749. {
  31750. if (empty($this->filesystem)) {
  31751. $this->filesystem = new Filesystem($this->process);
  31752. }
  31753. return $this->filesystem;
  31754. }
  31755. public function setFilesystem(Filesystem $fs)
  31756. {
  31757. $this->filesystem = $fs;
  31758. }
  31759. }
  31760. <?php
  31761. namespace Composer\Util;
  31762. class Platform
  31763. {
  31764. public static function expandPath($path)
  31765. {
  31766. if (preg_match('#^~[\\/]#', $path)) {
  31767. return self::getUserDirectory() . substr($path, 1);
  31768. }
  31769. return preg_replace_callback('#^(\$|(?P<percent>%))(?P<var>\w++)(?(percent)%)(?P<path>.*)#', function ($matches) {
  31770. if (Platform::isWindows() && $matches['var'] == 'HOME') {
  31771. return (getenv('HOME') ?: getenv('USERPROFILE')) . $matches['path'];
  31772. }
  31773. return getenv($matches['var']) . $matches['path'];
  31774. }, $path);
  31775. }
  31776. public static function getUserDirectory()
  31777. {
  31778. if (false !== ($home = getenv('HOME'))) {
  31779. return $home;
  31780. }
  31781. if (self::isWindows() && false !== ($home = getenv('USERPROFILE'))) {
  31782. return $home;
  31783. }
  31784. if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
  31785. $info = posix_getpwuid(posix_getuid());
  31786. return $info['dir'];
  31787. }
  31788. throw new \RuntimeException('Could not determine user directory');
  31789. }
  31790. public static function isWindows()
  31791. {
  31792. return \defined('PHP_WINDOWS_VERSION_BUILD');
  31793. }
  31794. public static function strlen($str)
  31795. {
  31796. static $useMbString = null;
  31797. if (null === $useMbString) {
  31798. $useMbString = \function_exists('mb_strlen') && ini_get('mbstring.func_overload');
  31799. }
  31800. if ($useMbString) {
  31801. return mb_strlen($str, '8bit');
  31802. }
  31803. return \strlen($str);
  31804. }
  31805. public static function isTty($fd = null)
  31806. {
  31807. if ($fd === null) {
  31808. $fd = defined('STDOUT') ? STDOUT : fopen('php://stdout', 'w');
  31809. }
  31810. if (function_exists('stream_isatty')) {
  31811. return stream_isatty($fd);
  31812. }
  31813. if (function_exists('posix_isatty') && posix_isatty($fd)) {
  31814. return true;
  31815. }
  31816. $stat = @fstat($fd);
  31817. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  31818. }
  31819. }
  31820. <?php
  31821. namespace Composer\Util;
  31822. use Composer\IO\IOInterface;
  31823. use Symfony\Component\Process\Process;
  31824. use Symfony\Component\Process\ProcessUtils;
  31825. use Symfony\Component\Process\Exception\RuntimeException;
  31826. use React\Promise\Promise;
  31827. class ProcessExecutor
  31828. {
  31829. const STATUS_QUEUED = 1;
  31830. const STATUS_STARTED = 2;
  31831. const STATUS_COMPLETED = 3;
  31832. const STATUS_FAILED = 4;
  31833. const STATUS_ABORTED = 5;
  31834. protected static $timeout = 300;
  31835. protected $captureOutput;
  31836. protected $errorOutput;
  31837. protected $io;
  31838. private $jobs = array();
  31839. private $runningJobs = 0;
  31840. private $maxJobs = 10;
  31841. private $idGen = 0;
  31842. private $allowAsync = false;
  31843. public function __construct(IOInterface $io = null)
  31844. {
  31845. $this->io = $io;
  31846. }
  31847. public function execute($command, &$output = null, $cwd = null)
  31848. {
  31849. if (func_num_args() > 1) {
  31850. return $this->doExecute($command, $cwd, false, $output);
  31851. }
  31852. return $this->doExecute($command, $cwd, false);
  31853. }
  31854. public function executeTty($command, $cwd = null)
  31855. {
  31856. if (Platform::isTty()) {
  31857. return $this->doExecute($command, $cwd, true);
  31858. }
  31859. return $this->doExecute($command, $cwd, false);
  31860. }
  31861. private function doExecute($command, $cwd, $tty, &$output = null)
  31862. {
  31863. if ($this->io && $this->io->isDebug()) {
  31864. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  31865. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  31866. return '://***:***@';
  31867. }
  31868. return '://'.$m['user'].':***@';
  31869. }, $command);
  31870. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  31871. $this->io->writeError('Executing command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  31872. }
  31873. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  31874. $cwd = realpath(getcwd());
  31875. }
  31876. $this->captureOutput = func_num_args() > 3;
  31877. $this->errorOutput = null;
  31878. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  31879. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  31880. } else {
  31881. $process = new Process($command, $cwd, null, null, static::getTimeout());
  31882. }
  31883. if (!Platform::isWindows() && $tty) {
  31884. try {
  31885. $process->setTty(true);
  31886. } catch (RuntimeException $e) {
  31887. }
  31888. }
  31889. $callback = is_callable($output) ? $output : array($this, 'outputHandler');
  31890. $process->run($callback);
  31891. if ($this->captureOutput && !is_callable($output)) {
  31892. $output = $process->getOutput();
  31893. }
  31894. $this->errorOutput = $process->getErrorOutput();
  31895. return $process->getExitCode();
  31896. }
  31897. public function executeAsync($command, $cwd = null)
  31898. {
  31899. if (!$this->allowAsync) {
  31900. throw new \LogicException('You must use the ProcessExecutor instance which is part of a Composer\Loop instance to be able to run async processes');
  31901. }
  31902. $job = array(
  31903. 'id' => $this->idGen++,
  31904. 'status' => self::STATUS_QUEUED,
  31905. 'command' => $command,
  31906. 'cwd' => $cwd,
  31907. );
  31908. $resolver = function ($resolve, $reject) use (&$job) {
  31909. $job['status'] = ProcessExecutor::STATUS_QUEUED;
  31910. $job['resolve'] = $resolve;
  31911. $job['reject'] = $reject;
  31912. };
  31913. $self = $this;
  31914. $canceler = function () use (&$job) {
  31915. if ($job['status'] === ProcessExecutor::STATUS_QUEUED) {
  31916. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  31917. }
  31918. if ($job['status'] !== ProcessExecutor::STATUS_STARTED) {
  31919. return;
  31920. }
  31921. $job['status'] = ProcessExecutor::STATUS_ABORTED;
  31922. try {
  31923. if (defined('SIGINT')) {
  31924. $job['process']->signal(SIGINT);
  31925. }
  31926. } catch (\Exception $e) {
  31927. }
  31928. $job['process']->stop(1);
  31929. };
  31930. $promise = new Promise($resolver, $canceler);
  31931. $promise = $promise->then(function () use (&$job, $self) {
  31932. if ($job['process']->isSuccessful()) {
  31933. $job['status'] = ProcessExecutor::STATUS_COMPLETED;
  31934. } else {
  31935. $job['status'] = ProcessExecutor::STATUS_FAILED;
  31936. }
  31937. $self->markJobDone();
  31938. return $job['process'];
  31939. }, function ($e) use (&$job, $self) {
  31940. $job['status'] = ProcessExecutor::STATUS_FAILED;
  31941. $self->markJobDone();
  31942. throw $e;
  31943. });
  31944. $this->jobs[$job['id']] = &$job;
  31945. if ($this->runningJobs < $this->maxJobs) {
  31946. $this->startJob($job['id']);
  31947. }
  31948. return $promise;
  31949. }
  31950. private function startJob($id)
  31951. {
  31952. $job = &$this->jobs[$id];
  31953. if ($job['status'] !== self::STATUS_QUEUED) {
  31954. return;
  31955. }
  31956. $job['status'] = self::STATUS_STARTED;
  31957. $this->runningJobs++;
  31958. $command = $job['command'];
  31959. $cwd = $job['cwd'];
  31960. if ($this->io && $this->io->isDebug()) {
  31961. $safeCommand = preg_replace_callback('{://(?P<user>[^:/\s]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  31962. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  31963. return '://***:***@';
  31964. }
  31965. return '://'.$m['user'].':***@';
  31966. }, $command);
  31967. $safeCommand = preg_replace("{--password (.*[^\\\\]\') }", '--password \'***\' ', $safeCommand);
  31968. $this->io->writeError('Executing async command ('.($cwd ?: 'CWD').'): '.$safeCommand);
  31969. }
  31970. if (null === $cwd && Platform::isWindows() && false !== strpos($command, 'git') && getcwd()) {
  31971. $cwd = realpath(getcwd());
  31972. }
  31973. if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) {
  31974. $process = Process::fromShellCommandline($command, $cwd, null, null, static::getTimeout());
  31975. } else {
  31976. $process = new Process($command, $cwd, null, null, static::getTimeout());
  31977. }
  31978. $job['process'] = $process;
  31979. $process->start();
  31980. }
  31981. public function wait($index = null)
  31982. {
  31983. while (true) {
  31984. if (!$this->countActiveJobs($index)) {
  31985. return;
  31986. }
  31987. usleep(1000);
  31988. }
  31989. }
  31990. public function enableAsync()
  31991. {
  31992. $this->allowAsync = true;
  31993. }
  31994. public function countActiveJobs($index = null)
  31995. {
  31996. foreach ($this->jobs as $job) {
  31997. if ($job['status'] === self::STATUS_STARTED) {
  31998. if (!$job['process']->isRunning()) {
  31999. call_user_func($job['resolve'], $job['process']);
  32000. }
  32001. }
  32002. if ($this->runningJobs < $this->maxJobs) {
  32003. if ($job['status'] === self::STATUS_QUEUED) {
  32004. $this->startJob($job['id']);
  32005. }
  32006. }
  32007. }
  32008. if (null !== $index) {
  32009. return $this->jobs[$index]['status'] < self::STATUS_COMPLETED ? 1 : 0;
  32010. }
  32011. $active = 0;
  32012. foreach ($this->jobs as $job) {
  32013. if ($job['status'] < self::STATUS_COMPLETED) {
  32014. $active++;
  32015. } else {
  32016. unset($this->jobs[$job['id']]);
  32017. }
  32018. }
  32019. return $active;
  32020. }
  32021. public function markJobDone()
  32022. {
  32023. $this->runningJobs--;
  32024. }
  32025. public function splitLines($output)
  32026. {
  32027. $output = trim($output);
  32028. return ((string) $output === '') ? array() : preg_split('{\r?\n}', $output);
  32029. }
  32030. public function getErrorOutput()
  32031. {
  32032. return $this->errorOutput;
  32033. }
  32034. public function outputHandler($type, $buffer)
  32035. {
  32036. if ($this->captureOutput) {
  32037. return;
  32038. }
  32039. if (null === $this->io) {
  32040. echo $buffer;
  32041. return;
  32042. }
  32043. if (Process::ERR === $type) {
  32044. $this->io->writeErrorRaw($buffer, false);
  32045. } else {
  32046. $this->io->writeRaw($buffer, false);
  32047. }
  32048. }
  32049. public static function getTimeout()
  32050. {
  32051. return static::$timeout;
  32052. }
  32053. public static function setTimeout($timeout)
  32054. {
  32055. static::$timeout = $timeout;
  32056. }
  32057. public static function escape($argument)
  32058. {
  32059. return self::escapeArgument($argument);
  32060. }
  32061. private static function escapeArgument($argument)
  32062. {
  32063. if ('\\' === DIRECTORY_SEPARATOR) {
  32064. if ((string) $argument === '') {
  32065. return escapeshellarg($argument);
  32066. }
  32067. $escapedArgument = '';
  32068. $quote = false;
  32069. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  32070. if ('"' === $part) {
  32071. $escapedArgument .= '\\"';
  32072. } elseif (self::isSurroundedBy($part, '%')) {
  32073. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  32074. } else {
  32075. if ('\\' === substr($part, -1)) {
  32076. $part .= '\\';
  32077. }
  32078. $quote = true;
  32079. $escapedArgument .= $part;
  32080. }
  32081. }
  32082. if ($quote) {
  32083. $escapedArgument = '"'.$escapedArgument.'"';
  32084. }
  32085. return $escapedArgument;
  32086. }
  32087. return "'".str_replace("'", "'\\''", $argument)."'";
  32088. }
  32089. private static function isSurroundedBy($arg, $char)
  32090. {
  32091. return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
  32092. }
  32093. }
  32094. <?php
  32095. namespace Composer\Util;
  32096. use Composer\Config;
  32097. use Composer\Downloader\MaxFileSizeExceededException;
  32098. use Composer\IO\IOInterface;
  32099. use Composer\Downloader\TransportException;
  32100. use Composer\CaBundle\CaBundle;
  32101. use Composer\Util\Http\Response;
  32102. use Composer\Util\Http\ProxyManager;
  32103. class RemoteFilesystem
  32104. {
  32105. private $io;
  32106. private $config;
  32107. private $scheme;
  32108. private $bytesMax;
  32109. private $originUrl;
  32110. private $fileUrl;
  32111. private $fileName;
  32112. private $retry;
  32113. private $progress;
  32114. private $lastProgress;
  32115. private $options = array();
  32116. private $peerCertificateMap = array();
  32117. private $disableTls = false;
  32118. private $lastHeaders;
  32119. private $storeAuth;
  32120. private $authHelper;
  32121. private $degradedMode = false;
  32122. private $redirects;
  32123. private $maxRedirects = 20;
  32124. private $proxyManager;
  32125. public function __construct(IOInterface $io, Config $config, array $options = array(), $disableTls = false, AuthHelper $authHelper = null)
  32126. {
  32127. $this->io = $io;
  32128. if ($disableTls === false) {
  32129. $this->options = StreamContextFactory::getTlsDefaults($options, $io);
  32130. } else {
  32131. $this->disableTls = true;
  32132. }
  32133. $this->options = array_replace_recursive($this->options, $options);
  32134. $this->config = $config;
  32135. $this->authHelper = isset($authHelper) ? $authHelper : new AuthHelper($io, $config);
  32136. $this->proxyManager = ProxyManager::getInstance();
  32137. }
  32138. public function copy($originUrl, $fileUrl, $fileName, $progress = true, $options = array())
  32139. {
  32140. return $this->get($originUrl, $fileUrl, $options, $fileName, $progress);
  32141. }
  32142. public function getContents($originUrl, $fileUrl, $progress = true, $options = array())
  32143. {
  32144. return $this->get($originUrl, $fileUrl, $options, null, $progress);
  32145. }
  32146. public function getOptions()
  32147. {
  32148. return $this->options;
  32149. }
  32150. public function setOptions(array $options)
  32151. {
  32152. $this->options = array_replace_recursive($this->options, $options);
  32153. }
  32154. public function isTlsDisabled()
  32155. {
  32156. return $this->disableTls === true;
  32157. }
  32158. public function getLastHeaders()
  32159. {
  32160. return $this->lastHeaders;
  32161. }
  32162. public static function findStatusCode(array $headers)
  32163. {
  32164. $value = null;
  32165. foreach ($headers as $header) {
  32166. if (preg_match('{^HTTP/\S+ (\d+)}i', $header, $match)) {
  32167. $value = (int) $match[1];
  32168. }
  32169. }
  32170. return $value;
  32171. }
  32172. public function findStatusMessage(array $headers)
  32173. {
  32174. $value = null;
  32175. foreach ($headers as $header) {
  32176. if (preg_match('{^HTTP/\S+ \d+}i', $header)) {
  32177. $value = $header;
  32178. }
  32179. }
  32180. return $value;
  32181. }
  32182. protected function get($originUrl, $fileUrl, $additionalOptions = array(), $fileName = null, $progress = true)
  32183. {
  32184. $this->scheme = parse_url($fileUrl, PHP_URL_SCHEME);
  32185. $this->bytesMax = 0;
  32186. $this->originUrl = $originUrl;
  32187. $this->fileUrl = $fileUrl;
  32188. $this->fileName = $fileName;
  32189. $this->progress = $progress;
  32190. $this->lastProgress = null;
  32191. $retryAuthFailure = true;
  32192. $this->lastHeaders = array();
  32193. $this->redirects = 1;
  32194. $tempAdditionalOptions = $additionalOptions;
  32195. if (isset($tempAdditionalOptions['retry-auth-failure'])) {
  32196. $retryAuthFailure = (bool) $tempAdditionalOptions['retry-auth-failure'];
  32197. unset($tempAdditionalOptions['retry-auth-failure']);
  32198. }
  32199. $isRedirect = false;
  32200. if (isset($tempAdditionalOptions['redirects'])) {
  32201. $this->redirects = $tempAdditionalOptions['redirects'];
  32202. $isRedirect = true;
  32203. unset($tempAdditionalOptions['redirects']);
  32204. }
  32205. $options = $this->getOptionsForUrl($originUrl, $tempAdditionalOptions);
  32206. unset($tempAdditionalOptions);
  32207. $origFileUrl = $fileUrl;
  32208. if (isset($options['gitlab-token'])) {
  32209. $fileUrl .= (false === strpos($fileUrl, '?') ? '?' : '&') . 'access_token='.$options['gitlab-token'];
  32210. unset($options['gitlab-token']);
  32211. }
  32212. if (isset($options['http'])) {
  32213. $options['http']['ignore_errors'] = true;
  32214. }
  32215. if ($this->degradedMode && strpos($fileUrl, 'http://repo.packagist.org/') === 0) {
  32216. $fileUrl = 'http://' . gethostbyname('repo.packagist.org') . substr($fileUrl, 20);
  32217. $degradedPackagist = true;
  32218. }
  32219. $maxFileSize = null;
  32220. if (isset($options['max_file_size'])) {
  32221. $maxFileSize = $options['max_file_size'];
  32222. unset($options['max_file_size']);
  32223. }
  32224. $ctx = StreamContextFactory::getContext($fileUrl, $options, array('notification' => array($this, 'callbackGet')));
  32225. $proxy = ProxyManager::getInstance()->getProxyForRequest($fileUrl);
  32226. $usingProxy = $proxy->getFormattedUrl(' using proxy (%s)');
  32227. $this->io->writeError((strpos($origFileUrl, 'http') === 0 ? 'Downloading ' : 'Reading ') . Url::sanitize($origFileUrl) . $usingProxy, true, IOInterface::DEBUG);
  32228. unset($origFileUrl, $proxy, $usingProxy);
  32229. if ((!preg_match('{^http://(repo\.)?packagist\.org/p/}', $fileUrl) || (false === strpos($fileUrl, '$') && false === strpos($fileUrl, '%24'))) && empty($degradedPackagist) && $this->config) {
  32230. $this->config->prohibitUrlByConfig($fileUrl, $this->io);
  32231. }
  32232. if ($this->progress && !$isRedirect) {
  32233. $this->io->writeError("Downloading (<comment>connecting...</comment>)", false);
  32234. }
  32235. $errorMessage = '';
  32236. $errorCode = 0;
  32237. $result = false;
  32238. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  32239. if ($errorMessage) {
  32240. $errorMessage .= "\n";
  32241. }
  32242. $errorMessage .= preg_replace('{^file_get_contents\(.*?\): }', '', $msg);
  32243. return true;
  32244. });
  32245. $http_response_header = array();
  32246. try {
  32247. $result = $this->getRemoteContents($originUrl, $fileUrl, $ctx, $http_response_header, $maxFileSize);
  32248. if (!empty($http_response_header[0])) {
  32249. $statusCode = self::findStatusCode($http_response_header);
  32250. if ($statusCode >= 400 && Response::findHeaderValue($http_response_header, 'content-type') === 'application/json') {
  32251. HttpDownloader::outputWarnings($this->io, $originUrl, json_decode($result, true));
  32252. }
  32253. if (in_array($statusCode, array(401, 403)) && $retryAuthFailure) {
  32254. $this->promptAuthAndRetry($statusCode, $this->findStatusMessage($http_response_header), $http_response_header);
  32255. }
  32256. }
  32257. $contentLength = !empty($http_response_header[0]) ? Response::findHeaderValue($http_response_header, 'content-length') : null;
  32258. if ($contentLength && Platform::strlen($result) < $contentLength) {
  32259. $e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
  32260. $e->setHeaders($http_response_header);
  32261. $e->setStatusCode(self::findStatusCode($http_response_header));
  32262. try {
  32263. $e->setResponse($this->decodeResult($result, $http_response_header));
  32264. } catch (\Exception $e) {
  32265. $e->setResponse($result);
  32266. }
  32267. $this->io->writeError('Content-Length mismatch, received '.Platform::strlen($result).' out of '.$contentLength.' bytes: (' . base64_encode($result).')', true, IOInterface::DEBUG);
  32268. throw $e;
  32269. }
  32270. if (PHP_VERSION_ID < 50600 && !empty($options['ssl']['peer_fingerprint'])) {
  32271. $params = stream_context_get_params($ctx);
  32272. $expectedPeerFingerprint = $options['ssl']['peer_fingerprint'];
  32273. $peerFingerprint = TlsHelper::getCertificateFingerprint($params['options']['ssl']['peer_certificate']);
  32274. if ($expectedPeerFingerprint !== $peerFingerprint) {
  32275. throw new TransportException('Peer fingerprint did not match');
  32276. }
  32277. }
  32278. } catch (\Exception $e) {
  32279. if ($e instanceof TransportException && !empty($http_response_header[0])) {
  32280. $e->setHeaders($http_response_header);
  32281. $e->setStatusCode(self::findStatusCode($http_response_header));
  32282. }
  32283. if ($e instanceof TransportException && $result !== false) {
  32284. $e->setResponse($this->decodeResult($result, $http_response_header));
  32285. }
  32286. $result = false;
  32287. }
  32288. if ($errorMessage && !filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) {
  32289. $errorMessage = 'allow_url_fopen must be enabled in php.ini ('.$errorMessage.')';
  32290. }
  32291. restore_error_handler();
  32292. if (isset($e) && !$this->retry) {
  32293. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  32294. $this->degradedMode = true;
  32295. $this->io->writeError('');
  32296. $this->io->writeError(array(
  32297. '<error>'.$e->getMessage().'</error>',
  32298. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32299. ));
  32300. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32301. }
  32302. throw $e;
  32303. }
  32304. $statusCode = null;
  32305. $contentType = null;
  32306. $locationHeader = null;
  32307. if (!empty($http_response_header[0])) {
  32308. $statusCode = self::findStatusCode($http_response_header);
  32309. $contentType = Response::findHeaderValue($http_response_header, 'content-type');
  32310. $locationHeader = Response::findHeaderValue($http_response_header, 'location');
  32311. }
  32312. if ($originUrl === 'bitbucket.org'
  32313. && !$this->authHelper->isPublicBitBucketDownload($fileUrl)
  32314. && substr($fileUrl, -4) === '.zip'
  32315. && (!$locationHeader || substr(parse_url($locationHeader, PHP_URL_PATH), -4) !== '.zip')
  32316. && $contentType && preg_match('{^text/html\b}i', $contentType)
  32317. ) {
  32318. $result = false;
  32319. if ($retryAuthFailure) {
  32320. $this->promptAuthAndRetry(401);
  32321. }
  32322. }
  32323. if ($statusCode === 404
  32324. && $this->config && in_array($originUrl, $this->config->get('gitlab-domains'), true)
  32325. && false !== strpos($fileUrl, 'archive.zip')
  32326. ) {
  32327. $result = false;
  32328. if ($retryAuthFailure) {
  32329. $this->promptAuthAndRetry(401);
  32330. }
  32331. }
  32332. $hasFollowedRedirect = false;
  32333. if ($statusCode >= 300 && $statusCode <= 399 && $statusCode !== 304 && $this->redirects < $this->maxRedirects) {
  32334. $hasFollowedRedirect = true;
  32335. $result = $this->handleRedirect($http_response_header, $additionalOptions, $result);
  32336. }
  32337. if ($statusCode && $statusCode >= 400 && $statusCode <= 599) {
  32338. if (!$this->retry) {
  32339. if ($this->progress && !$isRedirect) {
  32340. $this->io->overwriteError("Downloading (<error>failed</error>)", false);
  32341. }
  32342. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded ('.$http_response_header[0].')', $statusCode);
  32343. $e->setHeaders($http_response_header);
  32344. $e->setResponse($this->decodeResult($result, $http_response_header));
  32345. $e->setStatusCode($statusCode);
  32346. throw $e;
  32347. }
  32348. $result = false;
  32349. }
  32350. if ($this->progress && !$this->retry && !$isRedirect) {
  32351. $this->io->overwriteError("Downloading (".($result === false ? '<error>failed</error>' : '<comment>100%</comment>').")", false);
  32352. }
  32353. if ($result && extension_loaded('zlib') && strpos($fileUrl, 'http') === 0 && !$hasFollowedRedirect) {
  32354. try {
  32355. $result = $this->decodeResult($result, $http_response_header);
  32356. } catch (\Exception $e) {
  32357. if ($this->degradedMode) {
  32358. throw $e;
  32359. }
  32360. $this->degradedMode = true;
  32361. $this->io->writeError(array(
  32362. '',
  32363. '<error>Failed to decode response: '.$e->getMessage().'</error>',
  32364. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32365. ));
  32366. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32367. }
  32368. }
  32369. if (false !== $result && null !== $fileName && !$isRedirect) {
  32370. if ('' === $result) {
  32371. throw new TransportException('"'.$this->fileUrl.'" appears broken, and returned an empty 200 response');
  32372. }
  32373. $errorMessage = '';
  32374. set_error_handler(function ($code, $msg) use (&$errorMessage) {
  32375. if ($errorMessage) {
  32376. $errorMessage .= "\n";
  32377. }
  32378. $errorMessage .= preg_replace('{^file_put_contents\(.*?\): }', '', $msg);
  32379. return true;
  32380. });
  32381. $result = (bool) file_put_contents($fileName, $result);
  32382. restore_error_handler();
  32383. if (false === $result) {
  32384. throw new TransportException('The "'.$this->fileUrl.'" file could not be written to '.$fileName.': '.$errorMessage);
  32385. }
  32386. }
  32387. if (false === $result && false !== strpos($errorMessage, 'Peer certificate') && PHP_VERSION_ID < 50600) {
  32388. if (CaBundle::isOpensslParseSafe()) {
  32389. $certDetails = $this->getCertificateCnAndFp($this->fileUrl, $options);
  32390. if ($certDetails) {
  32391. $this->peerCertificateMap[$this->getUrlAuthority($this->fileUrl)] = $certDetails;
  32392. $this->retry = true;
  32393. }
  32394. } else {
  32395. $this->io->writeError('');
  32396. $this->io->writeError(sprintf(
  32397. '<error>Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.</error>',
  32398. PHP_VERSION
  32399. ));
  32400. }
  32401. }
  32402. if ($this->retry) {
  32403. $this->retry = false;
  32404. $result = $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32405. if ($this->storeAuth && $this->config) {
  32406. $this->authHelper->storeAuth($this->originUrl, $this->storeAuth);
  32407. $this->storeAuth = false;
  32408. }
  32409. return $result;
  32410. }
  32411. if (false === $result) {
  32412. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded: '.$errorMessage, $errorCode);
  32413. if (!empty($http_response_header[0])) {
  32414. $e->setHeaders($http_response_header);
  32415. }
  32416. if (!$this->degradedMode && false !== strpos($e->getMessage(), 'Operation timed out')) {
  32417. $this->degradedMode = true;
  32418. $this->io->writeError('');
  32419. $this->io->writeError(array(
  32420. '<error>'.$e->getMessage().'</error>',
  32421. '<error>Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info</error>',
  32422. ));
  32423. return $this->get($this->originUrl, $this->fileUrl, $additionalOptions, $this->fileName, $this->progress);
  32424. }
  32425. throw $e;
  32426. }
  32427. if (!empty($http_response_header[0])) {
  32428. $this->lastHeaders = $http_response_header;
  32429. }
  32430. return $result;
  32431. }
  32432. protected function getRemoteContents($originUrl, $fileUrl, $context, array &$responseHeaders = null, $maxFileSize = null)
  32433. {
  32434. $result = false;
  32435. try {
  32436. $e = null;
  32437. if ($maxFileSize !== null) {
  32438. $result = file_get_contents($fileUrl, false, $context, 0, $maxFileSize);
  32439. } else {
  32440. $result = file_get_contents($fileUrl, false, $context);
  32441. }
  32442. } catch (\Throwable $e) {
  32443. } catch (\Exception $e) {
  32444. }
  32445. if ($maxFileSize !== null && Platform::strlen($result) >= $maxFileSize) {
  32446. throw new MaxFileSizeExceededException('Maximum allowed download size reached. Downloaded ' . Platform::strlen($result) . ' of allowed ' . $maxFileSize . ' bytes');
  32447. }
  32448. $responseHeaders = isset($http_response_header) ? $http_response_header : array();
  32449. if (null !== $e) {
  32450. throw $e;
  32451. }
  32452. return $result;
  32453. }
  32454. protected function callbackGet($notificationCode, $severity, $message, $messageCode, $bytesTransferred, $bytesMax)
  32455. {
  32456. switch ($notificationCode) {
  32457. case STREAM_NOTIFY_FAILURE:
  32458. if (400 === $messageCode) {
  32459. throw new TransportException("The '" . $this->fileUrl . "' URL could not be accessed: " . $message, $messageCode);
  32460. }
  32461. break;
  32462. case STREAM_NOTIFY_FILE_SIZE_IS:
  32463. $this->bytesMax = $bytesMax;
  32464. break;
  32465. case STREAM_NOTIFY_PROGRESS:
  32466. if ($this->bytesMax > 0 && $this->progress) {
  32467. $progression = min(100, round($bytesTransferred / $this->bytesMax * 100));
  32468. if ((0 === $progression % 5) && 100 !== $progression && $progression !== $this->lastProgress) {
  32469. $this->lastProgress = $progression;
  32470. $this->io->overwriteError("Downloading (<comment>$progression%</comment>)", false);
  32471. }
  32472. }
  32473. break;
  32474. default:
  32475. break;
  32476. }
  32477. }
  32478. protected function promptAuthAndRetry($httpStatus, $reason = null, $headers = array())
  32479. {
  32480. $result = $this->authHelper->promptAuthIfNeeded($this->fileUrl, $this->originUrl, $httpStatus, $reason, $headers);
  32481. $this->storeAuth = $result['storeAuth'];
  32482. $this->retry = $result['retry'];
  32483. if ($this->retry) {
  32484. throw new TransportException('RETRY');
  32485. }
  32486. }
  32487. protected function getOptionsForUrl($originUrl, $additionalOptions)
  32488. {
  32489. $tlsOptions = array();
  32490. if ($this->disableTls === false && PHP_VERSION_ID < 50600 && !stream_is_local($this->fileUrl)) {
  32491. $host = parse_url($this->fileUrl, PHP_URL_HOST);
  32492. if (PHP_VERSION_ID < 50304) {
  32493. if ($host === 'github.com' || $host === 'api.github.com') {
  32494. $host = '*.github.com';
  32495. }
  32496. }
  32497. $tlsOptions['ssl']['CN_match'] = $host;
  32498. $tlsOptions['ssl']['SNI_server_name'] = $host;
  32499. $urlAuthority = $this->getUrlAuthority($this->fileUrl);
  32500. if (isset($this->peerCertificateMap[$urlAuthority])) {
  32501. $certMap = $this->peerCertificateMap[$urlAuthority];
  32502. $this->io->writeError('', true, IOInterface::DEBUG);
  32503. $this->io->writeError(sprintf(
  32504. 'Using <info>%s</info> as CN for subjectAltName enabled host <info>%s</info>',
  32505. $certMap['cn'],
  32506. $urlAuthority
  32507. ), true, IOInterface::DEBUG);
  32508. $tlsOptions['ssl']['CN_match'] = $certMap['cn'];
  32509. $tlsOptions['ssl']['peer_fingerprint'] = $certMap['fp'];
  32510. } elseif (!CaBundle::isOpensslParseSafe() && $host === 'repo.packagist.org') {
  32511. $tlsOptions['ssl']['CN_match'] = 'packagist.org';
  32512. }
  32513. }
  32514. $headers = array();
  32515. if (extension_loaded('zlib')) {
  32516. $headers[] = 'Accept-Encoding: gzip';
  32517. }
  32518. $options = array_replace_recursive($this->options, $tlsOptions, $additionalOptions);
  32519. if (!$this->degradedMode) {
  32520. $options['http']['protocol_version'] = 1.1;
  32521. $headers[] = 'Connection: close';
  32522. }
  32523. $headers = $this->authHelper->addAuthenticationHeader($headers, $originUrl, $this->fileUrl);
  32524. $options['http']['follow_location'] = 0;
  32525. if (isset($options['http']['header']) && !is_array($options['http']['header'])) {
  32526. $options['http']['header'] = explode("\r\n", trim($options['http']['header'], "\r\n"));
  32527. }
  32528. foreach ($headers as $header) {
  32529. $options['http']['header'][] = $header;
  32530. }
  32531. return $options;
  32532. }
  32533. private function handleRedirect(array $http_response_header, array $additionalOptions, $result)
  32534. {
  32535. if ($locationHeader = Response::findHeaderValue($http_response_header, 'location')) {
  32536. if (parse_url($locationHeader, PHP_URL_SCHEME)) {
  32537. $targetUrl = $locationHeader;
  32538. } elseif (parse_url($locationHeader, PHP_URL_HOST)) {
  32539. $targetUrl = $this->scheme.':'.$locationHeader;
  32540. } elseif ('/' === $locationHeader[0]) {
  32541. $urlHost = parse_url($this->fileUrl, PHP_URL_HOST);
  32542. $targetUrl = preg_replace('{^(.+(?://|@)'.preg_quote($urlHost).'(?::\d+)?)(?:[/\?].*)?$}', '\1'.$locationHeader, $this->fileUrl);
  32543. } else {
  32544. $targetUrl = preg_replace('{^(.+/)[^/?]*(?:\?.*)?$}', '\1'.$locationHeader, $this->fileUrl);
  32545. }
  32546. }
  32547. if (!empty($targetUrl)) {
  32548. $this->redirects++;
  32549. $this->io->writeError('', true, IOInterface::DEBUG);
  32550. $this->io->writeError(sprintf('Following redirect (%u) %s', $this->redirects, Url::sanitize($targetUrl)), true, IOInterface::DEBUG);
  32551. $additionalOptions['redirects'] = $this->redirects;
  32552. return $this->get(parse_url($targetUrl, PHP_URL_HOST), $targetUrl, $additionalOptions, $this->fileName, $this->progress);
  32553. }
  32554. if (!$this->retry) {
  32555. $e = new TransportException('The "'.$this->fileUrl.'" file could not be downloaded, got redirect without Location ('.$http_response_header[0].')');
  32556. $e->setHeaders($http_response_header);
  32557. $e->setResponse($this->decodeResult($result, $http_response_header));
  32558. throw $e;
  32559. }
  32560. return false;
  32561. }
  32562. private function getCertificateCnAndFp($url, $options)
  32563. {
  32564. if (PHP_VERSION_ID >= 50600) {
  32565. throw new \BadMethodCallException(sprintf(
  32566. '%s must not be used on PHP >= 5.6',
  32567. __METHOD__
  32568. ));
  32569. }
  32570. $context = StreamContextFactory::getContext($url, $options, array('options' => array(
  32571. 'ssl' => array(
  32572. 'capture_peer_cert' => true,
  32573. 'verify_peer' => false,
  32574. ), ),
  32575. ));
  32576. if (false === $handle = @fopen($url, 'rb', false, $context)) {
  32577. return;
  32578. }
  32579. fclose($handle);
  32580. $handle = null;
  32581. $params = stream_context_get_params($context);
  32582. if (!empty($params['options']['ssl']['peer_certificate'])) {
  32583. $peerCertificate = $params['options']['ssl']['peer_certificate'];
  32584. if (TlsHelper::checkCertificateHost($peerCertificate, parse_url($url, PHP_URL_HOST), $commonName)) {
  32585. return array(
  32586. 'cn' => $commonName,
  32587. 'fp' => TlsHelper::getCertificateFingerprint($peerCertificate),
  32588. );
  32589. }
  32590. }
  32591. }
  32592. private function getUrlAuthority($url)
  32593. {
  32594. $defaultPorts = array(
  32595. 'ftp' => 21,
  32596. 'http' => 80,
  32597. 'https' => 443,
  32598. 'ssh2.sftp' => 22,
  32599. 'ssh2.scp' => 22,
  32600. );
  32601. $scheme = parse_url($url, PHP_URL_SCHEME);
  32602. if (!isset($defaultPorts[$scheme])) {
  32603. throw new \InvalidArgumentException(sprintf(
  32604. 'Could not get default port for unknown scheme: %s',
  32605. $scheme
  32606. ));
  32607. }
  32608. $defaultPort = $defaultPorts[$scheme];
  32609. $port = parse_url($url, PHP_URL_PORT) ?: $defaultPort;
  32610. return parse_url($url, PHP_URL_HOST).':'.$port;
  32611. }
  32612. private function decodeResult($result, $http_response_header)
  32613. {
  32614. if ($result && extension_loaded('zlib')) {
  32615. $contentEncoding = Response::findHeaderValue($http_response_header, 'content-encoding');
  32616. $decode = $contentEncoding && 'gzip' === strtolower($contentEncoding);
  32617. if ($decode) {
  32618. if (PHP_VERSION_ID >= 50400) {
  32619. $result = zlib_decode($result);
  32620. } else {
  32621. $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result));
  32622. }
  32623. if ($result === false) {
  32624. throw new TransportException('Failed to decode zlib stream');
  32625. }
  32626. }
  32627. }
  32628. return $result;
  32629. }
  32630. }
  32631. <?php
  32632. namespace Composer\Util;
  32633. class Silencer
  32634. {
  32635. private static $stack = array();
  32636. public static function suppress($mask = null)
  32637. {
  32638. if (!isset($mask)) {
  32639. $mask = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT;
  32640. }
  32641. $old = error_reporting();
  32642. self::$stack[] = $old;
  32643. error_reporting($old & ~$mask);
  32644. return $old;
  32645. }
  32646. public static function restore()
  32647. {
  32648. if (!empty(self::$stack)) {
  32649. error_reporting(array_pop(self::$stack));
  32650. }
  32651. }
  32652. public static function call($callable )
  32653. {
  32654. try {
  32655. self::suppress();
  32656. $result = call_user_func_array($callable, array_slice(func_get_args(), 1));
  32657. self::restore();
  32658. return $result;
  32659. } catch (\Exception $e) {
  32660. self::restore();
  32661. throw $e;
  32662. }
  32663. }
  32664. }
  32665. <?php
  32666. namespace Composer\Util;
  32667. use Composer\Composer;
  32668. use Composer\CaBundle\CaBundle;
  32669. use Composer\Downloader\TransportException;
  32670. use Composer\Util\Http\ProxyManager;
  32671. use Psr\Log\LoggerInterface;
  32672. final class StreamContextFactory
  32673. {
  32674. public static function getContext($url, array $defaultOptions = array(), array $defaultParams = array())
  32675. {
  32676. $options = array('http' => array(
  32677. 'follow_location' => 1,
  32678. 'max_redirects' => 20,
  32679. ));
  32680. $options = array_replace_recursive($options, self::initOptions($url, $defaultOptions));
  32681. unset($defaultOptions['http']['header']);
  32682. $options = array_replace_recursive($options, $defaultOptions);
  32683. if (isset($options['http']['header'])) {
  32684. $options['http']['header'] = self::fixHttpHeaderField($options['http']['header']);
  32685. }
  32686. return stream_context_create($options, $defaultParams);
  32687. }
  32688. public static function initOptions($url, array $options, $forCurl = false)
  32689. {
  32690. if (!isset($options['http']['header'])) {
  32691. $options['http']['header'] = array();
  32692. }
  32693. if (is_string($options['http']['header'])) {
  32694. $options['http']['header'] = explode("\r\n", $options['http']['header']);
  32695. }
  32696. if (!$forCurl) {
  32697. $proxy = ProxyManager::getInstance()->getProxyForRequest($url);
  32698. if ($proxyOptions = $proxy->getContextOptions()) {
  32699. $isHttpsRequest = 0 === strpos($url, 'https://');
  32700. if ($proxy->isSecure()) {
  32701. if (!extension_loaded('openssl')) {
  32702. throw new TransportException('You must enable the openssl extension to use a secure proxy.');
  32703. }
  32704. if ($isHttpsRequest) {
  32705. throw new TransportException('You must enable the curl extension to make https requests through a secure proxy.');
  32706. }
  32707. } elseif ($isHttpsRequest && !extension_loaded('openssl')) {
  32708. throw new TransportException('You must enable the openssl extension to make https requests through a proxy.');
  32709. }
  32710. if (isset($proxyOptions['http']['header'])) {
  32711. $options['http']['header'][] = $proxyOptions['http']['header'];
  32712. unset($proxyOptions['http']['header']);
  32713. }
  32714. $options = array_replace_recursive($options, $proxyOptions);
  32715. }
  32716. }
  32717. if (defined('HHVM_VERSION')) {
  32718. $phpVersion = 'HHVM ' . HHVM_VERSION;
  32719. } else {
  32720. $phpVersion = 'PHP ' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
  32721. }
  32722. if ($forCurl) {
  32723. $curl = curl_version();
  32724. $httpVersion = 'cURL '.$curl['version'];
  32725. } else {
  32726. $httpVersion = 'streams';
  32727. }
  32728. if (!isset($options['http']['header']) || false === stripos(implode('', $options['http']['header']), 'user-agent')) {
  32729. $options['http']['header'][] = sprintf(
  32730. 'User-Agent: Composer/%s (%s; %s; %s; %s%s)',
  32731. Composer::getVersion(),
  32732. function_exists('php_uname') ? php_uname('s') : 'Unknown',
  32733. function_exists('php_uname') ? php_uname('r') : 'Unknown',
  32734. $phpVersion,
  32735. $httpVersion,
  32736. getenv('CI') ? '; CI' : ''
  32737. );
  32738. }
  32739. return $options;
  32740. }
  32741. public static function getTlsDefaults(array $options, LoggerInterface $logger = null)
  32742. {
  32743. $ciphers = implode(':', array(
  32744. 'ECDHE-RSA-AES128-GCM-SHA256',
  32745. 'ECDHE-ECDSA-AES128-GCM-SHA256',
  32746. 'ECDHE-RSA-AES256-GCM-SHA384',
  32747. 'ECDHE-ECDSA-AES256-GCM-SHA384',
  32748. 'DHE-RSA-AES128-GCM-SHA256',
  32749. 'DHE-DSS-AES128-GCM-SHA256',
  32750. 'kEDH+AESGCM',
  32751. 'ECDHE-RSA-AES128-SHA256',
  32752. 'ECDHE-ECDSA-AES128-SHA256',
  32753. 'ECDHE-RSA-AES128-SHA',
  32754. 'ECDHE-ECDSA-AES128-SHA',
  32755. 'ECDHE-RSA-AES256-SHA384',
  32756. 'ECDHE-ECDSA-AES256-SHA384',
  32757. 'ECDHE-RSA-AES256-SHA',
  32758. 'ECDHE-ECDSA-AES256-SHA',
  32759. 'DHE-RSA-AES128-SHA256',
  32760. 'DHE-RSA-AES128-SHA',
  32761. 'DHE-DSS-AES128-SHA256',
  32762. 'DHE-RSA-AES256-SHA256',
  32763. 'DHE-DSS-AES256-SHA',
  32764. 'DHE-RSA-AES256-SHA',
  32765. 'AES128-GCM-SHA256',
  32766. 'AES256-GCM-SHA384',
  32767. 'AES128-SHA256',
  32768. 'AES256-SHA256',
  32769. 'AES128-SHA',
  32770. 'AES256-SHA',
  32771. 'AES',
  32772. 'CAMELLIA',
  32773. 'DES-CBC3-SHA',
  32774. '!aNULL',
  32775. '!eNULL',
  32776. '!EXPORT',
  32777. '!DES',
  32778. '!RC4',
  32779. '!MD5',
  32780. '!PSK',
  32781. '!aECDH',
  32782. '!EDH-DSS-DES-CBC3-SHA',
  32783. '!EDH-RSA-DES-CBC3-SHA',
  32784. '!KRB5-DES-CBC3-SHA',
  32785. ));
  32786. $defaults = array(
  32787. 'ssl' => array(
  32788. 'ciphers' => $ciphers,
  32789. 'verify_peer' => true,
  32790. 'verify_depth' => 7,
  32791. 'SNI_enabled' => true,
  32792. 'capture_peer_cert' => true,
  32793. ),
  32794. );
  32795. if (isset($options['ssl'])) {
  32796. $defaults['ssl'] = array_replace_recursive($defaults['ssl'], $options['ssl']);
  32797. }
  32798. if (!isset($defaults['ssl']['cafile']) && !isset($defaults['ssl']['capath'])) {
  32799. $result = CaBundle::getSystemCaRootBundlePath($logger);
  32800. if (is_dir($result)) {
  32801. $defaults['ssl']['capath'] = $result;
  32802. } else {
  32803. $defaults['ssl']['cafile'] = $result;
  32804. }
  32805. }
  32806. if (isset($defaults['ssl']['cafile']) && (!is_readable($defaults['ssl']['cafile']) || !CaBundle::validateCaFile($defaults['ssl']['cafile'], $logger))) {
  32807. throw new TransportException('The configured cafile was not valid or could not be read.');
  32808. }
  32809. if (isset($defaults['ssl']['capath']) && (!is_dir($defaults['ssl']['capath']) || !is_readable($defaults['ssl']['capath']))) {
  32810. throw new TransportException('The configured capath was not valid or could not be read.');
  32811. }
  32812. if (PHP_VERSION_ID >= 50413) {
  32813. $defaults['ssl']['disable_compression'] = true;
  32814. }
  32815. return $defaults;
  32816. }
  32817. private static function fixHttpHeaderField($header)
  32818. {
  32819. if (!is_array($header)) {
  32820. $header = explode("\r\n", $header);
  32821. }
  32822. uasort($header, function ($el) {
  32823. return stripos($el, 'content-type') === 0 ? 1 : -1;
  32824. });
  32825. return $header;
  32826. }
  32827. }
  32828. <?php
  32829. namespace Composer\Util;
  32830. use Composer\Config;
  32831. use Composer\IO\IOInterface;
  32832. class Svn
  32833. {
  32834. const MAX_QTY_AUTH_TRIES = 5;
  32835. protected $credentials;
  32836. protected $hasAuth;
  32837. protected $io;
  32838. protected $url;
  32839. protected $cacheCredentials = true;
  32840. protected $process;
  32841. protected $qtyAuthTries = 0;
  32842. protected $config;
  32843. private static $version;
  32844. public function __construct($url, IOInterface $io, Config $config, ProcessExecutor $process = null)
  32845. {
  32846. $this->url = $url;
  32847. $this->io = $io;
  32848. $this->config = $config;
  32849. $this->process = $process ?: new ProcessExecutor($io);
  32850. }
  32851. public static function cleanEnv()
  32852. {
  32853. putenv("DYLD_LIBRARY_PATH");
  32854. unset($_SERVER['DYLD_LIBRARY_PATH']);
  32855. }
  32856. public function execute($command, $url, $cwd = null, $path = null, $verbose = false)
  32857. {
  32858. $this->config->prohibitUrlByConfig($url, $this->io);
  32859. return $this->executeWithAuthRetry($command, $cwd, $url, $path, $verbose);
  32860. }
  32861. public function executeLocal($command, $path, $cwd = null, $verbose = false)
  32862. {
  32863. return $this->executeWithAuthRetry($command, $cwd, '', $path, $verbose);
  32864. }
  32865. private function executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose)
  32866. {
  32867. $command = $this->getCommand($svnCommand, $url, $path);
  32868. $output = null;
  32869. $io = $this->io;
  32870. $handler = function ($type, $buffer) use (&$output, $io, $verbose) {
  32871. if ($type !== 'out') {
  32872. return;
  32873. }
  32874. if (strpos($buffer, 'Redirecting to URL ') === 0) {
  32875. return;
  32876. }
  32877. $output .= $buffer;
  32878. if ($verbose) {
  32879. $io->writeError($buffer, false);
  32880. }
  32881. };
  32882. $status = $this->process->execute($command, $handler, $cwd);
  32883. if (0 === $status) {
  32884. return $output;
  32885. }
  32886. $errorOutput = $this->process->getErrorOutput();
  32887. $fullOutput = implode("\n", array($output, $errorOutput));
  32888. if (false === stripos($fullOutput, 'Could not authenticate to server:')
  32889. && false === stripos($fullOutput, 'authorization failed')
  32890. && false === stripos($fullOutput, 'svn: E170001:')
  32891. && false === stripos($fullOutput, 'svn: E215004:')) {
  32892. throw new \RuntimeException($fullOutput);
  32893. }
  32894. if (!$this->hasAuth()) {
  32895. $this->doAuthDance();
  32896. }
  32897. if ($this->qtyAuthTries++ < self::MAX_QTY_AUTH_TRIES) {
  32898. return $this->executeWithAuthRetry($svnCommand, $cwd, $url, $path, $verbose);
  32899. }
  32900. throw new \RuntimeException(
  32901. 'wrong credentials provided ('.$fullOutput.')'
  32902. );
  32903. }
  32904. public function setCacheCredentials($cacheCredentials)
  32905. {
  32906. $this->cacheCredentials = $cacheCredentials;
  32907. }
  32908. protected function doAuthDance()
  32909. {
  32910. if (!$this->io->isInteractive()) {
  32911. throw new \RuntimeException(
  32912. 'can not ask for authentication in non interactive mode'
  32913. );
  32914. }
  32915. $this->io->writeError("The Subversion server ({$this->url}) requested credentials:");
  32916. $this->hasAuth = true;
  32917. $this->credentials['username'] = $this->io->ask("Username: ");
  32918. $this->credentials['password'] = $this->io->askAndHideAnswer("Password: ");
  32919. $this->cacheCredentials = $this->io->askConfirmation("Should Subversion cache these credentials? (yes/no) ");
  32920. return $this;
  32921. }
  32922. protected function getCommand($cmd, $url, $path = null)
  32923. {
  32924. $cmd = sprintf(
  32925. '%s %s%s %s',
  32926. $cmd,
  32927. '--non-interactive ',
  32928. $this->getCredentialString(),
  32929. ProcessExecutor::escape($url)
  32930. );
  32931. if ($path) {
  32932. $cmd .= ' ' . ProcessExecutor::escape($path);
  32933. }
  32934. return $cmd;
  32935. }
  32936. protected function getCredentialString()
  32937. {
  32938. if (!$this->hasAuth()) {
  32939. return '';
  32940. }
  32941. return sprintf(
  32942. ' %s--username %s --password %s ',
  32943. $this->getAuthCache(),
  32944. ProcessExecutor::escape($this->getUsername()),
  32945. ProcessExecutor::escape($this->getPassword())
  32946. );
  32947. }
  32948. protected function getPassword()
  32949. {
  32950. if ($this->credentials === null) {
  32951. throw new \LogicException("No svn auth detected.");
  32952. }
  32953. return isset($this->credentials['password']) ? $this->credentials['password'] : '';
  32954. }
  32955. protected function getUsername()
  32956. {
  32957. if ($this->credentials === null) {
  32958. throw new \LogicException("No svn auth detected.");
  32959. }
  32960. return $this->credentials['username'];
  32961. }
  32962. protected function hasAuth()
  32963. {
  32964. if (null !== $this->hasAuth) {
  32965. return $this->hasAuth;
  32966. }
  32967. if (false === $this->createAuthFromConfig()) {
  32968. $this->createAuthFromUrl();
  32969. }
  32970. return (bool) $this->hasAuth;
  32971. }
  32972. protected function getAuthCache()
  32973. {
  32974. return $this->cacheCredentials ? '' : '--no-auth-cache ';
  32975. }
  32976. private function createAuthFromConfig()
  32977. {
  32978. if (!$this->config->has('http-basic')) {
  32979. return $this->hasAuth = false;
  32980. }
  32981. $authConfig = $this->config->get('http-basic');
  32982. $host = parse_url($this->url, PHP_URL_HOST);
  32983. if (isset($authConfig[$host])) {
  32984. $this->credentials['username'] = $authConfig[$host]['username'];
  32985. $this->credentials['password'] = $authConfig[$host]['password'];
  32986. return $this->hasAuth = true;
  32987. }
  32988. return $this->hasAuth = false;
  32989. }
  32990. private function createAuthFromUrl()
  32991. {
  32992. $uri = parse_url($this->url);
  32993. if (empty($uri['user'])) {
  32994. return $this->hasAuth = false;
  32995. }
  32996. $this->credentials['username'] = $uri['user'];
  32997. if (!empty($uri['pass'])) {
  32998. $this->credentials['password'] = $uri['pass'];
  32999. }
  33000. return $this->hasAuth = true;
  33001. }
  33002. public function binaryVersion()
  33003. {
  33004. if (!self::$version) {
  33005. if (0 === $this->process->execute('svn --version', $output)) {
  33006. if (preg_match('{(\d+(?:\.\d+)+)}', $output, $match)) {
  33007. self::$version = $match[1];
  33008. }
  33009. }
  33010. }
  33011. return self::$version;
  33012. }
  33013. }
  33014. <?php
  33015. namespace Composer\Util;
  33016. use Composer\Downloader\DownloaderInterface;
  33017. use Composer\Package\PackageInterface;
  33018. use React\Promise\PromiseInterface;
  33019. class SyncHelper
  33020. {
  33021. public static function downloadAndInstallPackageSync(Loop $loop, DownloaderInterface $downloader, $path, PackageInterface $package, PackageInterface $prevPackage = null)
  33022. {
  33023. $type = $prevPackage ? 'update' : 'install';
  33024. try {
  33025. self::await($loop, $downloader->download($package, $path, $prevPackage));
  33026. self::await($loop, $downloader->prepare($type, $package, $path, $prevPackage));
  33027. if ($type === 'update') {
  33028. self::await($loop, $downloader->update($package, $path, $prevPackage));
  33029. } else {
  33030. self::await($loop, $downloader->install($package, $path, $prevPackage));
  33031. }
  33032. } catch (\Exception $e) {
  33033. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  33034. throw $e;
  33035. }
  33036. self::await($loop, $downloader->cleanup($type, $package, $path, $prevPackage));
  33037. }
  33038. public static function await(Loop $loop, PromiseInterface $promise = null)
  33039. {
  33040. if ($promise) {
  33041. $loop->wait(array($promise));
  33042. }
  33043. }
  33044. }
  33045. <?php
  33046. namespace Composer\Util;
  33047. class Tar
  33048. {
  33049. public static function getComposerJson($pathToArchive)
  33050. {
  33051. $phar = new \PharData($pathToArchive);
  33052. if (!$phar->valid()) {
  33053. return null;
  33054. }
  33055. return self::extractComposerJsonFromFolder($phar);
  33056. }
  33057. private static function extractComposerJsonFromFolder(\PharData $phar)
  33058. {
  33059. if (isset($phar['composer.json'])) {
  33060. return $phar['composer.json']->getContent();
  33061. }
  33062. $topLevelPaths = array();
  33063. foreach ($phar as $folderFile) {
  33064. $name = $folderFile->getBasename();
  33065. if ($folderFile->isDir()) {
  33066. $topLevelPaths[$name] = true;
  33067. if (\count($topLevelPaths) > 1) {
  33068. 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)));
  33069. }
  33070. }
  33071. }
  33072. $composerJsonPath = key($topLevelPaths).'/composer.json';
  33073. if ($topLevelPaths && isset($phar[$composerJsonPath])) {
  33074. return $phar[$composerJsonPath]->getContent();
  33075. }
  33076. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  33077. }
  33078. }
  33079. <?php
  33080. namespace Composer\Util;
  33081. use Composer\CaBundle\CaBundle;
  33082. final class TlsHelper
  33083. {
  33084. public static function checkCertificateHost($certificate, $hostname, &$cn = null)
  33085. {
  33086. $names = self::getCertificateNames($certificate);
  33087. if (empty($names)) {
  33088. return false;
  33089. }
  33090. $combinedNames = array_merge($names['san'], array($names['cn']));
  33091. $hostname = strtolower($hostname);
  33092. foreach ($combinedNames as $certName) {
  33093. $matcher = self::certNameMatcher($certName);
  33094. if ($matcher && $matcher($hostname)) {
  33095. $cn = $names['cn'];
  33096. return true;
  33097. }
  33098. }
  33099. return false;
  33100. }
  33101. public static function getCertificateNames($certificate)
  33102. {
  33103. if (is_array($certificate)) {
  33104. $info = $certificate;
  33105. } elseif (CaBundle::isOpensslParseSafe()) {
  33106. $info = openssl_x509_parse($certificate, false);
  33107. }
  33108. if (!isset($info['subject']['commonName'])) {
  33109. return null;
  33110. }
  33111. $commonName = strtolower($info['subject']['commonName']);
  33112. $subjectAltNames = array();
  33113. if (isset($info['extensions']['subjectAltName'])) {
  33114. $subjectAltNames = preg_split('{\s*,\s*}', $info['extensions']['subjectAltName']);
  33115. $subjectAltNames = array_filter(array_map(function ($name) {
  33116. if (0 === strpos($name, 'DNS:')) {
  33117. return strtolower(ltrim(substr($name, 4)));
  33118. }
  33119. return null;
  33120. }, $subjectAltNames));
  33121. $subjectAltNames = array_values($subjectAltNames);
  33122. }
  33123. return array(
  33124. 'cn' => $commonName,
  33125. 'san' => $subjectAltNames,
  33126. );
  33127. }
  33128. public static function getCertificateFingerprint($certificate)
  33129. {
  33130. $pubkeydetails = openssl_pkey_get_details(openssl_get_publickey($certificate));
  33131. $pubkeypem = $pubkeydetails['key'];
  33132. $start = '-----BEGIN PUBLIC KEY-----';
  33133. $end = '-----END PUBLIC KEY-----';
  33134. $pemtrim = substr($pubkeypem, strpos($pubkeypem, $start) + strlen($start), (strlen($pubkeypem) - strpos($pubkeypem, $end)) * (-1));
  33135. $der = base64_decode($pemtrim);
  33136. return sha1($der);
  33137. }
  33138. public static function isOpensslParseSafe()
  33139. {
  33140. return CaBundle::isOpensslParseSafe();
  33141. }
  33142. private static function certNameMatcher($certName)
  33143. {
  33144. $wildcards = substr_count($certName, '*');
  33145. if (0 === $wildcards) {
  33146. return function ($hostname) use ($certName) {
  33147. return $hostname === $certName;
  33148. };
  33149. }
  33150. if (1 === $wildcards) {
  33151. $components = explode('.', $certName);
  33152. if (3 > count($components)) {
  33153. return;
  33154. }
  33155. $firstComponent = $components[0];
  33156. if ('*' !== $firstComponent[strlen($firstComponent) - 1]) {
  33157. return;
  33158. }
  33159. $wildcardRegex = preg_quote($certName);
  33160. $wildcardRegex = str_replace('\\*', '[a-z0-9-]+', $wildcardRegex);
  33161. $wildcardRegex = "{^{$wildcardRegex}$}";
  33162. return function ($hostname) use ($wildcardRegex) {
  33163. return 1 === preg_match($wildcardRegex, $hostname);
  33164. };
  33165. }
  33166. }
  33167. }
  33168. <?php
  33169. namespace Composer\Util;
  33170. use Composer\Config;
  33171. class Url
  33172. {
  33173. public static function updateDistReference(Config $config, $url, $ref)
  33174. {
  33175. $host = parse_url($url, PHP_URL_HOST);
  33176. if ($host === 'api.github.com' || $host === 'github.com' || $host === 'www.github.com') {
  33177. if (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/(zip|tar)ball/(.+)$}i', $url, $match)) {
  33178. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33179. } elseif (preg_match('{^https?://(?:www\.)?github\.com/([^/]+)/([^/]+)/archive/.+\.(zip|tar)(?:\.gz)?$}i', $url, $match)) {
  33180. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33181. } elseif (preg_match('{^https?://api\.github\.com/repos/([^/]+)/([^/]+)/(zip|tar)ball(?:/.+)?$}i', $url, $match)) {
  33182. $url = 'https://api.github.com/repos/' . $match[1] . '/'. $match[2] . '/' . $match[3] . 'ball/' . $ref;
  33183. }
  33184. } elseif ($host === 'bitbucket.org' || $host === 'www.bitbucket.org') {
  33185. if (preg_match('{^https?://(?:www\.)?bitbucket\.org/([^/]+)/([^/]+)/get/(.+)\.(zip|tar\.gz|tar\.bz2)$}i', $url, $match)) {
  33186. $url = 'https://bitbucket.org/' . $match[1] . '/'. $match[2] . '/get/' . $ref . '.' . $match[4];
  33187. }
  33188. } elseif ($host === 'gitlab.com' || $host === 'www.gitlab.com') {
  33189. if (preg_match('{^https?://(?:www\.)?gitlab\.com/api/v[34]/projects/([^/]+)/repository/archive\.(zip|tar\.gz|tar\.bz2|tar)\?sha=.+$}i', $url, $match)) {
  33190. $url = 'https://gitlab.com/api/v4/projects/' . $match[1] . '/repository/archive.' . $match[2] . '?sha=' . $ref;
  33191. }
  33192. } elseif (in_array($host, $config->get('github-domains'), true)) {
  33193. $url = preg_replace('{(/repos/[^/]+/[^/]+/(zip|tar)ball)(?:/.+)?$}i', '$1/'.$ref, $url);
  33194. } elseif (in_array($host, $config->get('gitlab-domains'), true)) {
  33195. $url = preg_replace('{(/api/v[34]/projects/[^/]+/repository/archive\.(?:zip|tar\.gz|tar\.bz2|tar)\?sha=).+$}i', '${1}'.$ref, $url);
  33196. }
  33197. return $url;
  33198. }
  33199. public static function getOrigin(Config $config, $url)
  33200. {
  33201. if (0 === strpos($url, 'file://')) {
  33202. return $url;
  33203. }
  33204. $origin = (string) parse_url($url, PHP_URL_HOST);
  33205. if ($port = parse_url($url, PHP_URL_PORT)) {
  33206. $origin .= ':'.$port;
  33207. }
  33208. if (strpos($origin, '.github.com') === (strlen($origin) - 11)) {
  33209. return 'github.com';
  33210. }
  33211. if ($origin === 'repo.packagist.org') {
  33212. return 'packagist.org';
  33213. }
  33214. if ($origin === '') {
  33215. $origin = $url;
  33216. }
  33217. if (
  33218. is_array($config->get('gitlab-domains'))
  33219. && false === strpos($origin, '/')
  33220. && !in_array($origin, $config->get('gitlab-domains'))
  33221. ) {
  33222. foreach ($config->get('gitlab-domains') as $gitlabDomain) {
  33223. if (0 === strpos($gitlabDomain, $origin)) {
  33224. return $gitlabDomain;
  33225. }
  33226. }
  33227. }
  33228. return $origin;
  33229. }
  33230. public static function sanitize($url)
  33231. {
  33232. $url = preg_replace('{([&?]access_token=)[^&]+}', '$1***', $url);
  33233. $url = preg_replace_callback('{(?P<prefix>://|^)(?P<user>[^:/\s@]+):(?P<password>[^@\s/]+)@}i', function ($m) {
  33234. if (preg_match('{^[a-f0-9]{12,}$}', $m['user'])) {
  33235. return $m['prefix'].'***:***@';
  33236. }
  33237. return $m['prefix'].$m['user'].':***@';
  33238. }, $url);
  33239. return $url;
  33240. }
  33241. }
  33242. <?php
  33243. namespace Composer\Util;
  33244. class Zip
  33245. {
  33246. public static function getComposerJson($pathToZip)
  33247. {
  33248. if (!extension_loaded('zip')) {
  33249. throw new \RuntimeException('The Zip Util requires PHP\'s zip extension');
  33250. }
  33251. $zip = new \ZipArchive();
  33252. if ($zip->open($pathToZip) !== true) {
  33253. return null;
  33254. }
  33255. if (0 == $zip->numFiles) {
  33256. $zip->close();
  33257. return null;
  33258. }
  33259. $foundFileIndex = self::locateFile($zip, 'composer.json');
  33260. if (false === $foundFileIndex) {
  33261. $zip->close();
  33262. return null;
  33263. }
  33264. $content = null;
  33265. $configurationFileName = $zip->getNameIndex($foundFileIndex);
  33266. $stream = $zip->getStream($configurationFileName);
  33267. if (false !== $stream) {
  33268. $content = stream_get_contents($stream);
  33269. }
  33270. $zip->close();
  33271. return $content;
  33272. }
  33273. private static function locateFile(\ZipArchive $zip, $filename)
  33274. {
  33275. if (false !== ($index = $zip->locateName($filename)) && $zip->getFromIndex($index) !== false) {
  33276. return $index;
  33277. }
  33278. $topLevelPaths = array();
  33279. for ($i = 0; $i < $zip->numFiles; $i++) {
  33280. $name = $zip->getNameIndex($i);
  33281. $dirname = dirname($name);
  33282. if (strpos($name, '__MACOSX') !== false) {
  33283. continue;
  33284. }
  33285. if ($dirname === '.') {
  33286. $topLevelPaths[$name] = true;
  33287. if (\count($topLevelPaths) > 1) {
  33288. 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)));
  33289. }
  33290. continue;
  33291. }
  33292. if (false === strpos($dirname, '\\') && false === strpos($dirname, '/')) {
  33293. $topLevelPaths[$dirname.'/'] = true;
  33294. if (\count($topLevelPaths) > 1) {
  33295. 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)));
  33296. }
  33297. }
  33298. }
  33299. if ($topLevelPaths && false !== ($index = $zip->locateName(key($topLevelPaths).$filename)) && $zip->getFromIndex($index) !== false) {
  33300. return $index;
  33301. }
  33302. throw new \RuntimeException('No composer.json found either at the top level or within the topmost directory');
  33303. }
  33304. }
  33305. <?php
  33306. function includeIfExists($file)
  33307. {
  33308. return file_exists($file) ? include $file : false;
  33309. }
  33310. if ((!$loader = includeIfExists(__DIR__.'/../vendor/autoload.php')) && (!$loader = includeIfExists(__DIR__.'/../../../autoload.php'))) {
  33311. echo 'You must set up the project dependencies using `composer install`'.PHP_EOL.
  33312. 'See https://getcomposer.org/download/ for instructions on installing Composer'.PHP_EOL;
  33313. exit(1);
  33314. }
  33315. return $loader;
  33316. <?php
  33317. /*
  33318. * This file is part of Composer.
  33319. *
  33320. * (c) Nils Adermann <naderman@naderman.de>
  33321. * Jordi Boggiano <j.boggiano@seld.be>
  33322. *
  33323. * For the full copyright and license information, please view the LICENSE
  33324. * file that was distributed with this source code.
  33325. */
  33326. namespace Composer\Autoload;
  33327. /**
  33328. * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
  33329. *
  33330. * $loader = new \Composer\Autoload\ClassLoader();
  33331. *
  33332. * // register classes with namespaces
  33333. * $loader->add('Symfony\Component', __DIR__.'/component');
  33334. * $loader->add('Symfony', __DIR__.'/framework');
  33335. *
  33336. * // activate the autoloader
  33337. * $loader->register();
  33338. *
  33339. * // to enable searching the include path (eg. for PEAR packages)
  33340. * $loader->setUseIncludePath(true);
  33341. *
  33342. * In this example, if you try to use a class in the Symfony\Component
  33343. * namespace or one of its children (Symfony\Component\Console for instance),
  33344. * the autoloader will first look for the class under the component/
  33345. * directory, and it will then fallback to the framework/ directory if not
  33346. * found before giving up.
  33347. *
  33348. * This class is loosely based on the Symfony UniversalClassLoader.
  33349. *
  33350. * @author Fabien Potencier <fabien@symfony.com>
  33351. * @author Jordi Boggiano <j.boggiano@seld.be>
  33352. * @see https://www.php-fig.org/psr/psr-0/
  33353. * @see https://www.php-fig.org/psr/psr-4/
  33354. */
  33355. class ClassLoader
  33356. {
  33357. private $vendorDir;
  33358. // PSR-4
  33359. private $prefixLengthsPsr4 = array();
  33360. private $prefixDirsPsr4 = array();
  33361. private $fallbackDirsPsr4 = array();
  33362. // PSR-0
  33363. private $prefixesPsr0 = array();
  33364. private $fallbackDirsPsr0 = array();
  33365. private $useIncludePath = false;
  33366. private $classMap = array();
  33367. private $classMapAuthoritative = false;
  33368. private $missingClasses = array();
  33369. private $apcuPrefix;
  33370. private static $registeredLoaders = array();
  33371. public function __construct($vendorDir = null)
  33372. {
  33373. $this->vendorDir = $vendorDir;
  33374. }
  33375. public function getPrefixes()
  33376. {
  33377. if (!empty($this->prefixesPsr0)) {
  33378. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  33379. }
  33380. return array();
  33381. }
  33382. public function getPrefixesPsr4()
  33383. {
  33384. return $this->prefixDirsPsr4;
  33385. }
  33386. public function getFallbackDirs()
  33387. {
  33388. return $this->fallbackDirsPsr0;
  33389. }
  33390. public function getFallbackDirsPsr4()
  33391. {
  33392. return $this->fallbackDirsPsr4;
  33393. }
  33394. public function getClassMap()
  33395. {
  33396. return $this->classMap;
  33397. }
  33398. /**
  33399. * @param array $classMap Class to filename map
  33400. */
  33401. public function addClassMap(array $classMap)
  33402. {
  33403. if ($this->classMap) {
  33404. $this->classMap = array_merge($this->classMap, $classMap);
  33405. } else {
  33406. $this->classMap = $classMap;
  33407. }
  33408. }
  33409. /**
  33410. * Registers a set of PSR-0 directories for a given prefix, either
  33411. * appending or prepending to the ones previously set for this prefix.
  33412. *
  33413. * @param string $prefix The prefix
  33414. * @param array|string $paths The PSR-0 root directories
  33415. * @param bool $prepend Whether to prepend the directories
  33416. */
  33417. public function add($prefix, $paths, $prepend = false)
  33418. {
  33419. if (!$prefix) {
  33420. if ($prepend) {
  33421. $this->fallbackDirsPsr0 = array_merge(
  33422. (array) $paths,
  33423. $this->fallbackDirsPsr0
  33424. );
  33425. } else {
  33426. $this->fallbackDirsPsr0 = array_merge(
  33427. $this->fallbackDirsPsr0,
  33428. (array) $paths
  33429. );
  33430. }
  33431. return;
  33432. }
  33433. $first = $prefix[0];
  33434. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  33435. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  33436. return;
  33437. }
  33438. if ($prepend) {
  33439. $this->prefixesPsr0[$first][$prefix] = array_merge(
  33440. (array) $paths,
  33441. $this->prefixesPsr0[$first][$prefix]
  33442. );
  33443. } else {
  33444. $this->prefixesPsr0[$first][$prefix] = array_merge(
  33445. $this->prefixesPsr0[$first][$prefix],
  33446. (array) $paths
  33447. );
  33448. }
  33449. }
  33450. /**
  33451. * Registers a set of PSR-4 directories for a given namespace, either
  33452. * appending or prepending to the ones previously set for this namespace.
  33453. *
  33454. * @param string $prefix The prefix/namespace, with trailing '\\'
  33455. * @param array|string $paths The PSR-4 base directories
  33456. * @param bool $prepend Whether to prepend the directories
  33457. *
  33458. * @throws \InvalidArgumentException
  33459. */
  33460. public function addPsr4($prefix, $paths, $prepend = false)
  33461. {
  33462. if (!$prefix) {
  33463. // Register directories for the root namespace.
  33464. if ($prepend) {
  33465. $this->fallbackDirsPsr4 = array_merge(
  33466. (array) $paths,
  33467. $this->fallbackDirsPsr4
  33468. );
  33469. } else {
  33470. $this->fallbackDirsPsr4 = array_merge(
  33471. $this->fallbackDirsPsr4,
  33472. (array) $paths
  33473. );
  33474. }
  33475. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  33476. // Register directories for a new namespace.
  33477. $length = strlen($prefix);
  33478. if ('\\' !== $prefix[$length - 1]) {
  33479. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  33480. }
  33481. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  33482. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  33483. } elseif ($prepend) {
  33484. // Prepend directories for an already registered namespace.
  33485. $this->prefixDirsPsr4[$prefix] = array_merge(
  33486. (array) $paths,
  33487. $this->prefixDirsPsr4[$prefix]
  33488. );
  33489. } else {
  33490. // Append directories for an already registered namespace.
  33491. $this->prefixDirsPsr4[$prefix] = array_merge(
  33492. $this->prefixDirsPsr4[$prefix],
  33493. (array) $paths
  33494. );
  33495. }
  33496. }
  33497. /**
  33498. * Registers a set of PSR-0 directories for a given prefix,
  33499. * replacing any others previously set for this prefix.
  33500. *
  33501. * @param string $prefix The prefix
  33502. * @param array|string $paths The PSR-0 base directories
  33503. */
  33504. public function set($prefix, $paths)
  33505. {
  33506. if (!$prefix) {
  33507. $this->fallbackDirsPsr0 = (array) $paths;
  33508. } else {
  33509. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  33510. }
  33511. }
  33512. /**
  33513. * Registers a set of PSR-4 directories for a given namespace,
  33514. * replacing any others previously set for this namespace.
  33515. *
  33516. * @param string $prefix The prefix/namespace, with trailing '\\'
  33517. * @param array|string $paths The PSR-4 base directories
  33518. *
  33519. * @throws \InvalidArgumentException
  33520. */
  33521. public function setPsr4($prefix, $paths)
  33522. {
  33523. if (!$prefix) {
  33524. $this->fallbackDirsPsr4 = (array) $paths;
  33525. } else {
  33526. $length = strlen($prefix);
  33527. if ('\\' !== $prefix[$length - 1]) {
  33528. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  33529. }
  33530. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  33531. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  33532. }
  33533. }
  33534. /**
  33535. * Turns on searching the include path for class files.
  33536. *
  33537. * @param bool $useIncludePath
  33538. */
  33539. public function setUseIncludePath($useIncludePath)
  33540. {
  33541. $this->useIncludePath = $useIncludePath;
  33542. }
  33543. /**
  33544. * Can be used to check if the autoloader uses the include path to check
  33545. * for classes.
  33546. *
  33547. * @return bool
  33548. */
  33549. public function getUseIncludePath()
  33550. {
  33551. return $this->useIncludePath;
  33552. }
  33553. /**
  33554. * Turns off searching the prefix and fallback directories for classes
  33555. * that have not been registered with the class map.
  33556. *
  33557. * @param bool $classMapAuthoritative
  33558. */
  33559. public function setClassMapAuthoritative($classMapAuthoritative)
  33560. {
  33561. $this->classMapAuthoritative = $classMapAuthoritative;
  33562. }
  33563. /**
  33564. * Should class lookup fail if not found in the current class map?
  33565. *
  33566. * @return bool
  33567. */
  33568. public function isClassMapAuthoritative()
  33569. {
  33570. return $this->classMapAuthoritative;
  33571. }
  33572. /**
  33573. * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
  33574. *
  33575. * @param string|null $apcuPrefix
  33576. */
  33577. public function setApcuPrefix($apcuPrefix)
  33578. {
  33579. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  33580. }
  33581. /**
  33582. * The APCu prefix in use, or null if APCu caching is not enabled.
  33583. *
  33584. * @return string|null
  33585. */
  33586. public function getApcuPrefix()
  33587. {
  33588. return $this->apcuPrefix;
  33589. }
  33590. /**
  33591. * Registers this instance as an autoloader.
  33592. *
  33593. * @param bool $prepend Whether to prepend the autoloader or not
  33594. */
  33595. public function register($prepend = false)
  33596. {
  33597. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  33598. if (null === $this->vendorDir) {
  33599. //no-op
  33600. } elseif ($prepend) {
  33601. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  33602. } else {
  33603. unset(self::$registeredLoaders[$this->vendorDir]);
  33604. self::$registeredLoaders[$this->vendorDir] = $this;
  33605. }
  33606. }
  33607. /**
  33608. * Unregisters this instance as an autoloader.
  33609. */
  33610. public function unregister()
  33611. {
  33612. spl_autoload_unregister(array($this, 'loadClass'));
  33613. if (null !== $this->vendorDir) {
  33614. unset(self::$registeredLoaders[$this->vendorDir]);
  33615. }
  33616. }
  33617. /**
  33618. * Loads the given class or interface.
  33619. *
  33620. * @param string $class The name of the class
  33621. * @return bool|null True if loaded, null otherwise
  33622. */
  33623. public function loadClass($class)
  33624. {
  33625. if ($file = $this->findFile($class)) {
  33626. includeFile($file);
  33627. return true;
  33628. }
  33629. }
  33630. /**
  33631. * Finds the path to the file where the class is defined.
  33632. *
  33633. * @param string $class The name of the class
  33634. *
  33635. * @return string|false The path if found, false otherwise
  33636. */
  33637. public function findFile($class)
  33638. {
  33639. // class map lookup
  33640. if (isset($this->classMap[$class])) {
  33641. return $this->classMap[$class];
  33642. }
  33643. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  33644. return false;
  33645. }
  33646. if (null !== $this->apcuPrefix) {
  33647. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  33648. if ($hit) {
  33649. return $file;
  33650. }
  33651. }
  33652. $file = $this->findFileWithExtension($class, '.php');
  33653. // Search for Hack files if we are running on HHVM
  33654. if (false === $file && defined('HHVM_VERSION')) {
  33655. $file = $this->findFileWithExtension($class, '.hh');
  33656. }
  33657. if (null !== $this->apcuPrefix) {
  33658. apcu_add($this->apcuPrefix.$class, $file);
  33659. }
  33660. if (false === $file) {
  33661. // Remember that this class does not exist.
  33662. $this->missingClasses[$class] = true;
  33663. }
  33664. return $file;
  33665. }
  33666. /**
  33667. * Returns the currently registered loaders indexed by their corresponding vendor directories.
  33668. *
  33669. * @return self[]
  33670. */
  33671. public static function getRegisteredLoaders()
  33672. {
  33673. return self::$registeredLoaders;
  33674. }
  33675. private function findFileWithExtension($class, $ext)
  33676. {
  33677. // PSR-4 lookup
  33678. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  33679. $first = $class[0];
  33680. if (isset($this->prefixLengthsPsr4[$first])) {
  33681. $subPath = $class;
  33682. while (false !== $lastPos = strrpos($subPath, '\\')) {
  33683. $subPath = substr($subPath, 0, $lastPos);
  33684. $search = $subPath . '\\';
  33685. if (isset($this->prefixDirsPsr4[$search])) {
  33686. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  33687. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  33688. if (file_exists($file = $dir . $pathEnd)) {
  33689. return $file;
  33690. }
  33691. }
  33692. }
  33693. }
  33694. }
  33695. // PSR-4 fallback dirs
  33696. foreach ($this->fallbackDirsPsr4 as $dir) {
  33697. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  33698. return $file;
  33699. }
  33700. }
  33701. // PSR-0 lookup
  33702. if (false !== $pos = strrpos($class, '\\')) {
  33703. // namespaced class name
  33704. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  33705. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  33706. } else {
  33707. // PEAR-like class name
  33708. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  33709. }
  33710. if (isset($this->prefixesPsr0[$first])) {
  33711. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  33712. if (0 === strpos($class, $prefix)) {
  33713. foreach ($dirs as $dir) {
  33714. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  33715. return $file;
  33716. }
  33717. }
  33718. }
  33719. }
  33720. }
  33721. // PSR-0 fallback dirs
  33722. foreach ($this->fallbackDirsPsr0 as $dir) {
  33723. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  33724. return $file;
  33725. }
  33726. }
  33727. // PSR-0 include paths.
  33728. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  33729. return $file;
  33730. }
  33731. return false;
  33732. }
  33733. }
  33734. /**
  33735. * Scope isolated include.
  33736. *
  33737. * Prevents access to $this/self from included files.
  33738. */
  33739. function includeFile($file)
  33740. {
  33741. include $file;
  33742. }
  33743. {
  33744. "$schema": "https://json-schema.org/draft-04/schema#",
  33745. "description": "A representation of packages metadata.",
  33746. "type": "object",
  33747. "oneOf": [
  33748. { "required": [ "packages" ] },
  33749. { "required": [ "providers" ] },
  33750. { "required": [ "provider-includes", "providers-url" ] }
  33751. ],
  33752. "properties": {
  33753. "packages": {
  33754. "type": ["object", "array"],
  33755. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  33756. "additionalProperties": { "$ref": "#/definitions/versions" }
  33757. },
  33758. "providers-url": {
  33759. "type": "string",
  33760. "description": "Endpoint to retrieve provider data from, e.g. '/p/%package%$%hash%.json'."
  33761. },
  33762. "provider-includes": {
  33763. "type": "object",
  33764. "description": "A hashmap of provider listings.",
  33765. "additionalProperties": { "$ref": "#/definitions/provider" }
  33766. },
  33767. "providers": {
  33768. "type": "object",
  33769. "description": "A hashmap of package names in the form of <vendor>/<name>.",
  33770. "additionalProperties": { "$ref": "#/definitions/provider" }
  33771. },
  33772. "notify-batch": {
  33773. "type": "string",
  33774. "description": "Endpoint to call after multiple packages have been installed, e.g. '/downloads/'."
  33775. },
  33776. "search": {
  33777. "type": "string",
  33778. "description": "Endpoint that provides search capabilities, e.g. '/search.json?q=%query%&type=%type%'."
  33779. },
  33780. "warning": {
  33781. "type": "string",
  33782. "description": "A message that will be output by Composer as a warning when this source is consulted."
  33783. }
  33784. },
  33785. "definitions": {
  33786. "versions": {
  33787. "type": "object",
  33788. "description": "A hashmap of versions and their metadata.",
  33789. "additionalProperties": { "$ref": "#/definitions/version" }
  33790. },
  33791. "version": {
  33792. "type": "object",
  33793. "oneOf": [
  33794. { "$ref": "#/definitions/package" },
  33795. { "$ref": "#/definitions/metapackage" }
  33796. ]
  33797. },
  33798. "package-base": {
  33799. "properties": {
  33800. "name": { "type": "string" },
  33801. "type": { "type": "string" },
  33802. "version": { "type": "string" },
  33803. "version_normalized": {
  33804. "type": "string",
  33805. "description": "Normalized version, optional but can save computational time on client side."
  33806. },
  33807. "autoload": { "type": "object" },
  33808. "require": { "type": "object" },
  33809. "replace": { "type": "object" },
  33810. "conflict": { "type": "object" },
  33811. "provide": { "type": "object" },
  33812. "time": { "type": "string" }
  33813. },
  33814. "additionalProperties": true
  33815. },
  33816. "package": {
  33817. "allOf": [
  33818. { "$ref": "#/definitions/package-base" },
  33819. {
  33820. "properties": {
  33821. "dist": { "type": "object" },
  33822. "source": { "type": "object" }
  33823. }
  33824. },
  33825. { "oneOf": [
  33826. { "required": [ "name", "version", "source" ] },
  33827. { "required": [ "name", "version", "dist" ] }
  33828. ] }
  33829. ]
  33830. },
  33831. "metapackage": {
  33832. "allOf": [
  33833. { "$ref": "#/definitions/package-base" },
  33834. {
  33835. "properties": {
  33836. "type": { "type": "string", "enum": [ "metapackage" ] }
  33837. },
  33838. "required": [ "name", "version", "type" ]
  33839. }
  33840. ]
  33841. },
  33842. "provider": {
  33843. "type": "object",
  33844. "properties": {
  33845. "sha256": {
  33846. "type": "string",
  33847. "description": "Hash value that can be used to validate the resource."
  33848. }
  33849. }
  33850. }
  33851. }
  33852. }
  33853. {
  33854. "$schema": "https://json-schema.org/draft-04/schema#",
  33855. "name": "Package",
  33856. "type": "object",
  33857. "additionalProperties": false,
  33858. "required": [ "name", "description" ],
  33859. "properties": {
  33860. "name": {
  33861. "type": "string",
  33862. "description": "Package name, including 'vendor-name/' prefix.",
  33863. "pattern": "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$"
  33864. },
  33865. "type": {
  33866. "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.",
  33867. "type": "string",
  33868. "pattern": "^[a-z0-9-]+$"
  33869. },
  33870. "target-dir": {
  33871. "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.",
  33872. "type": "string"
  33873. },
  33874. "description": {
  33875. "type": "string",
  33876. "description": "Short package description."
  33877. },
  33878. "keywords": {
  33879. "type": "array",
  33880. "items": {
  33881. "type": "string",
  33882. "description": "A tag/keyword that this package relates to."
  33883. }
  33884. },
  33885. "homepage": {
  33886. "type": "string",
  33887. "description": "Homepage URL for the project.",
  33888. "format": "uri"
  33889. },
  33890. "readme": {
  33891. "type": "string",
  33892. "description": "Relative path to the readme document."
  33893. },
  33894. "version": {
  33895. "type": "string",
  33896. "description": "Package version, see https://getcomposer.org/doc/04-schema.md#version for more info on valid schemes.",
  33897. "pattern": "^v?\\d+(((\\.\\d+)?\\.\\d+)?\\.\\d+)?|^dev-"
  33898. },
  33899. "time": {
  33900. "type": "string",
  33901. "description": "Package release date, in 'YYYY-MM-DD', 'YYYY-MM-DD HH:MM:SS' or 'YYYY-MM-DDTHH:MM:SSZ' format."
  33902. },
  33903. "license": {
  33904. "type": ["string", "array"],
  33905. "description": "License name. Or an array of license names."
  33906. },
  33907. "authors": {
  33908. "$ref": "#/definitions/authors"
  33909. },
  33910. "require": {
  33911. "type": "object",
  33912. "description": "This is a hash of package name (keys) and version constraints (values) that are required to run this package.",
  33913. "additionalProperties": {
  33914. "type": "string"
  33915. }
  33916. },
  33917. "replace": {
  33918. "type": "object",
  33919. "description": "This is a hash of package name (keys) and version constraints (values) that can be replaced by this package.",
  33920. "additionalProperties": {
  33921. "type": "string"
  33922. }
  33923. },
  33924. "conflict": {
  33925. "type": "object",
  33926. "description": "This is a hash of package name (keys) and version constraints (values) that conflict with this package.",
  33927. "additionalProperties": {
  33928. "type": "string"
  33929. }
  33930. },
  33931. "provide": {
  33932. "type": "object",
  33933. "description": "This is a hash of package name (keys) and version constraints (values) that this package provides in addition to this package's name.",
  33934. "additionalProperties": {
  33935. "type": "string"
  33936. }
  33937. },
  33938. "require-dev": {
  33939. "type": "object",
  33940. "description": "This is a hash of package name (keys) and version constraints (values) that this package requires for developing it (testing tools and such).",
  33941. "additionalProperties": {
  33942. "type": "string"
  33943. }
  33944. },
  33945. "suggest": {
  33946. "type": "object",
  33947. "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).",
  33948. "additionalProperties": {
  33949. "type": "string"
  33950. }
  33951. },
  33952. "config": {
  33953. "type": "object",
  33954. "description": "Composer options.",
  33955. "properties": {
  33956. "process-timeout": {
  33957. "type": "integer",
  33958. "description": "The timeout in seconds for process executions, defaults to 300 (5mins)."
  33959. },
  33960. "use-include-path": {
  33961. "type": "boolean",
  33962. "description": "If true, the Composer autoloader will also look for classes in the PHP include path."
  33963. },
  33964. "preferred-install": {
  33965. "type": ["string", "object"],
  33966. "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\"}."
  33967. },
  33968. "notify-on-install": {
  33969. "type": "boolean",
  33970. "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."
  33971. },
  33972. "github-protocols": {
  33973. "type": "array",
  33974. "description": "A list of protocols to use for github.com clones, in priority order, defaults to [\"git\", \"https\", \"http\"].",
  33975. "items": {
  33976. "type": "string"
  33977. }
  33978. },
  33979. "github-oauth": {
  33980. "type": "object",
  33981. "description": "A hash of domain name => github API oauth tokens, typically {\"github.com\":\"<token>\"}.",
  33982. "additionalProperties": {
  33983. "type": "string"
  33984. }
  33985. },
  33986. "gitlab-oauth": {
  33987. "type": "object",
  33988. "description": "A hash of domain name => gitlab API oauth tokens, typically {\"gitlab.com\":\"<token>\"}.",
  33989. "additionalProperties": {
  33990. "type": "string"
  33991. }
  33992. },
  33993. "gitlab-token": {
  33994. "type": "object",
  33995. "description": "A hash of domain name => gitlab private tokens, typically {\"gitlab.com\":\"<token>\"}.",
  33996. "additionalProperties": {
  33997. "type": "string"
  33998. }
  33999. },
  34000. "bearer": {
  34001. "type": "object",
  34002. "description": "A hash of domain name => bearer authentication token, for example {\"example.com\":\"<token>\"}.",
  34003. "additionalProperties": {
  34004. "type": "string"
  34005. }
  34006. },
  34007. "disable-tls": {
  34008. "type": "boolean",
  34009. "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."
  34010. },
  34011. "secure-http": {
  34012. "type": "boolean",
  34013. "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."
  34014. },
  34015. "cafile": {
  34016. "type": "string",
  34017. "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."
  34018. },
  34019. "capath": {
  34020. "type": "string",
  34021. "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."
  34022. },
  34023. "http-basic": {
  34024. "type": "object",
  34025. "description": "A hash of domain name => {\"username\": \"...\", \"password\": \"...\"}.",
  34026. "additionalProperties": {
  34027. "type": "object",
  34028. "required": ["username", "password"],
  34029. "properties": {
  34030. "username": {
  34031. "type": "string",
  34032. "description": "The username used for HTTP Basic authentication"
  34033. },
  34034. "password": {
  34035. "type": "string",
  34036. "description": "The password used for HTTP Basic authentication"
  34037. }
  34038. }
  34039. }
  34040. },
  34041. "store-auths": {
  34042. "type": ["string", "boolean"],
  34043. "description": "What to do after prompting for authentication, one of: true (store), false (do not store) or \"prompt\" (ask every time), defaults to prompt."
  34044. },
  34045. "platform": {
  34046. "type": "object",
  34047. "description": "This is a hash of package name (keys) and version (values) that will be used to mock the platform packages on this machine.",
  34048. "additionalProperties": {
  34049. "type": "string"
  34050. }
  34051. },
  34052. "vendor-dir": {
  34053. "type": "string",
  34054. "description": "The location where all packages are installed, defaults to \"vendor\"."
  34055. },
  34056. "bin-dir": {
  34057. "type": "string",
  34058. "description": "The location where all binaries are linked, defaults to \"vendor/bin\"."
  34059. },
  34060. "data-dir": {
  34061. "type": "string",
  34062. "description": "The location where old phar files are stored, defaults to \"$home\" except on XDG Base Directory compliant unixes."
  34063. },
  34064. "cache-dir": {
  34065. "type": "string",
  34066. "description": "The location where all caches are located, defaults to \"~/.composer/cache\" on *nix and \"%LOCALAPPDATA%\\Composer\" on windows."
  34067. },
  34068. "cache-files-dir": {
  34069. "type": "string",
  34070. "description": "The location where files (zip downloads) are cached, defaults to \"{$cache-dir}/files\"."
  34071. },
  34072. "cache-repo-dir": {
  34073. "type": "string",
  34074. "description": "The location where repo (git/hg repo clones) are cached, defaults to \"{$cache-dir}/repo\"."
  34075. },
  34076. "cache-vcs-dir": {
  34077. "type": "string",
  34078. "description": "The location where vcs infos (git clones, github api calls, etc. when reading vcs repos) are cached, defaults to \"{$cache-dir}/vcs\"."
  34079. },
  34080. "cache-ttl": {
  34081. "type": "integer",
  34082. "description": "The default cache time-to-live, defaults to 15552000 (6 months)."
  34083. },
  34084. "cache-files-ttl": {
  34085. "type": "integer",
  34086. "description": "The cache time-to-live for files, defaults to the value of cache-ttl."
  34087. },
  34088. "cache-files-maxsize": {
  34089. "type": ["string", "integer"],
  34090. "description": "The cache max size for the files cache, defaults to \"300MiB\"."
  34091. },
  34092. "cache-read-only": {
  34093. "type": ["boolean"],
  34094. "description": "Whether to use the Composer cache in read-only mode."
  34095. },
  34096. "bin-compat": {
  34097. "enum": ["auto", "full"],
  34098. "description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed) and can be \"full\" (compatible with both Windows and Unix-based systems)."
  34099. },
  34100. "discard-changes": {
  34101. "type": ["string", "boolean"],
  34102. "description": "The default style of handling dirty updates, defaults to false and can be any of true, false or \"stash\"."
  34103. },
  34104. "autoloader-suffix": {
  34105. "type": "string",
  34106. "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
  34107. },
  34108. "optimize-autoloader": {
  34109. "type": "boolean",
  34110. "description": "Always optimize when dumping the autoloader."
  34111. },
  34112. "prepend-autoloader": {
  34113. "type": "boolean",
  34114. "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
  34115. },
  34116. "classmap-authoritative": {
  34117. "type": "boolean",
  34118. "description": "If true, the composer autoloader will not scan the filesystem for classes that are not found in the class map, defaults to false."
  34119. },
  34120. "apcu-autoloader": {
  34121. "type": "boolean",
  34122. "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."
  34123. },
  34124. "github-domains": {
  34125. "type": "array",
  34126. "description": "A list of domains to use in github mode. This is used for GitHub Enterprise setups, defaults to [\"github.com\"].",
  34127. "items": {
  34128. "type": "string"
  34129. }
  34130. },
  34131. "github-expose-hostname": {
  34132. "type": "boolean",
  34133. "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."
  34134. },
  34135. "gitlab-domains": {
  34136. "type": "array",
  34137. "description": "A list of domains to use in gitlab mode. This is used for custom GitLab setups, defaults to [\"gitlab.com\"].",
  34138. "items": {
  34139. "type": "string"
  34140. }
  34141. },
  34142. "use-github-api": {
  34143. "type": "boolean",
  34144. "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."
  34145. },
  34146. "archive-format": {
  34147. "type": "string",
  34148. "description": "The default archiving format when not provided on cli, defaults to \"tar\"."
  34149. },
  34150. "archive-dir": {
  34151. "type": "string",
  34152. "description": "The default archive path when not provided on cli, defaults to \".\"."
  34153. },
  34154. "htaccess-protect": {
  34155. "type": "boolean",
  34156. "description": "Defaults to true. If set to false, Composer will not create .htaccess files in the composer home, cache, and data directories."
  34157. },
  34158. "sort-packages": {
  34159. "type": "boolean",
  34160. "description": "Defaults to false. If set to true, Composer will sort packages when adding/updating a new dependency."
  34161. },
  34162. "lock": {
  34163. "type": "boolean",
  34164. "description": "Defaults to true. If set to false, Composer will not create a composer.lock file."
  34165. },
  34166. "platform-check": {
  34167. "type": ["boolean", "string"],
  34168. "description": "Defaults to \"php-only\" which checks only the PHP version. Setting to true will also check the presence of required PHP extensions. If set to false, Composer will not create and require a platform_check.php file as part of the autoloader bootstrap."
  34169. }
  34170. }
  34171. },
  34172. "extra": {
  34173. "type": ["object", "array"],
  34174. "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.",
  34175. "additionalProperties": true
  34176. },
  34177. "autoload": {
  34178. "$ref": "#/definitions/autoload"
  34179. },
  34180. "autoload-dev": {
  34181. "type": "object",
  34182. "description": "Description of additional autoload rules for development purpose (eg. a test suite).",
  34183. "properties": {
  34184. "psr-0": {
  34185. "type": "object",
  34186. "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.",
  34187. "additionalProperties": {
  34188. "type": ["string", "array"],
  34189. "items": {
  34190. "type": "string"
  34191. }
  34192. }
  34193. },
  34194. "psr-4": {
  34195. "type": "object",
  34196. "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.",
  34197. "additionalProperties": {
  34198. "type": ["string", "array"],
  34199. "items": {
  34200. "type": "string"
  34201. }
  34202. }
  34203. },
  34204. "classmap": {
  34205. "type": "array",
  34206. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  34207. },
  34208. "files": {
  34209. "type": "array",
  34210. "description": "This is an array of files that are always required on every request."
  34211. }
  34212. }
  34213. },
  34214. "archive": {
  34215. "type": ["object"],
  34216. "description": "Options for creating package archives for distribution.",
  34217. "properties": {
  34218. "name": {
  34219. "type": "string",
  34220. "description": "A base name for archive."
  34221. },
  34222. "exclude": {
  34223. "type": "array",
  34224. "description": "A list of patterns for paths to exclude or include if prefixed with an exclamation mark."
  34225. }
  34226. }
  34227. },
  34228. "repositories": {
  34229. "type": ["object", "array"],
  34230. "description": "A set of additional repositories where packages can be found.",
  34231. "additionalProperties": {
  34232. "anyOf": [
  34233. { "$ref": "#/definitions/repository" },
  34234. { "type": "boolean", "enum": [false] }
  34235. ]
  34236. },
  34237. "items": {
  34238. "anyOf": [
  34239. { "$ref": "#/definitions/repository" },
  34240. {
  34241. "type": "object",
  34242. "additionalProperties": { "type": "boolean", "enum": [false] },
  34243. "minProperties": 1,
  34244. "maxProperties": 1
  34245. }
  34246. ]
  34247. }
  34248. },
  34249. "minimum-stability": {
  34250. "type": ["string"],
  34251. "description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable.",
  34252. "pattern": "^dev|alpha|beta|rc|RC|stable$"
  34253. },
  34254. "prefer-stable": {
  34255. "type": ["boolean"],
  34256. "description": "If set to true, stable packages will be preferred to dev packages when possible, even if the minimum-stability allows unstable packages."
  34257. },
  34258. "bin": {
  34259. "type": ["string", "array"],
  34260. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  34261. "items": {
  34262. "type": "string"
  34263. }
  34264. },
  34265. "include-path": {
  34266. "type": ["array"],
  34267. "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.",
  34268. "items": {
  34269. "type": "string"
  34270. }
  34271. },
  34272. "scripts": {
  34273. "type": ["object"],
  34274. "description": "Script listeners that will be executed before/after some events.",
  34275. "properties": {
  34276. "pre-install-cmd": {
  34277. "type": ["array", "string"],
  34278. "description": "Occurs before the install command is executed, contains one or more Class::method callables or shell commands."
  34279. },
  34280. "post-install-cmd": {
  34281. "type": ["array", "string"],
  34282. "description": "Occurs after the install command is executed, contains one or more Class::method callables or shell commands."
  34283. },
  34284. "pre-update-cmd": {
  34285. "type": ["array", "string"],
  34286. "description": "Occurs before the update command is executed, contains one or more Class::method callables or shell commands."
  34287. },
  34288. "post-update-cmd": {
  34289. "type": ["array", "string"],
  34290. "description": "Occurs after the update command is executed, contains one or more Class::method callables or shell commands."
  34291. },
  34292. "pre-status-cmd": {
  34293. "type": ["array", "string"],
  34294. "description": "Occurs before the status command is executed, contains one or more Class::method callables or shell commands."
  34295. },
  34296. "post-status-cmd": {
  34297. "type": ["array", "string"],
  34298. "description": "Occurs after the status command is executed, contains one or more Class::method callables or shell commands."
  34299. },
  34300. "pre-package-install": {
  34301. "type": ["array", "string"],
  34302. "description": "Occurs before a package is installed, contains one or more Class::method callables or shell commands."
  34303. },
  34304. "post-package-install": {
  34305. "type": ["array", "string"],
  34306. "description": "Occurs after a package is installed, contains one or more Class::method callables or shell commands."
  34307. },
  34308. "pre-package-update": {
  34309. "type": ["array", "string"],
  34310. "description": "Occurs before a package is updated, contains one or more Class::method callables or shell commands."
  34311. },
  34312. "post-package-update": {
  34313. "type": ["array", "string"],
  34314. "description": "Occurs after a package is updated, contains one or more Class::method callables or shell commands."
  34315. },
  34316. "pre-package-uninstall": {
  34317. "type": ["array", "string"],
  34318. "description": "Occurs before a package has been uninstalled, contains one or more Class::method callables or shell commands."
  34319. },
  34320. "post-package-uninstall": {
  34321. "type": ["array", "string"],
  34322. "description": "Occurs after a package has been uninstalled, contains one or more Class::method callables or shell commands."
  34323. },
  34324. "pre-autoload-dump": {
  34325. "type": ["array", "string"],
  34326. "description": "Occurs before the autoloader is dumped, contains one or more Class::method callables or shell commands."
  34327. },
  34328. "post-autoload-dump": {
  34329. "type": ["array", "string"],
  34330. "description": "Occurs after the autoloader is dumped, contains one or more Class::method callables or shell commands."
  34331. },
  34332. "post-root-package-install": {
  34333. "type": ["array", "string"],
  34334. "description": "Occurs after the root-package is installed, contains one or more Class::method callables or shell commands."
  34335. },
  34336. "post-create-project-cmd": {
  34337. "type": ["array", "string"],
  34338. "description": "Occurs after the create-project command is executed, contains one or more Class::method callables or shell commands."
  34339. }
  34340. }
  34341. },
  34342. "scripts-descriptions": {
  34343. "type": ["object"],
  34344. "description": "Descriptions for custom commands, shown in console help.",
  34345. "additionalProperties": {
  34346. "type": "string"
  34347. }
  34348. },
  34349. "support": {
  34350. "type": "object",
  34351. "properties": {
  34352. "email": {
  34353. "type": "string",
  34354. "description": "Email address for support.",
  34355. "format": "email"
  34356. },
  34357. "issues": {
  34358. "type": "string",
  34359. "description": "URL to the issue tracker.",
  34360. "format": "uri"
  34361. },
  34362. "forum": {
  34363. "type": "string",
  34364. "description": "URL to the forum.",
  34365. "format": "uri"
  34366. },
  34367. "wiki": {
  34368. "type": "string",
  34369. "description": "URL to the wiki.",
  34370. "format": "uri"
  34371. },
  34372. "irc": {
  34373. "type": "string",
  34374. "description": "IRC channel for support, as irc://server/channel.",
  34375. "format": "uri"
  34376. },
  34377. "chat": {
  34378. "type": "string",
  34379. "description": "URL to the support chat.",
  34380. "format": "uri"
  34381. },
  34382. "source": {
  34383. "type": "string",
  34384. "description": "URL to browse or download the sources.",
  34385. "format": "uri"
  34386. },
  34387. "docs": {
  34388. "type": "string",
  34389. "description": "URL to the documentation.",
  34390. "format": "uri"
  34391. },
  34392. "rss": {
  34393. "type": "string",
  34394. "description": "URL to the RSS feed.",
  34395. "format": "uri"
  34396. }
  34397. }
  34398. },
  34399. "funding": {
  34400. "type": "array",
  34401. "description": "A list of options to fund the development and maintenance of the package.",
  34402. "items": {
  34403. "type": "object",
  34404. "properties": {
  34405. "type": {
  34406. "type": "string",
  34407. "description": "Type of funding or platform through which funding is possible."
  34408. },
  34409. "url": {
  34410. "type": "string",
  34411. "description": "URL to a website with details on funding and a way to fund the package.",
  34412. "format": "uri"
  34413. }
  34414. }
  34415. }
  34416. },
  34417. "non-feature-branches": {
  34418. "type": ["array"],
  34419. "description": "A set of string or regex patterns for non-numeric branch names that will not be handled as feature branches.",
  34420. "items": {
  34421. "type": "string"
  34422. }
  34423. },
  34424. "default-branch": {
  34425. "type": ["boolean"],
  34426. "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."
  34427. },
  34428. "abandoned": {
  34429. "type": ["boolean", "string"],
  34430. "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."
  34431. },
  34432. "_comment": {
  34433. "type": ["array", "string"],
  34434. "description": "A key to store comments in"
  34435. }
  34436. },
  34437. "definitions": {
  34438. "authors": {
  34439. "type": "array",
  34440. "description": "List of authors that contributed to the package. This is typically the main maintainers, not the full list.",
  34441. "items": {
  34442. "type": "object",
  34443. "additionalProperties": false,
  34444. "required": [ "name"],
  34445. "properties": {
  34446. "name": {
  34447. "type": "string",
  34448. "description": "Full name of the author."
  34449. },
  34450. "email": {
  34451. "type": "string",
  34452. "description": "Email address of the author.",
  34453. "format": "email"
  34454. },
  34455. "homepage": {
  34456. "type": "string",
  34457. "description": "Homepage URL for the author.",
  34458. "format": "uri"
  34459. },
  34460. "role": {
  34461. "type": "string",
  34462. "description": "Author's role in the project."
  34463. }
  34464. }
  34465. }
  34466. },
  34467. "autoload": {
  34468. "type": "object",
  34469. "description": "Description of how the package can be autoloaded.",
  34470. "properties": {
  34471. "psr-0": {
  34472. "type": "object",
  34473. "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.",
  34474. "additionalProperties": {
  34475. "type": ["string", "array"],
  34476. "items": {
  34477. "type": "string"
  34478. }
  34479. }
  34480. },
  34481. "psr-4": {
  34482. "type": "object",
  34483. "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.",
  34484. "additionalProperties": {
  34485. "type": ["string", "array"],
  34486. "items": {
  34487. "type": "string"
  34488. }
  34489. }
  34490. },
  34491. "classmap": {
  34492. "type": "array",
  34493. "description": "This is an array of paths that contain classes to be included in the class-map generation process."
  34494. },
  34495. "files": {
  34496. "type": "array",
  34497. "description": "This is an array of files that are always required on every request."
  34498. },
  34499. "exclude-from-classmap": {
  34500. "type": "array",
  34501. "description": "This is an array of patterns to exclude from autoload classmap generation. (e.g. \"exclude-from-classmap\": [\"/test/\", \"/tests/\", \"/Tests/\"]"
  34502. }
  34503. }
  34504. },
  34505. "repository": {
  34506. "type": "object",
  34507. "anyOf": [
  34508. { "$ref": "#/definitions/composer-repository" },
  34509. { "$ref": "#/definitions/vcs-repository" },
  34510. { "$ref": "#/definitions/path-repository" },
  34511. { "$ref": "#/definitions/artifact-repository" },
  34512. { "$ref": "#/definitions/pear-repository" },
  34513. { "$ref": "#/definitions/package-repository" }
  34514. ]
  34515. },
  34516. "composer-repository": {
  34517. "type": "object",
  34518. "required": ["type", "url"],
  34519. "properties": {
  34520. "type": { "type": "string", "enum": ["composer"] },
  34521. "url": { "type": "string" },
  34522. "canonical": { "type": "boolean" },
  34523. "only": {
  34524. "type": "array",
  34525. "items": {
  34526. "type": "string"
  34527. }
  34528. },
  34529. "exclude": {
  34530. "type": "array",
  34531. "items": {
  34532. "type": "string"
  34533. }
  34534. },
  34535. "options": {
  34536. "type": "object",
  34537. "additionalProperties": true
  34538. },
  34539. "allow_ssl_downgrade": { "type": "boolean" },
  34540. "force-lazy-providers": { "type": "boolean" }
  34541. }
  34542. },
  34543. "vcs-repository": {
  34544. "type": "object",
  34545. "required": ["type", "url"],
  34546. "properties": {
  34547. "type": { "type": "string", "enum": ["vcs", "github", "git", "gitlab", "git-bitbucket", "hg", "hg-bitbucket", "fossil", "perforce", "svn"] },
  34548. "url": { "type": "string" },
  34549. "canonical": { "type": "boolean" },
  34550. "only": {
  34551. "type": "array",
  34552. "items": {
  34553. "type": "string"
  34554. }
  34555. },
  34556. "exclude": {
  34557. "type": "array",
  34558. "items": {
  34559. "type": "string"
  34560. }
  34561. },
  34562. "no-api": { "type": "boolean" },
  34563. "secure-http": { "type": "boolean" },
  34564. "svn-cache-credentials": { "type": "boolean" },
  34565. "trunk-path": { "type": ["string", "boolean"] },
  34566. "branches-path": { "type": ["string", "boolean"] },
  34567. "tags-path": { "type": ["string", "boolean"] },
  34568. "package-path": { "type": "string" },
  34569. "depot": { "type": "string" },
  34570. "branch": { "type": "string" },
  34571. "unique_perforce_client_name": { "type": "string" },
  34572. "p4user": { "type": "string" },
  34573. "p4password": { "type": "string" }
  34574. }
  34575. },
  34576. "path-repository": {
  34577. "type": "object",
  34578. "required": ["type", "url"],
  34579. "properties": {
  34580. "type": { "type": "string", "enum": ["path"] },
  34581. "url": { "type": "string" },
  34582. "canonical": { "type": "boolean" },
  34583. "only": {
  34584. "type": "array",
  34585. "items": {
  34586. "type": "string"
  34587. }
  34588. },
  34589. "exclude": {
  34590. "type": "array",
  34591. "items": {
  34592. "type": "string"
  34593. }
  34594. },
  34595. "options": {
  34596. "type": "object",
  34597. "properties": {
  34598. "symlink": { "type": ["boolean", "null"] }
  34599. },
  34600. "additionalProperties": true
  34601. }
  34602. }
  34603. },
  34604. "artifact-repository": {
  34605. "type": "object",
  34606. "required": ["type", "url"],
  34607. "properties": {
  34608. "type": { "type": "string", "enum": ["artifact"] },
  34609. "url": { "type": "string" },
  34610. "canonical": { "type": "boolean" },
  34611. "only": {
  34612. "type": "array",
  34613. "items": {
  34614. "type": "string"
  34615. }
  34616. },
  34617. "exclude": {
  34618. "type": "array",
  34619. "items": {
  34620. "type": "string"
  34621. }
  34622. }
  34623. }
  34624. },
  34625. "pear-repository": {
  34626. "type": "object",
  34627. "required": ["type", "url"],
  34628. "properties": {
  34629. "type": { "type": "string", "enum": ["pear"] },
  34630. "url": { "type": "string" },
  34631. "canonical": { "type": "boolean" },
  34632. "only": {
  34633. "type": "array",
  34634. "items": {
  34635. "type": "string"
  34636. }
  34637. },
  34638. "exclude": {
  34639. "type": "array",
  34640. "items": {
  34641. "type": "string"
  34642. }
  34643. },
  34644. "vendor-alias": { "type": "string" }
  34645. }
  34646. },
  34647. "package-repository": {
  34648. "type": "object",
  34649. "required": ["type", "package"],
  34650. "properties": {
  34651. "type": { "type": "string", "enum": ["package"] },
  34652. "canonical": { "type": "boolean" },
  34653. "only": {
  34654. "type": "array",
  34655. "items": {
  34656. "type": "string"
  34657. }
  34658. },
  34659. "exclude": {
  34660. "type": "array",
  34661. "items": {
  34662. "type": "string"
  34663. }
  34664. },
  34665. "package": {
  34666. "oneOf": [
  34667. { "$ref": "#/definitions/inline-package" },
  34668. {
  34669. "type": "array",
  34670. "items": { "$ref": "#/definitions/inline-package" }
  34671. }
  34672. ]
  34673. }
  34674. }
  34675. },
  34676. "inline-package": {
  34677. "type": "object",
  34678. "required": ["name", "version"],
  34679. "properties": {
  34680. "name": {
  34681. "type": "string",
  34682. "description": "Package name, including 'vendor-name/' prefix."
  34683. },
  34684. "type": {
  34685. "type": "string"
  34686. },
  34687. "target-dir": {
  34688. "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.",
  34689. "type": "string"
  34690. },
  34691. "description": {
  34692. "type": "string"
  34693. },
  34694. "keywords": {
  34695. "type": "array",
  34696. "items": {
  34697. "type": "string"
  34698. }
  34699. },
  34700. "homepage": {
  34701. "type": "string",
  34702. "format": "uri"
  34703. },
  34704. "version": {
  34705. "type": "string"
  34706. },
  34707. "time": {
  34708. "type": "string"
  34709. },
  34710. "license": {
  34711. "type": [
  34712. "string",
  34713. "array"
  34714. ]
  34715. },
  34716. "authors": {
  34717. "$ref": "#/definitions/authors"
  34718. },
  34719. "require": {
  34720. "type": "object",
  34721. "additionalProperties": {
  34722. "type": "string"
  34723. }
  34724. },
  34725. "replace": {
  34726. "type": "object",
  34727. "additionalProperties": {
  34728. "type": "string"
  34729. }
  34730. },
  34731. "conflict": {
  34732. "type": "object",
  34733. "additionalProperties": {
  34734. "type": "string"
  34735. }
  34736. },
  34737. "provide": {
  34738. "type": "object",
  34739. "additionalProperties": {
  34740. "type": "string"
  34741. }
  34742. },
  34743. "require-dev": {
  34744. "type": "object",
  34745. "additionalProperties": {
  34746. "type": "string"
  34747. }
  34748. },
  34749. "suggest": {
  34750. "type": "object",
  34751. "additionalProperties": {
  34752. "type": "string"
  34753. }
  34754. },
  34755. "extra": {
  34756. "type": ["object", "array"],
  34757. "additionalProperties": true
  34758. },
  34759. "autoload": {
  34760. "$ref": "#/definitions/autoload"
  34761. },
  34762. "archive": {
  34763. "type": ["object"],
  34764. "properties": {
  34765. "exclude": {
  34766. "type": "array"
  34767. }
  34768. }
  34769. },
  34770. "bin": {
  34771. "type": ["string", "array"],
  34772. "description": "A set of files, or a single file, that should be treated as binaries and symlinked into bin-dir (from config).",
  34773. "items": {
  34774. "type": "string"
  34775. }
  34776. },
  34777. "include-path": {
  34778. "type": ["array"],
  34779. "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.",
  34780. "items": {
  34781. "type": "string"
  34782. }
  34783. },
  34784. "source": {
  34785. "type": "object",
  34786. "required": ["type", "url", "reference"],
  34787. "properties": {
  34788. "type": {
  34789. "type": "string"
  34790. },
  34791. "url": {
  34792. "type": "string"
  34793. },
  34794. "reference": {
  34795. "type": "string"
  34796. },
  34797. "mirrors": {
  34798. "type": "array"
  34799. }
  34800. }
  34801. },
  34802. "dist": {
  34803. "type": "object",
  34804. "required": ["type", "url"],
  34805. "properties": {
  34806. "type": {
  34807. "type": "string"
  34808. },
  34809. "url": {
  34810. "type": "string"
  34811. },
  34812. "reference": {
  34813. "type": "string"
  34814. },
  34815. "shasum": {
  34816. "type": "string"
  34817. },
  34818. "mirrors": {
  34819. "type": "array"
  34820. }
  34821. }
  34822. }
  34823. },
  34824. "additionalProperties": true
  34825. }
  34826. }
  34827. }
  34828. <?php
  34829. require_once __DIR__ . '/composer/autoload_real.php';
  34830. return ComposerAutoloaderInitComposerPhar1611760167::getLoader();
  34831. <?php
  34832. namespace Composer\Autoload;
  34833. class ClassLoader
  34834. {
  34835. private $vendorDir;
  34836. private $prefixLengthsPsr4 = array();
  34837. private $prefixDirsPsr4 = array();
  34838. private $fallbackDirsPsr4 = array();
  34839. private $prefixesPsr0 = array();
  34840. private $fallbackDirsPsr0 = array();
  34841. private $useIncludePath = false;
  34842. private $classMap = array();
  34843. private $classMapAuthoritative = false;
  34844. private $missingClasses = array();
  34845. private $apcuPrefix;
  34846. private static $registeredLoaders = array();
  34847. public function __construct($vendorDir = null)
  34848. {
  34849. $this->vendorDir = $vendorDir;
  34850. }
  34851. public function getPrefixes()
  34852. {
  34853. if (!empty($this->prefixesPsr0)) {
  34854. return call_user_func_array('array_merge', array_values($this->prefixesPsr0));
  34855. }
  34856. return array();
  34857. }
  34858. public function getPrefixesPsr4()
  34859. {
  34860. return $this->prefixDirsPsr4;
  34861. }
  34862. public function getFallbackDirs()
  34863. {
  34864. return $this->fallbackDirsPsr0;
  34865. }
  34866. public function getFallbackDirsPsr4()
  34867. {
  34868. return $this->fallbackDirsPsr4;
  34869. }
  34870. public function getClassMap()
  34871. {
  34872. return $this->classMap;
  34873. }
  34874. public function addClassMap(array $classMap)
  34875. {
  34876. if ($this->classMap) {
  34877. $this->classMap = array_merge($this->classMap, $classMap);
  34878. } else {
  34879. $this->classMap = $classMap;
  34880. }
  34881. }
  34882. public function add($prefix, $paths, $prepend = false)
  34883. {
  34884. if (!$prefix) {
  34885. if ($prepend) {
  34886. $this->fallbackDirsPsr0 = array_merge(
  34887. (array) $paths,
  34888. $this->fallbackDirsPsr0
  34889. );
  34890. } else {
  34891. $this->fallbackDirsPsr0 = array_merge(
  34892. $this->fallbackDirsPsr0,
  34893. (array) $paths
  34894. );
  34895. }
  34896. return;
  34897. }
  34898. $first = $prefix[0];
  34899. if (!isset($this->prefixesPsr0[$first][$prefix])) {
  34900. $this->prefixesPsr0[$first][$prefix] = (array) $paths;
  34901. return;
  34902. }
  34903. if ($prepend) {
  34904. $this->prefixesPsr0[$first][$prefix] = array_merge(
  34905. (array) $paths,
  34906. $this->prefixesPsr0[$first][$prefix]
  34907. );
  34908. } else {
  34909. $this->prefixesPsr0[$first][$prefix] = array_merge(
  34910. $this->prefixesPsr0[$first][$prefix],
  34911. (array) $paths
  34912. );
  34913. }
  34914. }
  34915. public function addPsr4($prefix, $paths, $prepend = false)
  34916. {
  34917. if (!$prefix) {
  34918. if ($prepend) {
  34919. $this->fallbackDirsPsr4 = array_merge(
  34920. (array) $paths,
  34921. $this->fallbackDirsPsr4
  34922. );
  34923. } else {
  34924. $this->fallbackDirsPsr4 = array_merge(
  34925. $this->fallbackDirsPsr4,
  34926. (array) $paths
  34927. );
  34928. }
  34929. } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
  34930. $length = strlen($prefix);
  34931. if ('\\' !== $prefix[$length - 1]) {
  34932. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  34933. }
  34934. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  34935. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  34936. } elseif ($prepend) {
  34937. $this->prefixDirsPsr4[$prefix] = array_merge(
  34938. (array) $paths,
  34939. $this->prefixDirsPsr4[$prefix]
  34940. );
  34941. } else {
  34942. $this->prefixDirsPsr4[$prefix] = array_merge(
  34943. $this->prefixDirsPsr4[$prefix],
  34944. (array) $paths
  34945. );
  34946. }
  34947. }
  34948. public function set($prefix, $paths)
  34949. {
  34950. if (!$prefix) {
  34951. $this->fallbackDirsPsr0 = (array) $paths;
  34952. } else {
  34953. $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
  34954. }
  34955. }
  34956. public function setPsr4($prefix, $paths)
  34957. {
  34958. if (!$prefix) {
  34959. $this->fallbackDirsPsr4 = (array) $paths;
  34960. } else {
  34961. $length = strlen($prefix);
  34962. if ('\\' !== $prefix[$length - 1]) {
  34963. throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
  34964. }
  34965. $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
  34966. $this->prefixDirsPsr4[$prefix] = (array) $paths;
  34967. }
  34968. }
  34969. public function setUseIncludePath($useIncludePath)
  34970. {
  34971. $this->useIncludePath = $useIncludePath;
  34972. }
  34973. public function getUseIncludePath()
  34974. {
  34975. return $this->useIncludePath;
  34976. }
  34977. public function setClassMapAuthoritative($classMapAuthoritative)
  34978. {
  34979. $this->classMapAuthoritative = $classMapAuthoritative;
  34980. }
  34981. public function isClassMapAuthoritative()
  34982. {
  34983. return $this->classMapAuthoritative;
  34984. }
  34985. public function setApcuPrefix($apcuPrefix)
  34986. {
  34987. $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
  34988. }
  34989. public function getApcuPrefix()
  34990. {
  34991. return $this->apcuPrefix;
  34992. }
  34993. public function register($prepend = false)
  34994. {
  34995. spl_autoload_register(array($this, 'loadClass'), true, $prepend);
  34996. if (null === $this->vendorDir) {
  34997. } elseif ($prepend) {
  34998. self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders;
  34999. } else {
  35000. unset(self::$registeredLoaders[$this->vendorDir]);
  35001. self::$registeredLoaders[$this->vendorDir] = $this;
  35002. }
  35003. }
  35004. public function unregister()
  35005. {
  35006. spl_autoload_unregister(array($this, 'loadClass'));
  35007. if (null !== $this->vendorDir) {
  35008. unset(self::$registeredLoaders[$this->vendorDir]);
  35009. }
  35010. }
  35011. public function loadClass($class)
  35012. {
  35013. if ($file = $this->findFile($class)) {
  35014. includeFile($file);
  35015. return true;
  35016. }
  35017. }
  35018. public function findFile($class)
  35019. {
  35020. if (isset($this->classMap[$class])) {
  35021. return $this->classMap[$class];
  35022. }
  35023. if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
  35024. return false;
  35025. }
  35026. if (null !== $this->apcuPrefix) {
  35027. $file = apcu_fetch($this->apcuPrefix.$class, $hit);
  35028. if ($hit) {
  35029. return $file;
  35030. }
  35031. }
  35032. $file = $this->findFileWithExtension($class, '.php');
  35033. if (false === $file && defined('HHVM_VERSION')) {
  35034. $file = $this->findFileWithExtension($class, '.hh');
  35035. }
  35036. if (null !== $this->apcuPrefix) {
  35037. apcu_add($this->apcuPrefix.$class, $file);
  35038. }
  35039. if (false === $file) {
  35040. $this->missingClasses[$class] = true;
  35041. }
  35042. return $file;
  35043. }
  35044. public static function getRegisteredLoaders()
  35045. {
  35046. return self::$registeredLoaders;
  35047. }
  35048. private function findFileWithExtension($class, $ext)
  35049. {
  35050. $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
  35051. $first = $class[0];
  35052. if (isset($this->prefixLengthsPsr4[$first])) {
  35053. $subPath = $class;
  35054. while (false !== $lastPos = strrpos($subPath, '\\')) {
  35055. $subPath = substr($subPath, 0, $lastPos);
  35056. $search = $subPath . '\\';
  35057. if (isset($this->prefixDirsPsr4[$search])) {
  35058. $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
  35059. foreach ($this->prefixDirsPsr4[$search] as $dir) {
  35060. if (file_exists($file = $dir . $pathEnd)) {
  35061. return $file;
  35062. }
  35063. }
  35064. }
  35065. }
  35066. }
  35067. foreach ($this->fallbackDirsPsr4 as $dir) {
  35068. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
  35069. return $file;
  35070. }
  35071. }
  35072. if (false !== $pos = strrpos($class, '\\')) {
  35073. $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
  35074. . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
  35075. } else {
  35076. $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
  35077. }
  35078. if (isset($this->prefixesPsr0[$first])) {
  35079. foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
  35080. if (0 === strpos($class, $prefix)) {
  35081. foreach ($dirs as $dir) {
  35082. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  35083. return $file;
  35084. }
  35085. }
  35086. }
  35087. }
  35088. }
  35089. foreach ($this->fallbackDirsPsr0 as $dir) {
  35090. if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
  35091. return $file;
  35092. }
  35093. }
  35094. if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
  35095. return $file;
  35096. }
  35097. return false;
  35098. }
  35099. }
  35100. function includeFile($file)
  35101. {
  35102. include $file;
  35103. }
  35104. <?php
  35105. namespace Composer;
  35106. use Composer\Autoload\ClassLoader;
  35107. use Composer\Semver\VersionParser;
  35108. class InstalledVersions
  35109. {
  35110. private static $installed = array (
  35111. 'root' =>
  35112. array (
  35113. 'pretty_version' => '2.0.9',
  35114. 'version' => '2.0.9.0',
  35115. 'aliases' =>
  35116. array (
  35117. ),
  35118. 'reference' => '591c2c155cac0d2d7f34af41d3b1e29bcbfc685e',
  35119. 'name' => 'composer/composer',
  35120. ),
  35121. 'versions' =>
  35122. array (
  35123. 'composer/ca-bundle' =>
  35124. array (
  35125. 'pretty_version' => '1.2.9',
  35126. 'version' => '1.2.9.0',
  35127. 'aliases' =>
  35128. array (
  35129. ),
  35130. 'reference' => '78a0e288fdcebf92aa2318a8d3656168da6ac1a5',
  35131. ),
  35132. 'composer/composer' =>
  35133. array (
  35134. 'pretty_version' => '2.0.9',
  35135. 'version' => '2.0.9.0',
  35136. 'aliases' =>
  35137. array (
  35138. ),
  35139. 'reference' => '591c2c155cac0d2d7f34af41d3b1e29bcbfc685e',
  35140. ),
  35141. 'composer/semver' =>
  35142. array (
  35143. 'pretty_version' => '3.2.4',
  35144. 'version' => '3.2.4.0',
  35145. 'aliases' =>
  35146. array (
  35147. ),
  35148. 'reference' => 'a02fdf930a3c1c3ed3a49b5f63859c0c20e10464',
  35149. ),
  35150. 'composer/spdx-licenses' =>
  35151. array (
  35152. 'pretty_version' => '1.5.5',
  35153. 'version' => '1.5.5.0',
  35154. 'aliases' =>
  35155. array (
  35156. ),
  35157. 'reference' => 'de30328a7af8680efdc03e396aad24befd513200',
  35158. ),
  35159. 'composer/xdebug-handler' =>
  35160. array (
  35161. 'pretty_version' => '1.4.5',
  35162. 'version' => '1.4.5.0',
  35163. 'aliases' =>
  35164. array (
  35165. ),
  35166. 'reference' => 'f28d44c286812c714741478d968104c5e604a1d4',
  35167. ),
  35168. 'justinrainbow/json-schema' =>
  35169. array (
  35170. 'pretty_version' => '5.2.10',
  35171. 'version' => '5.2.10.0',
  35172. 'aliases' =>
  35173. array (
  35174. ),
  35175. 'reference' => '2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b',
  35176. ),
  35177. 'psr/log' =>
  35178. array (
  35179. 'pretty_version' => '1.1.3',
  35180. 'version' => '1.1.3.0',
  35181. 'aliases' =>
  35182. array (
  35183. ),
  35184. 'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
  35185. ),
  35186. 'react/promise' =>
  35187. array (
  35188. 'pretty_version' => 'v1.2.1',
  35189. 'version' => '1.2.1.0',
  35190. 'aliases' =>
  35191. array (
  35192. ),
  35193. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  35194. ),
  35195. 'seld/jsonlint' =>
  35196. array (
  35197. 'pretty_version' => '1.8.3',
  35198. 'version' => '1.8.3.0',
  35199. 'aliases' =>
  35200. array (
  35201. ),
  35202. 'reference' => '9ad6ce79c342fbd44df10ea95511a1b24dee5b57',
  35203. ),
  35204. 'seld/phar-utils' =>
  35205. array (
  35206. 'pretty_version' => '1.1.1',
  35207. 'version' => '1.1.1.0',
  35208. 'aliases' =>
  35209. array (
  35210. ),
  35211. 'reference' => '8674b1d84ffb47cc59a101f5d5a3b61e87d23796',
  35212. ),
  35213. 'symfony/console' =>
  35214. array (
  35215. 'pretty_version' => 'v2.8.52',
  35216. 'version' => '2.8.52.0',
  35217. 'aliases' =>
  35218. array (
  35219. ),
  35220. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  35221. ),
  35222. 'symfony/debug' =>
  35223. array (
  35224. 'pretty_version' => 'v2.8.52',
  35225. 'version' => '2.8.52.0',
  35226. 'aliases' =>
  35227. array (
  35228. ),
  35229. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  35230. ),
  35231. 'symfony/filesystem' =>
  35232. array (
  35233. 'pretty_version' => 'v2.8.52',
  35234. 'version' => '2.8.52.0',
  35235. 'aliases' =>
  35236. array (
  35237. ),
  35238. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  35239. ),
  35240. 'symfony/finder' =>
  35241. array (
  35242. 'pretty_version' => 'v2.8.52',
  35243. 'version' => '2.8.52.0',
  35244. 'aliases' =>
  35245. array (
  35246. ),
  35247. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  35248. ),
  35249. 'symfony/polyfill-ctype' =>
  35250. array (
  35251. 'pretty_version' => 'v1.19.0',
  35252. 'version' => '1.19.0.0',
  35253. 'aliases' =>
  35254. array (
  35255. ),
  35256. 'reference' => 'aed596913b70fae57be53d86faa2e9ef85a2297b',
  35257. ),
  35258. 'symfony/polyfill-mbstring' =>
  35259. array (
  35260. 'pretty_version' => 'v1.19.0',
  35261. 'version' => '1.19.0.0',
  35262. 'aliases' =>
  35263. array (
  35264. ),
  35265. 'reference' => 'b5f7b932ee6fa802fc792eabd77c4c88084517ce',
  35266. ),
  35267. 'symfony/process' =>
  35268. array (
  35269. 'pretty_version' => 'v2.8.52',
  35270. 'version' => '2.8.52.0',
  35271. 'aliases' =>
  35272. array (
  35273. ),
  35274. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  35275. ),
  35276. ),
  35277. );
  35278. private static $canGetVendors;
  35279. private static $installedByVendor = array();
  35280. public static function getInstalledPackages()
  35281. {
  35282. $packages = array();
  35283. foreach (self::getInstalled() as $installed) {
  35284. $packages[] = array_keys($installed['versions']);
  35285. }
  35286. if (1 === \count($packages)) {
  35287. return $packages[0];
  35288. }
  35289. return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
  35290. }
  35291. public static function isInstalled($packageName)
  35292. {
  35293. foreach (self::getInstalled() as $installed) {
  35294. if (isset($installed['versions'][$packageName])) {
  35295. return true;
  35296. }
  35297. }
  35298. return false;
  35299. }
  35300. public static function satisfies(VersionParser $parser, $packageName, $constraint)
  35301. {
  35302. $constraint = $parser->parseConstraints($constraint);
  35303. $provided = $parser->parseConstraints(self::getVersionRanges($packageName));
  35304. return $provided->matches($constraint);
  35305. }
  35306. public static function getVersionRanges($packageName)
  35307. {
  35308. foreach (self::getInstalled() as $installed) {
  35309. if (!isset($installed['versions'][$packageName])) {
  35310. continue;
  35311. }
  35312. $ranges = array();
  35313. if (isset($installed['versions'][$packageName]['pretty_version'])) {
  35314. $ranges[] = $installed['versions'][$packageName]['pretty_version'];
  35315. }
  35316. if (array_key_exists('aliases', $installed['versions'][$packageName])) {
  35317. $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
  35318. }
  35319. if (array_key_exists('replaced', $installed['versions'][$packageName])) {
  35320. $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
  35321. }
  35322. if (array_key_exists('provided', $installed['versions'][$packageName])) {
  35323. $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
  35324. }
  35325. return implode(' || ', $ranges);
  35326. }
  35327. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35328. }
  35329. public static function getVersion($packageName)
  35330. {
  35331. foreach (self::getInstalled() as $installed) {
  35332. if (!isset($installed['versions'][$packageName])) {
  35333. continue;
  35334. }
  35335. if (!isset($installed['versions'][$packageName]['version'])) {
  35336. return null;
  35337. }
  35338. return $installed['versions'][$packageName]['version'];
  35339. }
  35340. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35341. }
  35342. public static function getPrettyVersion($packageName)
  35343. {
  35344. foreach (self::getInstalled() as $installed) {
  35345. if (!isset($installed['versions'][$packageName])) {
  35346. continue;
  35347. }
  35348. if (!isset($installed['versions'][$packageName]['pretty_version'])) {
  35349. return null;
  35350. }
  35351. return $installed['versions'][$packageName]['pretty_version'];
  35352. }
  35353. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35354. }
  35355. public static function getReference($packageName)
  35356. {
  35357. foreach (self::getInstalled() as $installed) {
  35358. if (!isset($installed['versions'][$packageName])) {
  35359. continue;
  35360. }
  35361. if (!isset($installed['versions'][$packageName]['reference'])) {
  35362. return null;
  35363. }
  35364. return $installed['versions'][$packageName]['reference'];
  35365. }
  35366. throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
  35367. }
  35368. public static function getRootPackage()
  35369. {
  35370. $installed = self::getInstalled();
  35371. return $installed[0]['root'];
  35372. }
  35373. public static function getRawData()
  35374. {
  35375. return self::$installed;
  35376. }
  35377. public static function reload($data)
  35378. {
  35379. self::$installed = $data;
  35380. self::$installedByVendor = array();
  35381. }
  35382. private static function getInstalled()
  35383. {
  35384. if (null === self::$canGetVendors) {
  35385. self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
  35386. }
  35387. $installed = array();
  35388. if (self::$canGetVendors) {
  35389. foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
  35390. if (isset(self::$installedByVendor[$vendorDir])) {
  35391. $installed[] = self::$installedByVendor[$vendorDir];
  35392. } elseif (is_file($vendorDir.'/composer/installed.php')) {
  35393. $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
  35394. }
  35395. }
  35396. }
  35397. $installed[] = self::$installed;
  35398. return $installed;
  35399. }
  35400. }
  35401. <?php
  35402. $vendorDir = dirname(dirname(__FILE__));
  35403. $baseDir = dirname($vendorDir);
  35404. return array(
  35405. 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php',
  35406. );
  35407. <?php
  35408. $vendorDir = dirname(dirname(__FILE__));
  35409. $baseDir = dirname($vendorDir);
  35410. return array(
  35411. '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
  35412. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
  35413. '7844cce90d4037f1a077c08319eef109' => $vendorDir . '/react/promise/src/React/Promise/functions_include.php',
  35414. );
  35415. <?php
  35416. $vendorDir = dirname(dirname(__FILE__));
  35417. $baseDir = dirname($vendorDir);
  35418. return array(
  35419. 'React\\Promise' => array($vendorDir . '/react/promise/src'),
  35420. );
  35421. <?php
  35422. $vendorDir = dirname(dirname(__FILE__));
  35423. $baseDir = dirname($vendorDir);
  35424. return array(
  35425. 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
  35426. 'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
  35427. 'Symfony\\Component\\Process\\' => array($vendorDir . '/symfony/process'),
  35428. 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'),
  35429. 'Symfony\\Component\\Filesystem\\' => array($vendorDir . '/symfony/filesystem'),
  35430. 'Symfony\\Component\\Debug\\' => array($vendorDir . '/symfony/debug'),
  35431. 'Symfony\\Component\\Console\\' => array($vendorDir . '/symfony/console'),
  35432. 'Seld\\PharUtils\\' => array($vendorDir . '/seld/phar-utils/src'),
  35433. 'Seld\\JsonLint\\' => array($vendorDir . '/seld/jsonlint/src/Seld/JsonLint'),
  35434. 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
  35435. 'JsonSchema\\' => array($vendorDir . '/justinrainbow/json-schema/src/JsonSchema'),
  35436. 'Composer\\XdebugHandler\\' => array($vendorDir . '/composer/xdebug-handler/src'),
  35437. 'Composer\\Spdx\\' => array($vendorDir . '/composer/spdx-licenses/src'),
  35438. 'Composer\\Semver\\' => array($vendorDir . '/composer/semver/src'),
  35439. 'Composer\\CaBundle\\' => array($vendorDir . '/composer/ca-bundle/src'),
  35440. 'Composer\\' => array($baseDir . '/src/Composer'),
  35441. );
  35442. <?php
  35443. class ComposerAutoloaderInitComposerPhar1611760167
  35444. {
  35445. private static $loader;
  35446. public static function loadClassLoader($class)
  35447. {
  35448. if ('Composer\Autoload\ClassLoader' === $class) {
  35449. require __DIR__ . '/ClassLoader.php';
  35450. }
  35451. }
  35452. public static function getLoader()
  35453. {
  35454. if (null !== self::$loader) {
  35455. return self::$loader;
  35456. }
  35457. spl_autoload_register(array('ComposerAutoloaderInitComposerPhar1611760167', 'loadClassLoader'), true, true);
  35458. self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
  35459. spl_autoload_unregister(array('ComposerAutoloaderInitComposerPhar1611760167', 'loadClassLoader'));
  35460. $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
  35461. if ($useStaticLoader) {
  35462. require __DIR__ . '/autoload_static.php';
  35463. call_user_func(\Composer\Autoload\ComposerStaticInitComposerPhar1611760167::getInitializer($loader));
  35464. } else {
  35465. $map = require __DIR__ . '/autoload_namespaces.php';
  35466. foreach ($map as $namespace => $path) {
  35467. $loader->set($namespace, $path);
  35468. }
  35469. $map = require __DIR__ . '/autoload_psr4.php';
  35470. foreach ($map as $namespace => $path) {
  35471. $loader->setPsr4($namespace, $path);
  35472. }
  35473. $classMap = require __DIR__ . '/autoload_classmap.php';
  35474. if ($classMap) {
  35475. $loader->addClassMap($classMap);
  35476. }
  35477. }
  35478. $loader->register(true);
  35479. if ($useStaticLoader) {
  35480. $includeFiles = Composer\Autoload\ComposerStaticInitComposerPhar1611760167::$files;
  35481. } else {
  35482. $includeFiles = require __DIR__ . '/autoload_files.php';
  35483. }
  35484. foreach ($includeFiles as $fileIdentifier => $file) {
  35485. composerRequireComposerPhar1611760167($fileIdentifier, $file);
  35486. }
  35487. return $loader;
  35488. }
  35489. }
  35490. function composerRequireComposerPhar1611760167($fileIdentifier, $file)
  35491. {
  35492. if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  35493. require $file;
  35494. $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
  35495. }
  35496. }
  35497. <?php
  35498. namespace Composer\Autoload;
  35499. class ComposerStaticInitComposerPhar1611760167
  35500. {
  35501. public static $files = array (
  35502. '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
  35503. '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
  35504. '7844cce90d4037f1a077c08319eef109' => __DIR__ . '/..' . '/react/promise/src/React/Promise/functions_include.php',
  35505. );
  35506. public static $prefixLengthsPsr4 = array (
  35507. 'S' =>
  35508. array (
  35509. 'Symfony\\Polyfill\\Mbstring\\' => 26,
  35510. 'Symfony\\Polyfill\\Ctype\\' => 23,
  35511. 'Symfony\\Component\\Process\\' => 26,
  35512. 'Symfony\\Component\\Finder\\' => 25,
  35513. 'Symfony\\Component\\Filesystem\\' => 29,
  35514. 'Symfony\\Component\\Debug\\' => 24,
  35515. 'Symfony\\Component\\Console\\' => 26,
  35516. 'Seld\\PharUtils\\' => 15,
  35517. 'Seld\\JsonLint\\' => 14,
  35518. ),
  35519. 'P' =>
  35520. array (
  35521. 'Psr\\Log\\' => 8,
  35522. ),
  35523. 'J' =>
  35524. array (
  35525. 'JsonSchema\\' => 11,
  35526. ),
  35527. 'C' =>
  35528. array (
  35529. 'Composer\\XdebugHandler\\' => 23,
  35530. 'Composer\\Spdx\\' => 14,
  35531. 'Composer\\Semver\\' => 16,
  35532. 'Composer\\CaBundle\\' => 18,
  35533. 'Composer\\' => 9,
  35534. ),
  35535. );
  35536. public static $prefixDirsPsr4 = array (
  35537. 'Symfony\\Polyfill\\Mbstring\\' =>
  35538. array (
  35539. 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
  35540. ),
  35541. 'Symfony\\Polyfill\\Ctype\\' =>
  35542. array (
  35543. 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
  35544. ),
  35545. 'Symfony\\Component\\Process\\' =>
  35546. array (
  35547. 0 => __DIR__ . '/..' . '/symfony/process',
  35548. ),
  35549. 'Symfony\\Component\\Finder\\' =>
  35550. array (
  35551. 0 => __DIR__ . '/..' . '/symfony/finder',
  35552. ),
  35553. 'Symfony\\Component\\Filesystem\\' =>
  35554. array (
  35555. 0 => __DIR__ . '/..' . '/symfony/filesystem',
  35556. ),
  35557. 'Symfony\\Component\\Debug\\' =>
  35558. array (
  35559. 0 => __DIR__ . '/..' . '/symfony/debug',
  35560. ),
  35561. 'Symfony\\Component\\Console\\' =>
  35562. array (
  35563. 0 => __DIR__ . '/..' . '/symfony/console',
  35564. ),
  35565. 'Seld\\PharUtils\\' =>
  35566. array (
  35567. 0 => __DIR__ . '/..' . '/seld/phar-utils/src',
  35568. ),
  35569. 'Seld\\JsonLint\\' =>
  35570. array (
  35571. 0 => __DIR__ . '/..' . '/seld/jsonlint/src/Seld/JsonLint',
  35572. ),
  35573. 'Psr\\Log\\' =>
  35574. array (
  35575. 0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
  35576. ),
  35577. 'JsonSchema\\' =>
  35578. array (
  35579. 0 => __DIR__ . '/..' . '/justinrainbow/json-schema/src/JsonSchema',
  35580. ),
  35581. 'Composer\\XdebugHandler\\' =>
  35582. array (
  35583. 0 => __DIR__ . '/..' . '/composer/xdebug-handler/src',
  35584. ),
  35585. 'Composer\\Spdx\\' =>
  35586. array (
  35587. 0 => __DIR__ . '/..' . '/composer/spdx-licenses/src',
  35588. ),
  35589. 'Composer\\Semver\\' =>
  35590. array (
  35591. 0 => __DIR__ . '/..' . '/composer/semver/src',
  35592. ),
  35593. 'Composer\\CaBundle\\' =>
  35594. array (
  35595. 0 => __DIR__ . '/..' . '/composer/ca-bundle/src',
  35596. ),
  35597. 'Composer\\' =>
  35598. array (
  35599. 0 => __DIR__ . '/../..' . '/src/Composer',
  35600. ),
  35601. );
  35602. public static $prefixesPsr0 = array (
  35603. 'R' =>
  35604. array (
  35605. 'React\\Promise' =>
  35606. array (
  35607. 0 => __DIR__ . '/..' . '/react/promise/src',
  35608. ),
  35609. ),
  35610. );
  35611. public static $classMap = array (
  35612. 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
  35613. );
  35614. public static function getInitializer(ClassLoader $loader)
  35615. {
  35616. return \Closure::bind(function () use ($loader) {
  35617. $loader->prefixLengthsPsr4 = ComposerStaticInitComposerPhar1611760167::$prefixLengthsPsr4;
  35618. $loader->prefixDirsPsr4 = ComposerStaticInitComposerPhar1611760167::$prefixDirsPsr4;
  35619. $loader->prefixesPsr0 = ComposerStaticInitComposerPhar1611760167::$prefixesPsr0;
  35620. $loader->classMap = ComposerStaticInitComposerPhar1611760167::$classMap;
  35621. }, null, ClassLoader::class);
  35622. }
  35623. }
  35624. Copyright (C) 2016 Composer
  35625. Permission is hereby granted, free of charge, to any person obtaining a copy of
  35626. this software and associated documentation files (the "Software"), to deal in
  35627. the Software without restriction, including without limitation the rights to
  35628. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  35629. of the Software, and to permit persons to whom the Software is furnished to do
  35630. so, subject to the following conditions:
  35631. The above copyright notice and this permission notice shall be included in all
  35632. copies or substantial portions of the Software.
  35633. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  35634. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  35635. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  35636. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  35637. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  35638. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  35639. SOFTWARE.
  35640. ##
  35641. ## Bundle of CA Root Certificates
  35642. ##
  35643. ## Certificate data from Mozilla as of: Tue Dec 8 04:12:05 2020 GMT
  35644. ##
  35645. ## This is a bundle of X.509 certificates of public Certificate Authorities
  35646. ## (CA). These were automatically extracted from Mozilla's root certificates
  35647. ## file (certdata.txt). This file can be found in the mozilla source tree:
  35648. ## https://hg.mozilla.org/releases/mozilla-release/raw-file/default/security/nss/lib/ckfw/builtins/certdata.txt
  35649. ##
  35650. ## It contains the certificates in PEM format and therefore
  35651. ## can be directly used with curl / libcurl / php_curl, or with
  35652. ## an Apache+mod_ssl webserver for SSL client authentication.
  35653. ## Just configure this file as the SSLCACertificateFile.
  35654. ##
  35655. ## Conversion done with mk-ca-bundle.pl version 1.28.
  35656. ## SHA256: d820b8696d8ffe42064a1384a56a8981cdc7e7e198036bbb5fa04a6c282dd9a2
  35657. ##
  35658. GlobalSign Root CA
  35659. ==================
  35660. -----BEGIN CERTIFICATE-----
  35661. MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkGA1UEBhMCQkUx
  35662. GTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jvb3QgQ0ExGzAZBgNVBAMTEkds
  35663. b2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAwMDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNV
  35664. BAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYD
  35665. VQQDExJHbG9iYWxTaWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDa
  35666. DuaZjc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavpxy0Sy6sc
  35667. THAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp1Wrjsok6Vjk4bwY8iGlb
  35668. Kk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdGsnUOhugZitVtbNV4FpWi6cgKOOvyJBNP
  35669. c1STE4U6G7weNLWLBYy5d4ux2x8gkasJU26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrX
  35670. gzT/LCrBbBlDSgeF59N89iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNV
  35671. HRMBAf8EBTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0BAQUF
  35672. AAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOzyj1hTdNGCbM+w6Dj
  35673. Y1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE38NflNUVyRRBnMRddWQVDf9VMOyG
  35674. j/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymPAbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhH
  35675. hm4qxFYxldBniYUr+WymXUadDKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveC
  35676. X4XSQRjbgbMEHMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A==
  35677. -----END CERTIFICATE-----
  35678. GlobalSign Root CA - R2
  35679. =======================
  35680. -----BEGIN CERTIFICATE-----
  35681. MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv
  35682. YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  35683. bFNpZ24wHhcNMDYxMjE1MDgwMDAwWhcNMjExMjE1MDgwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  35684. aWduIFJvb3QgQ0EgLSBSMjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  35685. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKbPJA6+Lm8omUVCxKs+IVSbC9N/hHD6
  35686. ErPLv4dfxn+G07IwXNb9rfF73OX4YJYJkhD10FPe+3t+c4isUoh7SqbKSaZeqKeMWhG8eoLrvozp
  35687. s6yWJQeXSpkqBy+0Hne/ig+1AnwblrjFuTosvNYSuetZfeLQBoZfXklqtTleiDTsvHgMCJiEbKjN
  35688. S7SgfQx5TfC4LcshytVsW33hoCmEofnTlEnLJGKRILzdC9XZzPnqJworc5HGnRusyMvo4KD0L5CL
  35689. TfuwNhv2GXqF4G3yYROIXJ/gkwpRl4pazq+r1feqCapgvdzZX99yqWATXgAByUr6P6TqBwMhAo6C
  35690. ygPCm48CAwEAAaOBnDCBmTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4E
  35691. FgQUm+IHV2ccHsBqBt5ZtJot39wZhi4wNgYDVR0fBC8wLTAroCmgJ4YlaHR0cDovL2NybC5nbG9i
  35692. YWxzaWduLm5ldC9yb290LXIyLmNybDAfBgNVHSMEGDAWgBSb4gdXZxwewGoG3lm0mi3f3BmGLjAN
  35693. BgkqhkiG9w0BAQUFAAOCAQEAmYFThxxol4aR7OBKuEQLq4GsJ0/WwbgcQ3izDJr86iw8bmEbTUsp
  35694. 9Z8FHSbBuOmDAGJFtqkIk7mpM0sYmsL4h4hO291xNBrBVNpGP+DTKqttVCL1OmLNIG+6KYnX3ZHu
  35695. 01yiPqFbQfXf5WRDLenVOavSot+3i9DAgBkcRcAtjOj4LaR0VknFBbVPFd5uRHg5h6h+u/N5GJG7
  35696. 9G+dwfCMNYxdAfvDbbnvRG15RjF+Cv6pgsH/76tuIMRQyV+dTZsXjAzlAcmgQWpzU/qlULRuJQ/7
  35697. TBj0/VLZjmmx6BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==
  35698. -----END CERTIFICATE-----
  35699. Entrust.net Premium 2048 Secure Server CA
  35700. =========================================
  35701. -----BEGIN CERTIFICATE-----
  35702. MIIEKjCCAxKgAwIBAgIEOGPe+DANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UEChMLRW50cnVzdC5u
  35703. ZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9DUFNfMjA0OCBpbmNvcnAuIGJ5IHJlZi4gKGxp
  35704. bWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNV
  35705. BAMTKkVudHJ1c3QubmV0IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ICgyMDQ4KTAeFw05OTEyMjQx
  35706. NzUwNTFaFw0yOTA3MjQxNDE1MTJaMIG0MRQwEgYDVQQKEwtFbnRydXN0Lm5ldDFAMD4GA1UECxQ3
  35707. d3d3LmVudHJ1c3QubmV0L0NQU18yMDQ4IGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl
  35708. MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5u
  35709. ZXQgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgKDIwNDgpMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  35710. MIIBCgKCAQEArU1LqRKGsuqjIAcVFmQqK0vRvwtKTY7tgHalZ7d4QMBzQshowNtTK91euHaYNZOL
  35711. Gp18EzoOH1u3Hs/lJBQesYGpjX24zGtLA/ECDNyrpUAkAH90lKGdCCmziAv1h3edVc3kw37XamSr
  35712. hRSGlVuXMlBvPci6Zgzj/L24ScF2iUkZ/cCovYmjZy/Gn7xxGWC4LeksyZB2ZnuU4q941mVTXTzW
  35713. nLLPKQP5L6RQstRIzgUyVYr9smRMDuSYB3Xbf9+5CFVghTAp+XtIpGmG4zU/HoZdenoVve8AjhUi
  35714. VBcAkCaTvA5JaJG/+EfTnZVCwQ5N328mz8MYIWJmQ3DW1cAH4QIDAQABo0IwQDAOBgNVHQ8BAf8E
  35715. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUVeSB0RGAvtiJuQijMfmhJAkWuXAwDQYJ
  35716. KoZIhvcNAQEFBQADggEBADubj1abMOdTmXx6eadNl9cZlZD7Bh/KM3xGY4+WZiT6QBshJ8rmcnPy
  35717. T/4xmf3IDExoU8aAghOY+rat2l098c5u9hURlIIM7j+VrxGrD9cv3h8Dj1csHsm7mhpElesYT6Yf
  35718. zX1XEC+bBAlahLVu2B064dae0Wx5XnkcFMXj0EyTO2U87d89vqbllRrDtRnDvV5bu/8j72gZyxKT
  35719. J1wDLW8w0B62GqzeWvfRqqgnpv55gcR5mTNXuhKwqeBCbJPKVt7+bYQLCIt+jerXmCHG8+c8eS9e
  35720. nNFMFY3h7CI3zJpDC5fcgJCNs2ebb0gIFVbPv/ErfF6adulZkMV8gzURZVE=
  35721. -----END CERTIFICATE-----
  35722. Baltimore CyberTrust Root
  35723. =========================
  35724. -----BEGIN CERTIFICATE-----
  35725. MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJRTESMBAGA1UE
  35726. ChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYDVQQDExlCYWx0aW1vcmUgQ3li
  35727. ZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoXDTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMC
  35728. SUUxEjAQBgNVBAoTCUJhbHRpbW9yZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFs
  35729. dGltb3JlIEN5YmVyVHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKME
  35730. uyKrmD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjrIZ3AQSsB
  35731. UnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeKmpYcqWe4PwzV9/lSEy/C
  35732. G9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSuXmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9
  35733. XbIGevOF6uvUA65ehD5f/xXtabz5OTZydc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjpr
  35734. l3RjM71oGDHweI12v/yejl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoI
  35735. VDaGezq1BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEB
  35736. BQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT929hkTI7gQCvlYpNRh
  35737. cL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3WgxjkzSswF07r51XgdIGn9w/xZchMB5
  35738. hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsa
  35739. Y71k5h+3zvDyny67G7fyUIhzksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9H
  35740. RCwBXbsdtTLSR9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp
  35741. -----END CERTIFICATE-----
  35742. Entrust Root Certification Authority
  35743. ====================================
  35744. -----BEGIN CERTIFICATE-----
  35745. MIIEkTCCA3mgAwIBAgIERWtQVDANBgkqhkiG9w0BAQUFADCBsDELMAkGA1UEBhMCVVMxFjAUBgNV
  35746. BAoTDUVudHJ1c3QsIEluYy4xOTA3BgNVBAsTMHd3dy5lbnRydXN0Lm5ldC9DUFMgaXMgaW5jb3Jw
  35747. b3JhdGVkIGJ5IHJlZmVyZW5jZTEfMB0GA1UECxMWKGMpIDIwMDYgRW50cnVzdCwgSW5jLjEtMCsG
  35748. A1UEAxMkRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTA2MTEyNzIwMjM0
  35749. MloXDTI2MTEyNzIwNTM0MlowgbAxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMu
  35750. MTkwNwYDVQQLEzB3d3cuZW50cnVzdC5uZXQvQ1BTIGlzIGluY29ycG9yYXRlZCBieSByZWZlcmVu
  35751. Y2UxHzAdBgNVBAsTFihjKSAyMDA2IEVudHJ1c3QsIEluYy4xLTArBgNVBAMTJEVudHJ1c3QgUm9v
  35752. dCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  35753. ALaVtkNC+sZtKm9I35RMOVcF7sN5EUFoNu3s/poBj6E4KPz3EEZmLk0eGrEaTsbRwJWIsMn/MYsz
  35754. A9u3g3s+IIRe7bJWKKf44LlAcTfFy0cOlypowCKVYhXbR9n10Cv/gkvJrT7eTNuQgFA/CYqEAOww
  35755. Cj0Yzfv9KlmaI5UXLEWeH25DeW0MXJj+SKfFI0dcXv1u5x609mhF0YaDW6KKjbHjKYD+JXGIrb68
  35756. j6xSlkuqUY3kEzEZ6E5Nn9uss2rVvDlUccp6en+Q3X0dgNmBu1kmwhH+5pPi94DkZfs0Nw4pgHBN
  35757. rziGLp5/V6+eF67rHMsoIV+2HNjnogQi+dPa2MsCAwEAAaOBsDCBrTAOBgNVHQ8BAf8EBAMCAQYw
  35758. DwYDVR0TAQH/BAUwAwEB/zArBgNVHRAEJDAigA8yMDA2MTEyNzIwMjM0MlqBDzIwMjYxMTI3MjA1
  35759. MzQyWjAfBgNVHSMEGDAWgBRokORnpKZTgMeGZqTx90tD+4S9bTAdBgNVHQ4EFgQUaJDkZ6SmU4DH
  35760. hmak8fdLQ/uEvW0wHQYJKoZIhvZ9B0EABBAwDhsIVjcuMTo0LjADAgSQMA0GCSqGSIb3DQEBBQUA
  35761. A4IBAQCT1DCw1wMgKtD5Y+iRDAUgqV8ZyntyTtSx29CW+1RaGSwMCPeyvIWonX9tO1KzKtvn1ISM
  35762. Y/YPyyYBkVBs9F8U4pN0wBOeMDpQ47RgxRzwIkSNcUesyBrJ6ZuaAGAT/3B+XxFNSRuzFVJ7yVTa
  35763. v52Vr2ua2J7p8eRDjeIRRDq/r72DQnNSi6q7pynP9WQcCk3RvKqsnyrQ/39/2n3qse0wJcGE2jTS
  35764. W3iDVuycNsMm4hH2Z0kdkquM++v/eu6FSqdQgPCnXEqULl8FmTxSQeDNtGPPAUO6nIPcj2A781q0
  35765. tHuu2guQOHXvgR1m0vdXcDazv/wor3ElhVsT/h5/WrQ8
  35766. -----END CERTIFICATE-----
  35767. GeoTrust Global CA
  35768. ==================
  35769. -----BEGIN CERTIFICATE-----
  35770. MIIDVDCCAjygAwIBAgIDAjRWMA0GCSqGSIb3DQEBBQUAMEIxCzAJBgNVBAYTAlVTMRYwFAYDVQQK
  35771. Ew1HZW9UcnVzdCBJbmMuMRswGQYDVQQDExJHZW9UcnVzdCBHbG9iYWwgQ0EwHhcNMDIwNTIxMDQw
  35772. MDAwWhcNMjIwNTIxMDQwMDAwWjBCMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5j
  35773. LjEbMBkGA1UEAxMSR2VvVHJ1c3QgR2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  35774. CgKCAQEA2swYYzD99BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjo
  35775. BbdqfnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDviS2Aelet
  35776. 8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU1XupGc1V3sjs0l44U+Vc
  35777. T4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+bw8HHa8sHo9gOeL6NlMTOdReJivbPagU
  35778. vTLrGAMoUgRx5aszPeE4uwc2hGKceeoWMPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTAD
  35779. AQH/MB0GA1UdDgQWBBTAephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVk
  35780. DBF9qn1luMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKInZ57Q
  35781. zxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfStQWVYrmm3ok9Nns4
  35782. d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcFPseKUgzbFbS9bZvlxrFUaKnjaZC2
  35783. mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Unhw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6p
  35784. XE0zX5IJL4hmXXeXxx12E6nV5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvm
  35785. Mw==
  35786. -----END CERTIFICATE-----
  35787. GeoTrust Universal CA
  35788. =====================
  35789. -----BEGIN CERTIFICATE-----
  35790. MIIFaDCCA1CgAwIBAgIBATANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  35791. R2VvVHJ1c3QgSW5jLjEeMBwGA1UEAxMVR2VvVHJ1c3QgVW5pdmVyc2FsIENBMB4XDTA0MDMwNDA1
  35792. MDAwMFoXDTI5MDMwNDA1MDAwMFowRTELMAkGA1UEBhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IElu
  35793. Yy4xHjAcBgNVBAMTFUdlb1RydXN0IFVuaXZlcnNhbCBDQTCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  35794. ADCCAgoCggIBAKYVVaCjxuAfjJ0hUNfBvitbtaSeodlyWL0AG0y/YckUHUWCq8YdgNY96xCcOq9t
  35795. JPi8cQGeBvV8Xx7BDlXKg5pZMK4ZyzBIle0iN430SppyZj6tlcDgFgDgEB8rMQ7XlFTTQjOgNB0e
  35796. RXbdT8oYN+yFFXoZCPzVx5zw8qkuEKmS5j1YPakWaDwvdSEYfyh3peFhF7em6fgemdtzbvQKoiFs
  35797. 7tqqhZJmr/Z6a4LauiIINQ/PQvE1+mrufislzDoR5G2vc7J2Ha3QsnhnGqQ5HFELZ1aD/ThdDc7d
  35798. 8Lsrlh/eezJS/R27tQahsiFepdaVaH/wmZ7cRQg+59IJDTWU3YBOU5fXtQlEIGQWFwMCTFMNaN7V
  35799. qnJNk22CDtucvc+081xdVHppCZbW2xHBjXWotM85yM48vCR85mLK4b19p71XZQvk/iXttmkQ3Cga
  35800. Rr0BHdCXteGYO8A3ZNY9lO4L4fUorgtWv3GLIylBjobFS1J72HGrH4oVpjuDWtdYAVHGTEHZf9hB
  35801. Z3KiKN9gg6meyHv8U3NyWfWTehd2Ds735VzZC1U0oqpbtWpU5xPKV+yXbfReBi9Fi1jUIxaS5BZu
  35802. KGNZMN9QAZxjiRqf2xeUgnA3wySemkfWWspOqGmJch+RbNt+nhutxx9z3SxPGWX9f5NAEC7S8O08
  35803. ni4oPmkmM8V7AgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNq7LqqwDLiIJlF0
  35804. XG0D08DYj3rWMB8GA1UdIwQYMBaAFNq7LqqwDLiIJlF0XG0D08DYj3rWMA4GA1UdDwEB/wQEAwIB
  35805. hjANBgkqhkiG9w0BAQUFAAOCAgEAMXjmx7XfuJRAyXHEqDXsRh3ChfMoWIawC/yOsjmPRFWrZIRc
  35806. aanQmjg8+uUfNeVE44B5lGiku8SfPeE0zTBGi1QrlaXv9z+ZhP015s8xxtxqv6fXIwjhmF7DWgh2
  35807. qaavdy+3YL1ERmrvl/9zlcGO6JP7/TG37FcREUWbMPEaiDnBTzynANXH/KttgCJwpQzgXQQpAvvL
  35808. oJHRfNbDflDVnVi+QTjruXU8FdmbyUqDWcDaU/0zuzYYm4UPFd3uLax2k7nZAY1IEKj79TiG8dsK
  35809. xr2EoyNB3tZ3b4XUhRxQ4K5RirqNPnbiucon8l+f725ZDQbYKxek0nxru18UGkiPGkzns0ccjkxF
  35810. KyDuSN/n3QmOGKjaQI2SJhFTYXNd673nxE0pN2HrrDktZy4W1vUAg4WhzH92xH3kt0tm7wNFYGm2
  35811. DFKWkoRepqO1pD4r2czYG0eq8kTaT/kD6PAUyz/zg97QwVTjt+gKN02LIFkDMBmhLMi9ER/frslK
  35812. xfMnZmaGrGiR/9nmUxwPi1xpZQomyB40w11Re9epnAahNt3ViZS82eQtDF4JbAiXfKM9fJP/P6EU
  35813. p8+1Xevb2xzEdt+Iub1FBZUbrvxGakyvSOPOrg/SfuvmbJxPgWp6ZKy7PtXny3YuxadIwVyQD8vI
  35814. P/rmMuGNG2+k5o7Y+SlIis5z/iw=
  35815. -----END CERTIFICATE-----
  35816. GeoTrust Universal CA 2
  35817. =======================
  35818. -----BEGIN CERTIFICATE-----
  35819. MIIFbDCCA1SgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMN
  35820. R2VvVHJ1c3QgSW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwHhcNMDQwMzA0
  35821. MDUwMDAwWhcNMjkwMzA0MDUwMDAwWjBHMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNR2VvVHJ1c3Qg
  35822. SW5jLjEgMB4GA1UEAxMXR2VvVHJ1c3QgVW5pdmVyc2FsIENBIDIwggIiMA0GCSqGSIb3DQEBAQUA
  35823. A4ICDwAwggIKAoICAQCzVFLByT7y2dyxUxpZKeexw0Uo5dfR7cXFS6GqdHtXr0om/Nj1XqduGdt0
  35824. DE81WzILAePb63p3NeqqWuDW6KFXlPCQo3RWlEQwAx5cTiuFJnSCegx2oG9NzkEtoBUGFF+3Qs17
  35825. j1hhNNwqCPkuwwGmIkQcTAeC5lvO0Ep8BNMZcyfwqph/Lq9O64ceJHdqXbboW0W63MOhBW9Wjo8Q
  35826. JqVJwy7XQYci4E+GymC16qFjwAGXEHm9ADwSbSsVsaxLse4YuU6W3Nx2/zu+z18DwPw76L5GG//a
  35827. QMJS9/7jOvdqdzXQ2o3rXhhqMcceujwbKNZrVMaqW9eiLBsZzKIC9ptZvTdrhrVtgrrY6slWvKk2
  35828. WP0+GfPtDCapkzj4T8FdIgbQl+rhrcZV4IErKIM6+vR7IVEAvlI4zs1meaj0gVbi0IMJR1FbUGrP
  35829. 20gaXT73y/Zl92zxlfgCOzJWgjl6W70viRu/obTo/3+NjN8D8WBOWBFM66M/ECuDmgFz2ZRthAAn
  35830. ZqzwcEAJQpKtT5MNYQlRJNiS1QuUYbKHsu3/mjX/hVTK7URDrBs8FmtISgocQIgfksILAAX/8sgC
  35831. SqSqqcyZlpwvWOB94b67B9xfBHJcMTTD7F8t4D1kkCLm0ey4Lt1ZrtmhN79UNdxzMk+MBB4zsslG
  35832. 8dhcyFVQyWi9qLo2CQIDAQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR281Xh+qQ2
  35833. +/CfXGJx7Tz0RzgQKzAfBgNVHSMEGDAWgBR281Xh+qQ2+/CfXGJx7Tz0RzgQKzAOBgNVHQ8BAf8E
  35834. BAMCAYYwDQYJKoZIhvcNAQEFBQADggIBAGbBxiPz2eAubl/oz66wsCVNK/g7WJtAJDday6sWSf+z
  35835. dXkzoS9tcBc0kf5nfo/sm+VegqlVHy/c1FEHEv6sFj4sNcZj/NwQ6w2jqtB8zNHQL1EuxBRa3ugZ
  35836. 4T7GzKQp5y6EqgYweHZUcyiYWTjgAA1i00J9IZ+uPTqM1fp3DRgrFg5fNuH8KrUwJM/gYwx7WBr+
  35837. mbpCErGR9Hxo4sjoryzqyX6uuyo9DRXcNJW2GHSoag/HtPQTxORb7QrSpJdMKu0vbBKJPfEncKpq
  35838. A1Ihn0CoZ1Dy81of398j9tx4TuaYT1U6U+Pv8vSfx3zYWK8pIpe44L2RLrB27FcRz+8pRPPphXpg
  35839. Y+RdM4kX2TGq2tbzGDVyz4crL2MjhF2EjD9XoIj8mZEoJmmZ1I+XRL6O1UixpCgp8RW04eWe3fiP
  35840. pm8m1wk8OhwRDqZsN/etRIcsKMfYdIKz0G9KV7s1KSegi+ghp4dkNl3M2Basx7InQJJVOCiNUW7d
  35841. FGdTbHFcJoRNdVq2fmBWqU2t+5sel/MN2dKXVHfaPRK34B7vCAas+YWH6aLcr34YEoP9VhdBLtUp
  35842. gn2Z9DH2canPLAEnpQW5qrJITirvn5NSUZU8UnOOVkwXQMAJKOSLakhT2+zNVVXxxvjpoixMptEm
  35843. X36vWkzaH6byHCx+rgIW0lbQL1dTR+iS
  35844. -----END CERTIFICATE-----
  35845. Comodo AAA Services root
  35846. ========================
  35847. -----BEGIN CERTIFICATE-----
  35848. MIIEMjCCAxqgAwIBAgIBATANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwS
  35849. R3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0Eg
  35850. TGltaXRlZDEhMB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTA0MDEwMTAwMDAw
  35851. MFoXDTI4MTIzMTIzNTk1OVowezELMAkGA1UEBhMCR0IxGzAZBgNVBAgMEkdyZWF0ZXIgTWFuY2hl
  35852. c3RlcjEQMA4GA1UEBwwHU2FsZm9yZDEaMBgGA1UECgwRQ29tb2RvIENBIExpbWl0ZWQxITAfBgNV
  35853. BAMMGEFBQSBDZXJ0aWZpY2F0ZSBTZXJ2aWNlczCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  35854. ggEBAL5AnfRu4ep2hxxNRUSOvkbIgwadwSr+GB+O5AL686tdUIoWMQuaBtDFcCLNSS1UY8y2bmhG
  35855. C1Pqy0wkwLxyTurxFa70VJoSCsN6sjNg4tqJVfMiWPPe3M/vg4aijJRPn2jymJBGhCfHdr/jzDUs
  35856. i14HZGWCwEiwqJH5YZ92IFCokcdmtet4YgNW8IoaE+oxox6gmf049vYnMlhvB/VruPsUK6+3qszW
  35857. Y19zjNoFmag4qMsXeDZRrOme9Hg6jc8P2ULimAyrL58OAd7vn5lJ8S3frHRNG5i1R8XlKdH5kBjH
  35858. Ypy+g8cmez6KJcfA3Z3mNWgQIJ2P2N7Sw4ScDV7oL8kCAwEAAaOBwDCBvTAdBgNVHQ4EFgQUoBEK
  35859. Iz6W8Qfs4q8p74Klf9AwpLQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wewYDVR0f
  35860. BHQwcjA4oDagNIYyaHR0cDovL2NybC5jb21vZG9jYS5jb20vQUFBQ2VydGlmaWNhdGVTZXJ2aWNl
  35861. cy5jcmwwNqA0oDKGMGh0dHA6Ly9jcmwuY29tb2RvLm5ldC9BQUFDZXJ0aWZpY2F0ZVNlcnZpY2Vz
  35862. LmNybDANBgkqhkiG9w0BAQUFAAOCAQEACFb8AvCb6P+k+tZ7xkSAzk/ExfYAWMymtrwUSWgEdujm
  35863. 7l3sAg9g1o1QGE8mTgHj5rCl7r+8dFRBv/38ErjHT1r0iWAFf2C3BUrz9vHCv8S5dIa2LX1rzNLz
  35864. Rt0vxuBqw8M0Ayx9lt1awg6nCpnBBYurDC/zXDrPbDdVCYfeU0BsWO/8tqtlbgT2G9w84FoVxp7Z
  35865. 8VlIMCFlA2zs6SFz7JsDoeA3raAVGI/6ugLOpyypEBMs1OUIJqsil2D4kF501KKaU73yqWjgom7C
  35866. 12yxow+ev+to51byrvLjKzg6CYG1a4XXvi3tPxq3smPi9WIsgtRqAEFQ8TmDn5XpNpaYbg==
  35867. -----END CERTIFICATE-----
  35868. QuoVadis Root CA
  35869. ================
  35870. -----BEGIN CERTIFICATE-----
  35871. MIIF0DCCBLigAwIBAgIEOrZQizANBgkqhkiG9w0BAQUFADB/MQswCQYDVQQGEwJCTTEZMBcGA1UE
  35872. ChMQUXVvVmFkaXMgTGltaXRlZDElMCMGA1UECxMcUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0
  35873. eTEuMCwGA1UEAxMlUXVvVmFkaXMgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wMTAz
  35874. MTkxODMzMzNaFw0yMTAzMTcxODMzMzNaMH8xCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRp
  35875. cyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MS4wLAYDVQQD
  35876. EyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEF
  35877. AAOCAQ8AMIIBCgKCAQEAv2G1lVO6V/z68mcLOhrfEYBklbTRvM16z/Ypli4kVEAkOPcahdxYTMuk
  35878. J0KX0J+DisPkBgNbAKVRHnAEdOLB1Dqr1607BxgFjv2DrOpm2RgbaIr1VxqYuvXtdj182d6UajtL
  35879. F8HVj71lODqV0D1VNk7feVcxKh7YWWVJWCCYfqtffp/p1k3sg3Spx2zY7ilKhSoGFPlU5tPaZQeL
  35880. YzcS19Dsw3sgQUSj7cugF+FxZc4dZjH3dgEZyH0DWLaVSR2mEiboxgx24ONmy+pdpibu5cxfvWen
  35881. AScOospUxbF6lR1xHkopigPcakXBpBlebzbNw6Kwt/5cOOJSvPhEQ+aQuwIDAQABo4ICUjCCAk4w
  35882. PQYIKwYBBQUHAQEEMTAvMC0GCCsGAQUFBzABhiFodHRwczovL29jc3AucXVvdmFkaXNvZmZzaG9y
  35883. ZS5jb20wDwYDVR0TAQH/BAUwAwEB/zCCARoGA1UdIASCAREwggENMIIBCQYJKwYBBAG+WAABMIH7
  35884. MIHUBggrBgEFBQcCAjCBxxqBxFJlbGlhbmNlIG9uIHRoZSBRdW9WYWRpcyBSb290IENlcnRpZmlj
  35885. YXRlIGJ5IGFueSBwYXJ0eSBhc3N1bWVzIGFjY2VwdGFuY2Ugb2YgdGhlIHRoZW4gYXBwbGljYWJs
  35886. ZSBzdGFuZGFyZCB0ZXJtcyBhbmQgY29uZGl0aW9ucyBvZiB1c2UsIGNlcnRpZmljYXRpb24gcHJh
  35887. Y3RpY2VzLCBhbmQgdGhlIFF1b1ZhZGlzIENlcnRpZmljYXRlIFBvbGljeS4wIgYIKwYBBQUHAgEW
  35888. Fmh0dHA6Ly93d3cucXVvdmFkaXMuYm0wHQYDVR0OBBYEFItLbe3TKbkGGew5Oanwl4Rqy+/fMIGu
  35889. BgNVHSMEgaYwgaOAFItLbe3TKbkGGew5Oanwl4Rqy+/foYGEpIGBMH8xCzAJBgNVBAYTAkJNMRkw
  35890. FwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMSUwIwYDVQQLExxSb290IENlcnRpZmljYXRpb24gQXV0
  35891. aG9yaXR5MS4wLAYDVQQDEyVRdW9WYWRpcyBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggQ6
  35892. tlCLMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQUFAAOCAQEAitQUtf70mpKnGdSkfnIYj9lo
  35893. fFIk3WdvOXrEql494liwTXCYhGHoG+NpGA7O+0dQoE7/8CQfvbLO9Sf87C9TqnN7Az10buYWnuul
  35894. LsS/VidQK2K6vkscPFVcQR0kvoIgR13VRH56FmjffU1RcHhXHTMe/QKZnAzNCgVPx7uOpHX6Sm2x
  35895. gI4JVrmcGmD+XcHXetwReNDWXcG31a0ymQM6isxUJTkxgXsTIlG6Rmyhu576BGxJJnSP0nPrzDCi
  35896. 5upZIof4l/UO/erMkqQWxFIY6iHOsfHmhIHluqmGKPJDWl0Snawe2ajlCmqnf6CHKc/yiU3U7MXi
  35897. 5nrQNiOKSnQ2+Q==
  35898. -----END CERTIFICATE-----
  35899. QuoVadis Root CA 2
  35900. ==================
  35901. -----BEGIN CERTIFICATE-----
  35902. MIIFtzCCA5+gAwIBAgICBQkwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  35903. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMjAeFw0wNjExMjQx
  35904. ODI3MDBaFw0zMTExMjQxODIzMzNaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  35905. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDIwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  35906. DwAwggIKAoICAQCaGMpLlA0ALa8DKYrwD4HIrkwZhR0In6spRIXzL4GtMh6QRr+jhiYaHv5+HBg6
  35907. XJxgFyo6dIMzMH1hVBHL7avg5tKifvVrbxi3Cgst/ek+7wrGsxDp3MJGF/hd/aTa/55JWpzmM+Yk
  35908. lvc/ulsrHHo1wtZn/qtmUIttKGAr79dgw8eTvI02kfN/+NsRE8Scd3bBrrcCaoF6qUWD4gXmuVbB
  35909. lDePSHFjIuwXZQeVikvfj8ZaCuWw419eaxGrDPmF60Tp+ARz8un+XJiM9XOva7R+zdRcAitMOeGy
  35910. lZUtQofX1bOQQ7dsE/He3fbE+Ik/0XX1ksOR1YqI0JDs3G3eicJlcZaLDQP9nL9bFqyS2+r+eXyt
  35911. 66/3FsvbzSUr5R/7mp/iUcw6UwxI5g69ybR2BlLmEROFcmMDBOAENisgGQLodKcftslWZvB1Jdxn
  35912. wQ5hYIizPtGo/KPaHbDRsSNU30R2be1B2MGyIrZTHN81Hdyhdyox5C315eXbyOD/5YDXC2Og/zOh
  35913. D7osFRXql7PSorW+8oyWHhqPHWykYTe5hnMz15eWniN9gqRMgeKh0bpnX5UHoycR7hYQe7xFSkyy
  35914. BNKr79X9DFHOUGoIMfmR2gyPZFwDwzqLID9ujWc9Otb+fVuIyV77zGHcizN300QyNQliBJIWENie
  35915. J0f7OyHj+OsdWwIDAQABo4GwMIGtMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1Ud
  35916. DgQWBBQahGK8SEwzJQTU7tD2A8QZRtGUazBuBgNVHSMEZzBlgBQahGK8SEwzJQTU7tD2A8QZRtGU
  35917. a6FJpEcwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMT
  35918. ElF1b1ZhZGlzIFJvb3QgQ0EgMoICBQkwDQYJKoZIhvcNAQEFBQADggIBAD4KFk2fBluornFdLwUv
  35919. Z+YTRYPENvbzwCYMDbVHZF34tHLJRqUDGCdViXh9duqWNIAXINzng/iN/Ae42l9NLmeyhP3ZRPx3
  35920. UIHmfLTJDQtyU/h2BwdBR5YM++CCJpNVjP4iH2BlfF/nJrP3MpCYUNQ3cVX2kiF495V5+vgtJodm
  35921. VjB3pjd4M1IQWK4/YY7yarHvGH5KWWPKjaJW1acvvFYfzznB4vsKqBUsfU16Y8Zsl0Q80m/DShcK
  35922. +JDSV6IZUaUtl0HaB0+pUNqQjZRG4T7wlP0QADj1O+hA4bRuVhogzG9Yje0uRY/W6ZM/57Es3zrW
  35923. IozchLsib9D45MY56QSIPMO661V6bYCZJPVsAfv4l7CUW+v90m/xd2gNNWQjrLhVoQPRTUIZ3Ph1
  35924. WVaj+ahJefivDrkRoHy3au000LYmYjgahwz46P0u05B/B5EqHdZ+XIWDmbA4CD/pXvk1B+TJYm5X
  35925. f6dQlfe6yJvmjqIBxdZmv3lh8zwc4bmCXF2gw+nYSL0ZohEUGW6yhhtoPkg3Goi3XZZenMfvJ2II
  35926. 4pEZXNLxId26F0KCl3GBUzGpn/Z9Yr9y4aOTHcyKJloJONDO1w2AFrR4pTqHTI2KpdVGl/IsELm8
  35927. VCLAAVBpQ570su9t+Oza8eOx79+Rj1QqCyXBJhnEUhAFZdWCEOrCMc0u
  35928. -----END CERTIFICATE-----
  35929. QuoVadis Root CA 3
  35930. ==================
  35931. -----BEGIN CERTIFICATE-----
  35932. MIIGnTCCBIWgAwIBAgICBcYwDQYJKoZIhvcNAQEFBQAwRTELMAkGA1UEBhMCQk0xGTAXBgNVBAoT
  35933. EFF1b1ZhZGlzIExpbWl0ZWQxGzAZBgNVBAMTElF1b1ZhZGlzIFJvb3QgQ0EgMzAeFw0wNjExMjQx
  35934. OTExMjNaFw0zMTExMjQxOTA2NDRaMEUxCzAJBgNVBAYTAkJNMRkwFwYDVQQKExBRdW9WYWRpcyBM
  35935. aW1pdGVkMRswGQYDVQQDExJRdW9WYWRpcyBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  35936. DwAwggIKAoICAQDMV0IWVJzmmNPTTe7+7cefQzlKZbPoFog02w1ZkXTPkrgEQK0CSzGrvI2RaNgg
  35937. DhoB4hp7Thdd4oq3P5kazethq8Jlph+3t723j/z9cI8LoGe+AaJZz3HmDyl2/7FWeUUrH556VOij
  35938. KTVopAFPD6QuN+8bv+OPEKhyq1hX51SGyMnzW9os2l2ObjyjPtr7guXd8lyyBTNvijbO0BNO/79K
  35939. DDRMpsMhvVAEVeuxu537RR5kFd5VAYwCdrXLoT9CabwvvWhDFlaJKjdhkf2mrk7AyxRllDdLkgbv
  35940. BNDInIjbC3uBr7E9KsRlOni27tyAsdLTmZw67mtaa7ONt9XOnMK+pUsvFrGeaDsGb659n/je7Mwp
  35941. p5ijJUMv7/FfJuGITfhebtfZFG4ZM2mnO4SJk8RTVROhUXhA+LjJou57ulJCg54U7QVSWllWp5f8
  35942. nT8KKdjcT5EOE7zelaTfi5m+rJsziO+1ga8bxiJTyPbH7pcUsMV8eFLI8M5ud2CEpukqdiDtWAEX
  35943. MJPpGovgc2PZapKUSU60rUqFxKMiMPwJ7Wgic6aIDFUhWMXhOp8q3crhkODZc6tsgLjoC2SToJyM
  35944. Gf+z0gzskSaHirOi4XCPLArlzW1oUevaPwV/izLmE1xr/l9A4iLItLRkT9a6fUg+qGkM17uGcclz
  35945. uD87nSVL2v9A6wIDAQABo4IBlTCCAZEwDwYDVR0TAQH/BAUwAwEB/zCB4QYDVR0gBIHZMIHWMIHT
  35946. BgkrBgEEAb5YAAMwgcUwgZMGCCsGAQUFBwICMIGGGoGDQW55IHVzZSBvZiB0aGlzIENlcnRpZmlj
  35947. YXRlIGNvbnN0aXR1dGVzIGFjY2VwdGFuY2Ugb2YgdGhlIFF1b1ZhZGlzIFJvb3QgQ0EgMyBDZXJ0
  35948. aWZpY2F0ZSBQb2xpY3kgLyBDZXJ0aWZpY2F0aW9uIFByYWN0aWNlIFN0YXRlbWVudC4wLQYIKwYB
  35949. BQUHAgEWIWh0dHA6Ly93d3cucXVvdmFkaXNnbG9iYWwuY29tL2NwczALBgNVHQ8EBAMCAQYwHQYD
  35950. VR0OBBYEFPLAE+CCQz777i9nMpY1XNu4ywLQMG4GA1UdIwRnMGWAFPLAE+CCQz777i9nMpY1XNu4
  35951. ywLQoUmkRzBFMQswCQYDVQQGEwJCTTEZMBcGA1UEChMQUXVvVmFkaXMgTGltaXRlZDEbMBkGA1UE
  35952. AxMSUXVvVmFkaXMgUm9vdCBDQSAzggIFxjANBgkqhkiG9w0BAQUFAAOCAgEAT62gLEz6wPJv92ZV
  35953. qyM07ucp2sNbtrCD2dDQ4iH782CnO11gUyeim/YIIirnv6By5ZwkajGxkHon24QRiSemd1o417+s
  35954. hvzuXYO8BsbRd2sPbSQvS3pspweWyuOEn62Iix2rFo1bZhfZFvSLgNLd+LJ2w/w4E6oM3kJpK27z
  35955. POuAJ9v1pkQNn1pVWQvVDVJIxa6f8i+AxeoyUDUSly7B4f/xI4hROJ/yZlZ25w9Rl6VSDE1JUZU2
  35956. Pb+iSwwQHYaZTKrzchGT5Or2m9qoXadNt54CrnMAyNojA+j56hl0YgCUyyIgvpSnWbWCar6ZeXqp
  35957. 8kokUvd0/bpO5qgdAm6xDYBEwa7TIzdfu4V8K5Iu6H6li92Z4b8nby1dqnuH/grdS/yO9SbkbnBC
  35958. bjPsMZ57k8HkyWkaPcBrTiJt7qtYTcbQQcEr6k8Sh17rRdhs9ZgC06DYVYoGmRmioHfRMJ6szHXu
  35959. g/WwYjnPbFfiTNKRCw51KBuav/0aQ/HKd/s7j2G4aSgWQgRecCocIdiP4b0jWy10QJLZYxkNc91p
  35960. vGJHvOB0K7Lrfb5BG7XARsWhIstfTsEokt4YutUqKLsRixeTmJlglFwjz1onl14LBQaTNx47aTbr
  35961. qZ5hHY8y2o4M1nQ+ewkk2gF3R8Q7zTSMmfXK4SVhM7JZG+Ju1zdXtg2pEto=
  35962. -----END CERTIFICATE-----
  35963. Security Communication Root CA
  35964. ==============================
  35965. -----BEGIN CERTIFICATE-----
  35966. MIIDWjCCAkKgAwIBAgIBADANBgkqhkiG9w0BAQUFADBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  35967. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  35968. HhcNMDMwOTMwMDQyMDQ5WhcNMjMwOTMwMDQyMDQ5WjBQMQswCQYDVQQGEwJKUDEYMBYGA1UEChMP
  35969. U0VDT00gVHJ1c3QubmV0MScwJQYDVQQLEx5TZWN1cml0eSBDb21tdW5pY2F0aW9uIFJvb3RDQTEw
  35970. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCzs/5/022x7xZ8V6UMbXaKL0u/ZPtM7orw
  35971. 8yl89f/uKuDp6bpbZCKamm8sOiZpUQWZJtzVHGpxxpp9Hp3dfGzGjGdnSj74cbAZJ6kJDKaVv0uM
  35972. DPpVmDvY6CKhS3E4eayXkmmziX7qIWgGmBSWh9JhNrxtJ1aeV+7AwFb9Ms+k2Y7CI9eNqPPYJayX
  35973. 5HA49LY6tJ07lyZDo6G8SVlyTCMwhwFY9k6+HGhWZq/NQV3Is00qVUarH9oe4kA92819uZKAnDfd
  35974. DJZkndwi92SL32HeFZRSFaB9UslLqCHJxrHty8OVYNEP8Ktw+N/LTX7s1vqr2b1/VPKl6Xn62dZ2
  35975. JChzAgMBAAGjPzA9MB0GA1UdDgQWBBSgc0mZaNyFW2XjmygvV5+9M7wHSDALBgNVHQ8EBAMCAQYw
  35976. DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUFAAOCAQEAaECpqLvkT115swW1F7NgE+vGkl3g
  35977. 0dNq/vu+m22/xwVtWSDEHPC32oRYAmP6SBbvT6UL90qY8j+eG61Ha2POCEfrUj94nK9NrvjVT8+a
  35978. mCoQQTlSxN3Zmw7vkwGusi7KaEIkQmywszo+zenaSMQVy+n5Bw+SUEmK3TGXX8npN6o7WWWXlDLJ
  35979. s58+OmJYxUmtYg5xpTKqL8aJdkNAExNnPaJUJRDL8Try2frbSVa7pv6nQTXD4IhhyYjH3zYQIphZ
  35980. 6rBK+1YWc26sTfcioU+tHXotRSflMMFe8toTyyVCUZVHA4xsIcx0Qu1T/zOLjw9XARYvz6buyXAi
  35981. FL39vmwLAw==
  35982. -----END CERTIFICATE-----
  35983. Sonera Class 2 Root CA
  35984. ======================
  35985. -----BEGIN CERTIFICATE-----
  35986. MIIDIDCCAgigAwIBAgIBHTANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQGEwJGSTEPMA0GA1UEChMG
  35987. U29uZXJhMRkwFwYDVQQDExBTb25lcmEgQ2xhc3MyIENBMB4XDTAxMDQwNjA3Mjk0MFoXDTIxMDQw
  35988. NjA3Mjk0MFowOTELMAkGA1UEBhMCRkkxDzANBgNVBAoTBlNvbmVyYTEZMBcGA1UEAxMQU29uZXJh
  35989. IENsYXNzMiBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJAXSjWdyvANlsdE+hY3
  35990. /Ei9vX+ALTU74W+oZ6m/AxxNjG8yR9VBaKQTBME1DJqEQ/xcHf+Js+gXGM2RX/uJ4+q/Tl18GybT
  35991. dXnt5oTjV+WtKcT0OijnpXuENmmz/V52vaMtmdOQTiMofRhj8VQ7Jp12W5dCsv+u8E7s3TmVToMG
  35992. f+dJQMjFAbJUWmYdPfz56TwKnoG4cPABi+QjVHzIrviQHgCWctRUz2EjvOr7nQKV0ba5cTppCD8P
  35993. tOFCx4j1P5iop7oc4HFx71hXgVB6XGt0Rg6DA5jDjqhu8nYybieDwnPz3BjotJPqdURrBGAgcVeH
  35994. nfO+oJAjPYok4doh28MCAwEAAaMzMDEwDwYDVR0TAQH/BAUwAwEB/zARBgNVHQ4ECgQISqCqWITT
  35995. XjwwCwYDVR0PBAQDAgEGMA0GCSqGSIb3DQEBBQUAA4IBAQBazof5FnIVV0sd2ZvnoiYw7JNn39Yt
  35996. 0jSv9zilzqsWuasvfDXLrNAPtEwr/IDva4yRXzZ299uzGxnq9LIR/WFxRL8oszodv7ND6J+/3DEI
  35997. cbCdjdY0RzKQxmUk96BKfARzjzlvF4xytb1LyHr4e4PDKE6cCepnP7JnBBvDFNr450kkkdAdavph
  35998. Oe9r5yF1BgfYErQhIHBCcYHaPJo2vqZbDWpsmh+Re/n570K6Tk6ezAyNlNzZRZxe7EJQY670XcSx
  35999. EtzKO6gunRRaBXW37Ndj4ro1tgQIkejanZz2ZrUYrAqmVCY0M9IbwdR/GjqOC6oybtv8TyWf2TLH
  36000. llpwrN9M
  36001. -----END CERTIFICATE-----
  36002. XRamp Global CA Root
  36003. ====================
  36004. -----BEGIN CERTIFICATE-----
  36005. MIIEMDCCAxigAwIBAgIQUJRs7Bjq1ZxN1ZfvdY+grTANBgkqhkiG9w0BAQUFADCBgjELMAkGA1UE
  36006. BhMCVVMxHjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2Vj
  36007. dXJpdHkgU2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBB
  36008. dXRob3JpdHkwHhcNMDQxMTAxMTcxNDA0WhcNMzUwMTAxMDUzNzE5WjCBgjELMAkGA1UEBhMCVVMx
  36009. HjAcBgNVBAsTFXd3dy54cmFtcHNlY3VyaXR5LmNvbTEkMCIGA1UEChMbWFJhbXAgU2VjdXJpdHkg
  36010. U2VydmljZXMgSW5jMS0wKwYDVQQDEyRYUmFtcCBHbG9iYWwgQ2VydGlmaWNhdGlvbiBBdXRob3Jp
  36011. dHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCYJB69FbS638eMpSe2OAtp87ZOqCwu
  36012. IR1cRN8hXX4jdP5efrRKt6atH67gBhbim1vZZ3RrXYCPKZ2GG9mcDZhtdhAoWORlsH9KmHmf4MMx
  36013. foArtYzAQDsRhtDLooY2YKTVMIJt2W7QDxIEM5dfT2Fa8OT5kavnHTu86M/0ay00fOJIYRyO82FE
  36014. zG+gSqmUsE3a56k0enI4qEHMPJQRfevIpoy3hsvKMzvZPTeL+3o+hiznc9cKV6xkmxnr9A8ECIqs
  36015. AxcZZPRaJSKNNCyy9mgdEm3Tih4U2sSPpuIjhdV6Db1q4Ons7Be7QhtnqiXtRYMh/MHJfNViPvry
  36016. xS3T/dRlAgMBAAGjgZ8wgZwwEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  36017. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFMZPoj0GY4QJnM5i5ASsjVy16bYbMDYGA1UdHwQvMC0wK6Ap
  36018. oCeGJWh0dHA6Ly9jcmwueHJhbXBzZWN1cml0eS5jb20vWEdDQS5jcmwwEAYJKwYBBAGCNxUBBAMC
  36019. AQEwDQYJKoZIhvcNAQEFBQADggEBAJEVOQMBG2f7Shz5CmBbodpNl2L5JFMn14JkTpAuw0kbK5rc
  36020. /Kh4ZzXxHfARvbdI4xD2Dd8/0sm2qlWkSLoC295ZLhVbO50WfUfXN+pfTXYSNrsf16GBBEYgoyxt
  36021. qZ4Bfj8pzgCT3/3JknOJiWSe5yvkHJEs0rnOfc5vMZnT5r7SHpDwCRR5XCOrTdLaIR9NmXmd4c8n
  36022. nxCbHIgNsIpkQTG4DmyQJKSbXHGPurt+HBvbaoAPIbzp26a3QPSyi6mx5O+aGtA9aZnuqCij4Tyz
  36023. 8LIRnM98QObd50N9otg6tamN8jSZxNQQ4Qb9CYQQO+7ETPTsJ3xCwnR8gooJybQDJbw=
  36024. -----END CERTIFICATE-----
  36025. Go Daddy Class 2 CA
  36026. ===================
  36027. -----BEGIN CERTIFICATE-----
  36028. MIIEADCCAuigAwIBAgIBADANBgkqhkiG9w0BAQUFADBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMY
  36029. VGhlIEdvIERhZGR5IEdyb3VwLCBJbmMuMTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRp
  36030. ZmljYXRpb24gQXV0aG9yaXR5MB4XDTA0MDYyOTE3MDYyMFoXDTM0MDYyOTE3MDYyMFowYzELMAkG
  36031. A1UEBhMCVVMxITAfBgNVBAoTGFRoZSBHbyBEYWRkeSBHcm91cCwgSW5jLjExMC8GA1UECxMoR28g
  36032. RGFkZHkgQ2xhc3MgMiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTCCASAwDQYJKoZIhvcNAQEBBQAD
  36033. ggENADCCAQgCggEBAN6d1+pXGEmhW+vXX0iG6r7d/+TvZxz0ZWizV3GgXne77ZtJ6XCAPVYYYwhv
  36034. 2vLM0D9/AlQiVBDYsoHUwHU9S3/Hd8M+eKsaA7Ugay9qK7HFiH7Eux6wwdhFJ2+qN1j3hybX2C32
  36035. qRe3H3I2TqYXP2WYktsqbl2i/ojgC95/5Y0V4evLOtXiEqITLdiOr18SPaAIBQi2XKVlOARFmR6j
  36036. YGB0xUGlcmIbYsUfb18aQr4CUWWoriMYavx4A6lNf4DD+qta/KFApMoZFv6yyO9ecw3ud72a9nmY
  36037. vLEHZ6IVDd2gWMZEewo+YihfukEHU1jPEX44dMX4/7VpkI+EdOqXG68CAQOjgcAwgb0wHQYDVR0O
  36038. BBYEFNLEsNKR1EwRcbNhyz2h/t2oatTjMIGNBgNVHSMEgYUwgYKAFNLEsNKR1EwRcbNhyz2h/t2o
  36039. atTjoWekZTBjMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYVGhlIEdvIERhZGR5IEdyb3VwLCBJbmMu
  36040. MTEwLwYDVQQLEyhHbyBEYWRkeSBDbGFzcyAyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5ggEAMAwG
  36041. A1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBADJL87LKPpH8EsahB4yOd6AzBhRckB4Y9wim
  36042. PQoZ+YeAEW5p5JYXMP80kWNyOO7MHAGjHZQopDH2esRU1/blMVgDoszOYtuURXO1v0XJJLXVggKt
  36043. I3lpjbi2Tc7PTMozI+gciKqdi0FuFskg5YmezTvacPd+mSYgFFQlq25zheabIZ0KbIIOqPjCDPoQ
  36044. HmyW74cNxA9hi63ugyuV+I6ShHI56yDqg+2DzZduCLzrTia2cyvk0/ZM/iZx4mERdEr/VxqHD3VI
  36045. Ls9RaRegAhJhldXRQLIQTO7ErBBDpqWeCtWVYpoNz4iCxTIM5CufReYNnyicsbkqWletNw+vHX/b
  36046. vZ8=
  36047. -----END CERTIFICATE-----
  36048. Starfield Class 2 CA
  36049. ====================
  36050. -----BEGIN CERTIFICATE-----
  36051. MIIEDzCCAvegAwIBAgIBADANBgkqhkiG9w0BAQUFADBoMQswCQYDVQQGEwJVUzElMCMGA1UEChMc
  36052. U3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAGA1UECxMpU3RhcmZpZWxkIENsYXNzIDIg
  36053. Q2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMDQwNjI5MTczOTE2WhcNMzQwNjI5MTczOTE2WjBo
  36054. MQswCQYDVQQGEwJVUzElMCMGA1UEChMcU3RhcmZpZWxkIFRlY2hub2xvZ2llcywgSW5jLjEyMDAG
  36055. A1UECxMpU3RhcmZpZWxkIENsYXNzIDIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEgMA0GCSqG
  36056. SIb3DQEBAQUAA4IBDQAwggEIAoIBAQC3Msj+6XGmBIWtDBFk385N78gDGIc/oav7PKaf8MOh2tTY
  36057. bitTkPskpD6E8J7oX+zlJ0T1KKY/e97gKvDIr1MvnsoFAZMej2YcOadN+lq2cwQlZut3f+dZxkqZ
  36058. JRRU6ybH838Z1TBwj6+wRir/resp7defqgSHo9T5iaU0X9tDkYI22WY8sbi5gv2cOj4QyDvvBmVm
  36059. epsZGD3/cVE8MC5fvj13c7JdBmzDI1aaK4UmkhynArPkPw2vCHmCuDY96pzTNbO8acr1zJ3o/WSN
  36060. F4Azbl5KXZnJHoe0nRrA1W4TNSNe35tfPe/W93bC6j67eA0cQmdrBNj41tpvi/JEoAGrAgEDo4HF
  36061. MIHCMB0GA1UdDgQWBBS/X7fRzt0fhvRbVazc1xDCDqmI5zCBkgYDVR0jBIGKMIGHgBS/X7fRzt0f
  36062. hvRbVazc1xDCDqmI56FspGowaDELMAkGA1UEBhMCVVMxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNo
  36063. bm9sb2dpZXMsIEluYy4xMjAwBgNVBAsTKVN0YXJmaWVsZCBDbGFzcyAyIENlcnRpZmljYXRpb24g
  36064. QXV0aG9yaXR5ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAAWdP4id0ckaVaGs
  36065. afPzWdqbAYcaT1epoXkJKtv3L7IezMdeatiDh6GX70k1PncGQVhiv45YuApnP+yz3SFmH8lU+nLM
  36066. PUxA2IGvd56Deruix/U0F47ZEUD0/CwqTRV/p2JdLiXTAAsgGh1o+Re49L2L7ShZ3U0WixeDyLJl
  36067. xy16paq8U4Zt3VekyvggQQto8PT7dL5WXXp59fkdheMtlb71cZBDzI0fmgAKhynpVSJYACPq4xJD
  36068. KVtHCN2MQWplBqjlIapBtJUhlbl90TSrE9atvNziPTnNvT51cKEYWQPJIrSPnNVeKtelttQKbfi3
  36069. QBFGmh95DmK/D5fs4C8fF5Q=
  36070. -----END CERTIFICATE-----
  36071. DigiCert Assured ID Root CA
  36072. ===========================
  36073. -----BEGIN CERTIFICATE-----
  36074. MIIDtzCCAp+gAwIBAgIQDOfg5RfYRv6P5WD8G/AwOTANBgkqhkiG9w0BAQUFADBlMQswCQYDVQQG
  36075. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  36076. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0EwHhcNMDYxMTEwMDAwMDAwWhcNMzEx
  36077. MTEwMDAwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  36078. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgQ0Ew
  36079. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCtDhXO5EOAXLGH87dg+XESpa7cJpSIqvTO
  36080. 9SA5KFhgDPiA2qkVlTJhPLWxKISKityfCgyDF3qPkKyK53lTXDGEKvYPmDI2dsze3Tyoou9q+yHy
  36081. UmHfnyDXH+Kx2f4YZNISW1/5WBg1vEfNoTb5a3/UsDg+wRvDjDPZ2C8Y/igPs6eD1sNuRMBhNZYW
  36082. /lmci3Zt1/GiSw0r/wty2p5g0I6QNcZ4VYcgoc/lbQrISXwxmDNsIumH0DJaoroTghHtORedmTpy
  36083. oeb6pNnVFzF1roV9Iq4/AUaG9ih5yLHa5FcXxH4cDrC0kqZWs72yl+2qp/C3xag/lRbQ/6GW6whf
  36084. GHdPAgMBAAGjYzBhMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRF
  36085. 66Kv9JLLgjEtUYunpyGd823IDzAfBgNVHSMEGDAWgBRF66Kv9JLLgjEtUYunpyGd823IDzANBgkq
  36086. hkiG9w0BAQUFAAOCAQEAog683+Lt8ONyc3pklL/3cmbYMuRCdWKuh+vy1dneVrOfzM4UKLkNl2Bc
  36087. EkxY5NM9g0lFWJc1aRqoR+pWxnmrEthngYTffwk8lOa4JiwgvT2zKIn3X/8i4peEH+ll74fg38Fn
  36088. SbNd67IJKusm7Xi+fT8r87cmNW1fiQG2SVufAQWbqz0lwcy2f8Lxb4bG+mRo64EtlOtCt/qMHt1i
  36089. 8b5QZ7dsvfPxH2sMNgcWfzd8qVttevESRmCD1ycEvkvOl77DZypoEd+A5wwzZr8TDRRu838fYxAe
  36090. +o0bJW1sj6W3YQGx0qMmoRBxna3iw/nDmVG3KwcIzi7mULKn+gpFL6Lw8g==
  36091. -----END CERTIFICATE-----
  36092. DigiCert Global Root CA
  36093. =======================
  36094. -----BEGIN CERTIFICATE-----
  36095. MIIDrzCCApegAwIBAgIQCDvgVpBCRrGhdWrJWZHHSjANBgkqhkiG9w0BAQUFADBhMQswCQYDVQQG
  36096. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  36097. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBDQTAeFw0wNjExMTAwMDAwMDBaFw0zMTExMTAw
  36098. MDAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  36099. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IENBMIIBIjANBgkq
  36100. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4jvhEXLeqKTTo1eqUKKPC3eQyaKl7hLOllsBCSDMAZOn
  36101. TjC3U/dDxGkAV53ijSLdhwZAAIEJzs4bg7/fzTtxRuLWZscFs3YnFo97nh6Vfe63SKMI2tavegw5
  36102. BmV/Sl0fvBf4q77uKNd0f3p4mVmFaG5cIzJLv07A6Fpt43C/dxC//AH2hdmoRBBYMql1GNXRor5H
  36103. 4idq9Joz+EkIYIvUX7Q6hL+hqkpMfT7PT19sdl6gSzeRntwi5m3OFBqOasv+zbMUZBfHWymeMr/y
  36104. 7vrTC0LUq7dBMtoM1O/4gdW7jVg/tRvoSSiicNoxBN33shbyTApOB6jtSj1etX+jkMOvJwIDAQAB
  36105. o2MwYTAOBgNVHQ8BAf8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUA95QNVbRTLtm
  36106. 8KPiGxvDl7I90VUwHwYDVR0jBBgwFoAUA95QNVbRTLtm8KPiGxvDl7I90VUwDQYJKoZIhvcNAQEF
  36107. BQADggEBAMucN6pIExIK+t1EnE9SsPTfrgT1eXkIoyQY/EsrhMAtudXH/vTBH1jLuG2cenTnmCmr
  36108. EbXjcKChzUyImZOMkXDiqw8cvpOp/2PV5Adg06O/nVsJ8dWO41P0jmP6P6fbtGbfYmbW0W5BjfIt
  36109. tep3Sp+dWOIrWcBAI+0tKIJFPnlUkiaY4IBIqDfv8NZ5YBberOgOzW6sRBc4L0na4UU+Krk2U886
  36110. UAb3LujEV0lsYSEY1QSteDwsOoBrp+uvFRTp2InBuThs4pFsiv9kuXclVzDAGySj4dzp30d8tbQk
  36111. CAUw7C29C79Fv1C5qfPrmAESrciIxpg0X40KPMbp1ZWVbd4=
  36112. -----END CERTIFICATE-----
  36113. DigiCert High Assurance EV Root CA
  36114. ==================================
  36115. -----BEGIN CERTIFICATE-----
  36116. MIIDxTCCAq2gAwIBAgIQAqxcJmoLQJuPC3nyrkYldzANBgkqhkiG9w0BAQUFADBsMQswCQYDVQQG
  36117. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSsw
  36118. KQYDVQQDEyJEaWdpQ2VydCBIaWdoIEFzc3VyYW5jZSBFViBSb290IENBMB4XDTA2MTExMDAwMDAw
  36119. MFoXDTMxMTExMDAwMDAwMFowbDELMAkGA1UEBhMCVVMxFTATBgNVBAoTDERpZ2lDZXJ0IEluYzEZ
  36120. MBcGA1UECxMQd3d3LmRpZ2ljZXJ0LmNvbTErMCkGA1UEAxMiRGlnaUNlcnQgSGlnaCBBc3N1cmFu
  36121. Y2UgRVYgUm9vdCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMbM5XPm+9S75S0t
  36122. Mqbf5YE/yc0lSbZxKsPVlDRnogocsF9ppkCxxLeyj9CYpKlBWTrT3JTWPNt0OKRKzE0lgvdKpVMS
  36123. OO7zSW1xkX5jtqumX8OkhPhPYlG++MXs2ziS4wblCJEMxChBVfvLWokVfnHoNb9Ncgk9vjo4UFt3
  36124. MRuNs8ckRZqnrG0AFFoEt7oT61EKmEFBIk5lYYeBQVCmeVyJ3hlKV9Uu5l0cUyx+mM0aBhakaHPQ
  36125. NAQTXKFx01p8VdteZOE3hzBWBOURtCmAEvF5OYiiAhF8J2a3iLd48soKqDirCmTCv2ZdlYTBoSUe
  36126. h10aUAsgEsxBu24LUTi4S8sCAwEAAaNjMGEwDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMB
  36127. Af8wHQYDVR0OBBYEFLE+w2kD+L9HAdSYJhoIAu9jZCvDMB8GA1UdIwQYMBaAFLE+w2kD+L9HAdSY
  36128. JhoIAu9jZCvDMA0GCSqGSIb3DQEBBQUAA4IBAQAcGgaX3NecnzyIZgYIVyHbIUf4KmeqvxgydkAQ
  36129. V8GK83rZEWWONfqe/EW1ntlMMUu4kehDLI6zeM7b41N5cdblIZQB2lWHmiRk9opmzN6cN82oNLFp
  36130. myPInngiK3BD41VHMWEZ71jFhS9OMPagMRYjyOfiZRYzy78aG6A9+MpeizGLYAiJLQwGXFK3xPkK
  36131. mNEVX58Svnw2Yzi9RKR/5CYrCsSXaQ3pjOLAEFe4yHYSkVXySGnYvCoCWw9E1CAx2/S6cCZdkGCe
  36132. vEsXCS+0yx5DaMkHJ8HSXPfqIbloEpw8nL+e/IBcm2PN7EeqJSdnoDfzAIJ9VNep+OkuE6N36B9K
  36133. -----END CERTIFICATE-----
  36134. DST Root CA X3
  36135. ==============
  36136. -----BEGIN CERTIFICATE-----
  36137. MIIDSjCCAjKgAwIBAgIQRK+wgNajJ7qJMDmGLvhAazANBgkqhkiG9w0BAQUFADA/MSQwIgYDVQQK
  36138. ExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMTDkRTVCBSb290IENBIFgzMB4X
  36139. DTAwMDkzMDIxMTIxOVoXDTIxMDkzMDE0MDExNVowPzEkMCIGA1UEChMbRGlnaXRhbCBTaWduYXR1
  36140. cmUgVHJ1c3QgQ28uMRcwFQYDVQQDEw5EU1QgUm9vdCBDQSBYMzCCASIwDQYJKoZIhvcNAQEBBQAD
  36141. ggEPADCCAQoCggEBAN+v6ZdQCINXtMxiZfaQguzH0yxrMMpb7NnDfcdAwRgUi+DoM3ZJKuM/IUmT
  36142. rE4Orz5Iy2Xu/NMhD2XSKtkyj4zl93ewEnu1lcCJo6m67XMuegwGMoOifooUMM0RoOEqOLl5CjH9
  36143. UL2AZd+3UWODyOKIYepLYYHsUmu5ouJLGiifSKOeDNoJjj4XLh7dIN9bxiqKqy69cK3FCxolkHRy
  36144. xXtqqzTWMIn/5WgTe1QLyNau7Fqckh49ZLOMxt+/yUFw7BZy1SbsOFU5Q9D8/RhcQPGX69Wam40d
  36145. utolucbY38EVAjqr2m7xPi71XAicPNaDaeQQmxkqtilX4+U9m5/wAl0CAwEAAaNCMEAwDwYDVR0T
  36146. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMSnsaR7LHH62+FLkHX/xBVghYkQ
  36147. MA0GCSqGSIb3DQEBBQUAA4IBAQCjGiybFwBcqR7uKGY3Or+Dxz9LwwmglSBd49lZRNI+DT69ikug
  36148. dB/OEIKcdBodfpga3csTS7MgROSR6cz8faXbauX+5v3gTt23ADq1cEmv8uXrAvHRAosZy5Q6XkjE
  36149. GB5YGV8eAlrwDPGxrancWYaLbumR9YbK+rlmM6pZW87ipxZzR8srzJmwN0jP41ZL9c8PDHIyh8bw
  36150. RLtTcm1D9SZImlJnt1ir/md2cXjbDaJWFBM5JDGFoqgCWjBH4d1QB7wCCZAA62RjYJsWvIjJEubS
  36151. fZGL+T0yjWW06XyxV3bqxbYoOb8VZRzI9neWagqNdwvYkQsEjgfbKbYK7p2CNTUQ
  36152. -----END CERTIFICATE-----
  36153. SwissSign Gold CA - G2
  36154. ======================
  36155. -----BEGIN CERTIFICATE-----
  36156. MIIFujCCA6KgAwIBAgIJALtAHEP1Xk+wMA0GCSqGSIb3DQEBBQUAMEUxCzAJBgNVBAYTAkNIMRUw
  36157. EwYDVQQKEwxTd2lzc1NpZ24gQUcxHzAdBgNVBAMTFlN3aXNzU2lnbiBHb2xkIENBIC0gRzIwHhcN
  36158. MDYxMDI1MDgzMDM1WhcNMzYxMDI1MDgzMDM1WjBFMQswCQYDVQQGEwJDSDEVMBMGA1UEChMMU3dp
  36159. c3NTaWduIEFHMR8wHQYDVQQDExZTd2lzc1NpZ24gR29sZCBDQSAtIEcyMIICIjANBgkqhkiG9w0B
  36160. AQEFAAOCAg8AMIICCgKCAgEAr+TufoskDhJuqVAtFkQ7kpJcyrhdhJJCEyq8ZVeCQD5XJM1QiyUq
  36161. t2/876LQwB8CJEoTlo8jE+YoWACjR8cGp4QjK7u9lit/VcyLwVcfDmJlD909Vopz2q5+bbqBHH5C
  36162. jCA12UNNhPqE21Is8w4ndwtrvxEvcnifLtg+5hg3Wipy+dpikJKVyh+c6bM8K8vzARO/Ws/BtQpg
  36163. vd21mWRTuKCWs2/iJneRjOBiEAKfNA+k1ZIzUd6+jbqEemA8atufK+ze3gE/bk3lUIbLtK/tREDF
  36164. ylqM2tIrfKjuvqblCqoOpd8FUrdVxyJdMmqXl2MT28nbeTZ7hTpKxVKJ+STnnXepgv9VHKVxaSvR
  36165. AiTysybUa9oEVeXBCsdtMDeQKuSeFDNeFhdVxVu1yzSJkvGdJo+hB9TGsnhQ2wwMC3wLjEHXuend
  36166. jIj3o02yMszYF9rNt85mndT9Xv+9lz4pded+p2JYryU0pUHHPbwNUMoDAw8IWh+Vc3hiv69yFGkO
  36167. peUDDniOJihC8AcLYiAQZzlG+qkDzAQ4embvIIO1jEpWjpEA/I5cgt6IoMPiaG59je883WX0XaxR
  36168. 7ySArqpWl2/5rX3aYT+YdzylkbYcjCbaZaIJbcHiVOO5ykxMgI93e2CaHt+28kgeDrpOVG2Y4OGi
  36169. GqJ3UM/EY5LsRxmd6+ZrzsECAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUw
  36170. AwEB/zAdBgNVHQ4EFgQUWyV7lqRlUX64OfPAeGZe6Drn8O4wHwYDVR0jBBgwFoAUWyV7lqRlUX64
  36171. OfPAeGZe6Drn8O4wRgYDVR0gBD8wPTA7BglghXQBWQECAQEwLjAsBggrBgEFBQcCARYgaHR0cDov
  36172. L3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBACe645R88a7A3hfm
  36173. 5djV9VSwg/S7zV4Fe0+fdWavPOhWfvxyeDgD2StiGwC5+OlgzczOUYrHUDFu4Up+GC9pWbY9ZIEr
  36174. 44OE5iKHjn3g7gKZYbge9LgriBIWhMIxkziWMaa5O1M/wySTVltpkuzFwbs4AOPsF6m43Md8AYOf
  36175. Mke6UiI0HTJ6CVanfCU2qT1L2sCCbwq7EsiHSycR+R4tx5M/nttfJmtS2S6K8RTGRI0Vqbe/vd6m
  36176. Gu6uLftIdxf+u+yvGPUqUfA5hJeVbG4bwyvEdGB5JbAKJ9/fXtI5z0V9QkvfsywexcZdylU6oJxp
  36177. mo/a77KwPJ+HbBIrZXAVUjEaJM9vMSNQH4xPjyPDdEFjHFWoFN0+4FFQz/EbMFYOkrCChdiDyyJk
  36178. vC24JdVUorgG6q2SpCSgwYa1ShNqR88uC1aVVMvOmttqtKay20EIhid392qgQmwLOM7XdVAyksLf
  36179. KzAiSNDVQTglXaTpXZ/GlHXQRf0wl0OPkKsKx4ZzYEppLd6leNcG2mqeSz53OiATIgHQv2ieY2Br
  36180. NU0LbbqhPcCT4H8js1WtciVORvnSFu+wZMEBnunKoGqYDs/YYPIvSbjkQuE4NRb0yG5P94FW6Lqj
  36181. viOvrv1vA+ACOzB2+httQc8Bsem4yWb02ybzOqR08kkkW8mw0FfB+j564ZfJ
  36182. -----END CERTIFICATE-----
  36183. SwissSign Silver CA - G2
  36184. ========================
  36185. -----BEGIN CERTIFICATE-----
  36186. MIIFvTCCA6WgAwIBAgIITxvUL1S7L0swDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCQ0gxFTAT
  36187. BgNVBAoTDFN3aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMB4X
  36188. DTA2MTAyNTA4MzI0NloXDTM2MTAyNTA4MzI0NlowRzELMAkGA1UEBhMCQ0gxFTATBgNVBAoTDFN3
  36189. aXNzU2lnbiBBRzEhMB8GA1UEAxMYU3dpc3NTaWduIFNpbHZlciBDQSAtIEcyMIICIjANBgkqhkiG
  36190. 9w0BAQEFAAOCAg8AMIICCgKCAgEAxPGHf9N4Mfc4yfjDmUO8x/e8N+dOcbpLj6VzHVxumK4DV644
  36191. N0MvFz0fyM5oEMF4rhkDKxD6LHmD9ui5aLlV8gREpzn5/ASLHvGiTSf5YXu6t+WiE7brYT7QbNHm
  36192. +/pe7R20nqA1W6GSy/BJkv6FCgU+5tkL4k+73JU3/JHpMjUi0R86TieFnbAVlDLaYQ1HTWBCrpJH
  36193. 6INaUFjpiou5XaHc3ZlKHzZnu0jkg7Y360g6rw9njxcH6ATK72oxh9TAtvmUcXtnZLi2kUpCe2Uu
  36194. MGoM9ZDulebyzYLs2aFK7PayS+VFheZteJMELpyCbTapxDFkH4aDCyr0NQp4yVXPQbBH6TCfmb5h
  36195. qAaEuSh6XzjZG6k4sIN/c8HDO0gqgg8hm7jMqDXDhBuDsz6+pJVpATqJAHgE2cn0mRmrVn5bi4Y5
  36196. FZGkECwJMoBgs5PAKrYYC51+jUnyEEp/+dVGLxmSo5mnJqy7jDzmDrxHB9xzUfFwZC8I+bRHHTBs
  36197. ROopN4WSaGa8gzj+ezku01DwH/teYLappvonQfGbGHLy9YR0SslnxFSuSGTfjNFusB3hB48IHpmc
  36198. celM2KX3RxIfdNFRnobzwqIjQAtz20um53MGjMGg6cFZrEb65i/4z3GcRm25xBWNOHkDRUjvxF3X
  36199. CO6HOSKGsg0PWEP3calILv3q1h8CAwEAAaOBrDCBqTAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/
  36200. BAUwAwEB/zAdBgNVHQ4EFgQUF6DNweRBtjpbO8tFnb0cwpj6hlgwHwYDVR0jBBgwFoAUF6DNweRB
  36201. tjpbO8tFnb0cwpj6hlgwRgYDVR0gBD8wPTA7BglghXQBWQEDAQEwLjAsBggrBgEFBQcCARYgaHR0
  36202. cDovL3JlcG9zaXRvcnkuc3dpc3NzaWduLmNvbS8wDQYJKoZIhvcNAQEFBQADggIBAHPGgeAn0i0P
  36203. 4JUw4ppBf1AsX19iYamGamkYDHRJ1l2E6kFSGG9YrVBWIGrGvShpWJHckRE1qTodvBqlYJ7YH39F
  36204. kWnZfrt4csEGDyrOj4VwYaygzQu4OSlWhDJOhrs9xCrZ1x9y7v5RoSJBsXECYxqCsGKrXlcSH9/L
  36205. 3XWgwF15kIwb4FDm3jH+mHtwX6WQ2K34ArZv02DdQEsixT2tOnqfGhpHkXkzuoLcMmkDlm4fS/Bx
  36206. /uNncqCxv1yL5PqZIseEuRuNI5c/7SXgz2W79WEE790eslpBIlqhn10s6FvJbakMDHiqYMZWjwFa
  36207. DGi8aRl5xB9+lwW/xekkUV7U1UtT7dkjWjYDZaPBA61BMPNGG4WQr2W11bHkFlt4dR2Xem1ZqSqP
  36208. e97Dh4kQmUlzeMg9vVE1dCrV8X5pGyq7O70luJpaPXJhkGaH7gzWTdQRdAtq/gsD/KNVV4n+Ssuu
  36209. WxcFyPKNIzFTONItaj+CuY0IavdeQXRuwxF+B6wpYJE/OMpXEA29MC/HpeZBoNquBYeaoKRlbEwJ
  36210. DIm6uNO5wJOKMPqN5ZprFQFOZ6raYlY+hAhm0sQ2fac+EPyI4NSA5QC9qvNOBqN6avlicuMJT+ub
  36211. DgEj8Z+7fNzcbBGXJbLytGMU0gYqZ4yD9c7qB9iaah7s5Aq7KkzrCWA5zspi2C5u
  36212. -----END CERTIFICATE-----
  36213. GeoTrust Primary Certification Authority
  36214. ========================================
  36215. -----BEGIN CERTIFICATE-----
  36216. MIIDfDCCAmSgAwIBAgIQGKy1av1pthU6Y2yv2vrEoTANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQG
  36217. EwJVUzEWMBQGA1UEChMNR2VvVHJ1c3QgSW5jLjExMC8GA1UEAxMoR2VvVHJ1c3QgUHJpbWFyeSBD
  36218. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNjExMjcwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMFgx
  36219. CzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTEwLwYDVQQDEyhHZW9UcnVzdCBQ
  36220. cmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  36221. CgKCAQEAvrgVe//UfH1nrYNke8hCUy3f9oQIIGHWAVlqnEQRr+92/ZV+zmEwu3qDXwK9AWbK7hWN
  36222. b6EwnL2hhZ6UOvNWiAAxz9juapYC2e0DjPt1befquFUWBRaa9OBesYjAZIVcFU2Ix7e64HXprQU9
  36223. nceJSOC7KMgD4TCTZF5SwFlwIjVXiIrxlQqD17wxcwE07e9GceBrAqg1cmuXm2bgyxx5X9gaBGge
  36224. RwLmnWDiNpcB3841kt++Z8dtd1k7j53WkBWUvEI0EME5+bEnPn7WinXFsq+W06Lem+SYvn3h6YGt
  36225. tm/81w7a4DSwDRp35+MImO9Y+pyEtzavwt+s0vQQBnBxNQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  36226. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQULNVQQZcVi/CPNmFbSvtr2ZnJM5IwDQYJKoZI
  36227. hvcNAQEFBQADggEBAFpwfyzdtzRP9YZRqSa+S7iq8XEN3GHHoOo0Hnp3DwQ16CePbJC/kRYkRj5K
  36228. Ts4rFtULUh38H2eiAkUxT87z+gOneZ1TatnaYzr4gNfTmeGl4b7UVXGYNTq+k+qurUKykG/g/CFN
  36229. NWMziUnWm07Kx+dOCQD32sfvmWKZd7aVIl6KoKv0uHiYyjgZmclynnjNS6yvGaBzEi38wkG6gZHa
  36230. Floxt/m0cYASSJlyc1pZU8FjUjPtp8nSOQJw+uCxQmYpqptR7TBUIhRf2asdweSU8Pj1K/fqynhG
  36231. 1riR/aYNKxoUAT6A8EKglQdebc3MS6RFjasS6LPeWuWgfOgPIh1a6Vk=
  36232. -----END CERTIFICATE-----
  36233. thawte Primary Root CA
  36234. ======================
  36235. -----BEGIN CERTIFICATE-----
  36236. MIIEIDCCAwigAwIBAgIQNE7VVyDV7exJ9C/ON9srbTANBgkqhkiG9w0BAQUFADCBqTELMAkGA1UE
  36237. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  36238. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  36239. cml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMTFnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwHhcNMDYxMTE3
  36240. MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCBqTELMAkGA1UEBhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwg
  36241. SW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMv
  36242. KGMpIDIwMDYgdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxHzAdBgNVBAMT
  36243. FnRoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCs
  36244. oPD7gFnUnMekz52hWXMJEEUMDSxuaPFsW0hoSVk3/AszGcJ3f8wQLZU0HObrTQmnHNK4yZc2AreJ
  36245. 1CRfBsDMRJSUjQJib+ta3RGNKJpchJAQeg29dGYvajig4tVUROsdB58Hum/u6f1OCyn1PoSgAfGc
  36246. q/gcfomk6KHYcWUNo1F77rzSImANuVud37r8UVsLr5iy6S7pBOhih94ryNdOwUxkHt3Ph1i6Sk/K
  36247. aAcdHJ1KxtUvkcx8cXIcxcBn6zL9yZJclNqFwJu/U30rCfSMnZEfl2pSy94JNqR32HuHUETVPm4p
  36248. afs5SSYeCaWAe0At6+gnhcn+Yf1+5nyXHdWdAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYD
  36249. VR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR7W0XPr87Lev0xkhpqtvNG61dIUDANBgkqhkiG9w0BAQUF
  36250. AAOCAQEAeRHAS7ORtvzw6WfUDW5FvlXok9LOAz/t2iWwHVfLHjp2oEzsUHboZHIMpKnxuIvW1oeE
  36251. uzLlQRHAd9mzYJ3rG9XRbkREqaYB7FViHXe4XI5ISXycO1cRrK1zN44veFyQaEfZYGDm/Ac9IiAX
  36252. xPcW6cTYcvnIc3zfFi8VqT79aie2oetaupgf1eNNZAqdE8hhuvU5HIe6uL17In/2/qxAeeWsEG89
  36253. jxt5dovEN7MhGITlNgDrYyCZuen+MwS7QcjBAvlEYyCegc5C09Y/LHbTY5xZ3Y+m4Q6gLkH3LpVH
  36254. z7z9M/P2C2F+fpErgUfCJzDupxBdN49cOSvkBPB7jVaMaA==
  36255. -----END CERTIFICATE-----
  36256. VeriSign Class 3 Public Primary Certification Authority - G5
  36257. ============================================================
  36258. -----BEGIN CERTIFICATE-----
  36259. MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCByjELMAkGA1UE
  36260. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  36261. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  36262. IHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRp
  36263. ZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCB
  36264. yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2ln
  36265. biBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2lnbiwgSW5jLiAtIEZvciBh
  36266. dXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmlt
  36267. YXJ5IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
  36268. ggEKAoIBAQCvJAgIKXo1nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6CqqpkKz
  36269. j/i5Vbext0uz/o9+B1fs70PbZmIVYc9gDaTY3vjgw2IIPVQT60nKWVSFJuUrjxuf6/WhkcIzSdhD
  36270. Y2pSS9KP6HBRTdGJaXvHcPaz3BJ023tdS1bTlr8Vd6Gw9KIl8q8ckmcY5fQGBO+QueQA5N06tRn/
  36271. Arr0PO7gi+s3i+z016zy9vA9r911kTMZHRxAy3QkGSGT2RT+rCpSx4/VBEnkjWNHiDxpg8v+R70r
  36272. fk/Fla4OndTRQ8Bnc+MUCH7lP59zuDMKz10/NIeWiu5T6CUVAgMBAAGjgbIwga8wDwYDVR0TAQH/
  36273. BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2Uv
  36274. Z2lmMCEwHzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVy
  36275. aXNpZ24uY29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG
  36276. SIb3DQEBBQUAA4IBAQCTJEowX2LP2BqYLz3q3JktvXf2pXkiOOzEp6B4Eq1iDkVwZMXnl2YtmAl+
  36277. X6/WzChl8gGqCBpH3vn5fJJaCGkgDdk+bW48DW7Y5gaRQBi5+MHt39tBquCWIMnNZBU4gcmU7qKE
  36278. KQsTb47bDN0lAtukixlE0kF6BWlKWE9gyn6CagsCqiUXObXbf+eEZSqVir2G3l6BFoMtEMze/aiC
  36279. Km0oHw0LxOXnGiYZ4fQRbxC1lfznQgUy286dUV4otp6F01vvpX1FQHKOtw5rDgb7MzVIcbidJ4vE
  36280. ZV8NhnacRHr2lVz2XTIIM6RUthg/aFzyQkqFOFSDX9HoLPKsEdao7WNq
  36281. -----END CERTIFICATE-----
  36282. SecureTrust CA
  36283. ==============
  36284. -----BEGIN CERTIFICATE-----
  36285. MIIDuDCCAqCgAwIBAgIQDPCOXAgWpa1Cf/DrJxhZ0DANBgkqhkiG9w0BAQUFADBIMQswCQYDVQQG
  36286. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xFzAVBgNVBAMTDlNlY3VyZVRy
  36287. dXN0IENBMB4XDTA2MTEwNzE5MzExOFoXDTI5MTIzMTE5NDA1NVowSDELMAkGA1UEBhMCVVMxIDAe
  36288. BgNVBAoTF1NlY3VyZVRydXN0IENvcnBvcmF0aW9uMRcwFQYDVQQDEw5TZWN1cmVUcnVzdCBDQTCC
  36289. ASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKukgeWVzfX2FI7CT8rU4niVWJxB4Q2ZQCQX
  36290. OZEzZum+4YOvYlyJ0fwkW2Gz4BERQRwdbvC4u/jep4G6pkjGnx29vo6pQT64lO0pGtSO0gMdA+9t
  36291. DWccV9cGrcrI9f4Or2YlSASWC12juhbDCE/RRvgUXPLIXgGZbf2IzIaowW8xQmxSPmjL8xk037uH
  36292. GFaAJsTQ3MBv396gwpEWoGQRS0S8Hvbn+mPeZqx2pHGj7DaUaHp3pLHnDi+BeuK1cobvomuL8A/b
  36293. 01k/unK8RCSc43Oz969XL0Imnal0ugBS8kvNU3xHCzaFDmapCJcWNFfBZveA4+1wVMeT4C4oFVmH
  36294. ursCAwEAAaOBnTCBmjATBgkrBgEEAYI3FAIEBh4EAEMAQTALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/
  36295. BAUwAwEB/zAdBgNVHQ4EFgQUQjK2FvoE/f5dS3rD/fdMQB1aQ68wNAYDVR0fBC0wKzApoCegJYYj
  36296. aHR0cDovL2NybC5zZWN1cmV0cnVzdC5jb20vU1RDQS5jcmwwEAYJKwYBBAGCNxUBBAMCAQAwDQYJ
  36297. KoZIhvcNAQEFBQADggEBADDtT0rhWDpSclu1pqNlGKa7UTt36Z3q059c4EVlew3KW+JwULKUBRSu
  36298. SceNQQcSc5R+DCMh/bwQf2AQWnL1mA6s7Ll/3XpvXdMc9P+IBWlCqQVxyLesJugutIxq/3HcuLHf
  36299. mbx8IVQr5Fiiu1cprp6poxkmD5kuCLDv/WnPmRoJjeOnnyvJNjR7JLN4TJUXpAYmHrZkUjZfYGfZ
  36300. nMUFdAvnZyPSCPyI6a6Lf+Ew9Dd+/cYy2i2eRDAwbO4H3tI0/NL/QPZL9GZGBlSm8jIKYyYwa5vR
  36301. 3ItHuuG51WLQoqD0ZwV4KWMabwTW+MZMo5qxN7SN5ShLHZ4swrhovO0C7jE=
  36302. -----END CERTIFICATE-----
  36303. Secure Global CA
  36304. ================
  36305. -----BEGIN CERTIFICATE-----
  36306. MIIDvDCCAqSgAwIBAgIQB1YipOjUiolN9BPI8PjqpTANBgkqhkiG9w0BAQUFADBKMQswCQYDVQQG
  36307. EwJVUzEgMB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBH
  36308. bG9iYWwgQ0EwHhcNMDYxMTA3MTk0MjI4WhcNMjkxMjMxMTk1MjA2WjBKMQswCQYDVQQGEwJVUzEg
  36309. MB4GA1UEChMXU2VjdXJlVHJ1c3QgQ29ycG9yYXRpb24xGTAXBgNVBAMTEFNlY3VyZSBHbG9iYWwg
  36310. Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvNS7YrGxVaQZx5RNoJLNP2MwhR/jx
  36311. YDiJiQPpvepeRlMJ3Fz1Wuj3RSoC6zFh1ykzTM7HfAo3fg+6MpjhHZevj8fcyTiW89sa/FHtaMbQ
  36312. bqR8JNGuQsiWUGMu4P51/pinX0kuleM5M2SOHqRfkNJnPLLZ/kG5VacJjnIFHovdRIWCQtBJwB1g
  36313. 8NEXLJXr9qXBkqPFwqcIYA1gBBCWeZ4WNOaptvolRTnIHmX5k/Wq8VLcmZg9pYYaDDUz+kulBAYV
  36314. HDGA76oYa8J719rO+TMg1fW9ajMtgQT7sFzUnKPiXB3jqUJ1XnvUd+85VLrJChgbEplJL4hL/VBi
  36315. 0XPnj3pDAgMBAAGjgZ0wgZowEwYJKwYBBAGCNxQCBAYeBABDAEEwCwYDVR0PBAQDAgGGMA8GA1Ud
  36316. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFK9EBMJBfkiD2045AuzshHrmzsmkMDQGA1UdHwQtMCswKaAn
  36317. oCWGI2h0dHA6Ly9jcmwuc2VjdXJldHJ1c3QuY29tL1NHQ0EuY3JsMBAGCSsGAQQBgjcVAQQDAgEA
  36318. MA0GCSqGSIb3DQEBBQUAA4IBAQBjGghAfaReUw132HquHw0LURYD7xh8yOOvaliTFGCRsoTciE6+
  36319. OYo68+aCiV0BN7OrJKQVDpI1WkpEXk5X+nXOH0jOZvQ8QCaSmGwb7iRGDBezUqXbpZGRzzfTb+cn
  36320. CDpOGR86p1hcF895P4vkp9MmI50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/5
  36321. 3CYNv6ZHdAbYiNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc
  36322. f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW
  36323. -----END CERTIFICATE-----
  36324. COMODO Certification Authority
  36325. ==============================
  36326. -----BEGIN CERTIFICATE-----
  36327. MIIEHTCCAwWgAwIBAgIQToEtioJl4AsC7j41AkblPTANBgkqhkiG9w0BAQUFADCBgTELMAkGA1UE
  36328. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  36329. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxJzAlBgNVBAMTHkNPTU9ETyBDZXJ0aWZpY2F0aW9uIEF1
  36330. dGhvcml0eTAeFw0wNjEyMDEwMDAwMDBaFw0yOTEyMzEyMzU5NTlaMIGBMQswCQYDVQQGEwJHQjEb
  36331. MBkGA1UECBMSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYDVQQHEwdTYWxmb3JkMRowGAYDVQQKExFD
  36332. T01PRE8gQ0EgTGltaXRlZDEnMCUGA1UEAxMeQ09NT0RPIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  36333. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0ECLi3LjkRv3UcEbVASY06m/weaKXTuH
  36334. +7uIzg3jLz8GlvCiKVCZrts7oVewdFFxze1CkU1B/qnI2GqGd0S7WWaXUF601CxwRM/aN5VCaTww
  36335. xHGzUvAhTaHYujl8HJ6jJJ3ygxaYqhZ8Q5sVW7euNJH+1GImGEaaP+vB+fGQV+useg2L23IwambV
  36336. 4EajcNxo2f8ESIl33rXp+2dtQem8Ob0y2WIC8bGoPW43nOIv4tOiJovGuFVDiOEjPqXSJDlqR6sA
  36337. 1KGzqSX+DT+nHbrTUcELpNqsOO9VUCQFZUaTNE8tja3G1CEZ0o7KBWFxB3NH5YoZEr0ETc5OnKVI
  36338. rLsm9wIDAQABo4GOMIGLMB0GA1UdDgQWBBQLWOWLxkwVN6RAqTCpIb5HNlpW/zAOBgNVHQ8BAf8E
  36339. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zBJBgNVHR8EQjBAMD6gPKA6hjhodHRwOi8vY3JsLmNvbW9k
  36340. b2NhLmNvbS9DT01PRE9DZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDANBgkqhkiG9w0BAQUFAAOC
  36341. AQEAPpiem/Yb6dc5t3iuHXIYSdOH5EOC6z/JqvWote9VfCFSZfnVDeFs9D6Mk3ORLgLETgdxb8CP
  36342. OGEIqB6BCsAvIC9Bi5HcSEW88cbeunZrM8gALTFGTO3nnc+IlP8zwFboJIYmuNg4ON8qa90SzMc/
  36343. RxdMosIGlgnW2/4/PEZB31jiVg88O8EckzXZOFKs7sjsLjBOlDW0JB9LeGna8gI4zJVSk/BwJVmc
  36344. IGfE7vmLV2H0knZ9P4SNVbfo5azV8fUZVqZa+5Acr5Pr5RzUZ5ddBA6+C4OmF4O5MBKgxTMVBbkN
  36345. +8cFduPYSo38NBejxiEovjBFMR7HeL5YYTisO+IBZQ==
  36346. -----END CERTIFICATE-----
  36347. Network Solutions Certificate Authority
  36348. =======================================
  36349. -----BEGIN CERTIFICATE-----
  36350. MIID5jCCAs6gAwIBAgIQV8szb8JcFuZHFhfjkDFo4DANBgkqhkiG9w0BAQUFADBiMQswCQYDVQQG
  36351. EwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMuMTAwLgYDVQQDEydOZXR3b3Jr
  36352. IFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwHhcNMDYxMjAxMDAwMDAwWhcNMjkxMjMx
  36353. MjM1OTU5WjBiMQswCQYDVQQGEwJVUzEhMB8GA1UEChMYTmV0d29yayBTb2x1dGlvbnMgTC5MLkMu
  36354. MTAwLgYDVQQDEydOZXR3b3JrIFNvbHV0aW9ucyBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkwggEiMA0G
  36355. CSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDkvH6SMG3G2I4rC7xGzuAnlt7e+foS0zwzc7MEL7xx
  36356. jOWftiJgPl9dzgn/ggwbmlFQGiaJ3dVhXRncEg8tCqJDXRfQNJIg6nPPOCwGJgl6cvf6UDL4wpPT
  36357. aaIjzkGxzOTVHzbRijr4jGPiFFlp7Q3Tf2vouAPlT2rlmGNpSAW+Lv8ztumXWWn4Zxmuk2GWRBXT
  36358. crA/vGp97Eh/jcOrqnErU2lBUzS1sLnFBgrEsEX1QV1uiUV7PTsmjHTC5dLRfbIR1PtYMiKagMnc
  36359. /Qzpf14Dl847ABSHJ3A4qY5usyd2mFHgBeMhqxrVhSI8KbWaFsWAqPS7azCPL0YCorEMIuDTAgMB
  36360. AAGjgZcwgZQwHQYDVR0OBBYEFCEwyfsA106Y2oeqKtCnLrFAMadMMA4GA1UdDwEB/wQEAwIBBjAP
  36361. BgNVHRMBAf8EBTADAQH/MFIGA1UdHwRLMEkwR6BFoEOGQWh0dHA6Ly9jcmwubmV0c29sc3NsLmNv
  36362. bS9OZXR3b3JrU29sdXRpb25zQ2VydGlmaWNhdGVBdXRob3JpdHkuY3JsMA0GCSqGSIb3DQEBBQUA
  36363. A4IBAQC7rkvnt1frf6ott3NHhWrB5KUd5Oc86fRZZXe1eltajSU24HqXLjjAV2CDmAaDn7l2em5Q
  36364. 4LqILPxFzBiwmZVRDuwduIj/h1AcgsLj4DKAv6ALR8jDMe+ZZzKATxcheQxpXN5eNK4CtSbqUN9/
  36365. GGUsyfJj4akH/nxxH2szJGoeBfcFaMBqEssuXmHLrijTfsK0ZpEmXzwuJF/LWA/rKOyvEZbz3Htv
  36366. wKeI8lN3s2Berq4o2jUsbzRF0ybh3uxbTydrFny9RAQYgrOJeRcQcT16ohZO9QHNpGxlaKFJdlxD
  36367. ydi8NmdspZS11My5vWo1ViHe2MPr+8ukYEywVaCge1ey
  36368. -----END CERTIFICATE-----
  36369. COMODO ECC Certification Authority
  36370. ==================================
  36371. -----BEGIN CERTIFICATE-----
  36372. MIICiTCCAg+gAwIBAgIQH0evqmIAcFBUTAGem2OZKjAKBggqhkjOPQQDAzCBhTELMAkGA1UEBhMC
  36373. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  36374. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBB
  36375. dXRob3JpdHkwHhcNMDgwMzA2MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMCR0Ix
  36376. GzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UEChMR
  36377. Q09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBFQ0MgQ2VydGlmaWNhdGlvbiBBdXRo
  36378. b3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQDR3svdcmCFYX7deSRFtSrYpn1PlILBs5BAH+X
  36379. 4QokPB0BBO490o0JlwzgdeT6+3eKKvUDYEs2ixYjFq0JcfRK9ChQtP6IHG4/bC8vCVlbpVsLM5ni
  36380. wz2J+Wos77LTBumjQjBAMB0GA1UdDgQWBBR1cacZSBm8nZ3qQUfflMRId5nTeTAOBgNVHQ8BAf8E
  36381. BAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjEA7wNbeqy3eApyt4jf/7VG
  36382. FAkK+qDmfQjGGoe9GKhzvSbKYAydzpmfz1wPMOG+FDHqAjAU9JM8SaczepBGR7NjfRObTrdvGDeA
  36383. U/7dIOA1mjbRxwG55tzd8/8dLDoWV9mSOdY=
  36384. -----END CERTIFICATE-----
  36385. Certigna
  36386. ========
  36387. -----BEGIN CERTIFICATE-----
  36388. MIIDqDCCApCgAwIBAgIJAP7c4wEPyUj/MA0GCSqGSIb3DQEBBQUAMDQxCzAJBgNVBAYTAkZSMRIw
  36389. EAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hMB4XDTA3MDYyOTE1MTMwNVoXDTI3
  36390. MDYyOTE1MTMwNVowNDELMAkGA1UEBhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczERMA8GA1UEAwwI
  36391. Q2VydGlnbmEwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDIaPHJ1tazNHUmgh7stL7q
  36392. XOEm7RFHYeGifBZ4QCHkYJ5ayGPhxLGWkv8YbWkj4Sti993iNi+RB7lIzw7sebYs5zRLcAglozyH
  36393. GxnygQcPOJAZ0xH+hrTy0V4eHpbNgGzOOzGTtvKg0KmVEn2lmsxryIRWijOp5yIVUxbwzBfsV1/p
  36394. ogqYCd7jX5xv3EjjhQsVWqa6n6xI4wmy9/Qy3l40vhx4XUJbzg4ij02Q130yGLMLLGq/jj8UEYkg
  36395. DncUtT2UCIf3JR7VsmAA7G8qKCVuKj4YYxclPz5EIBb2JsglrgVKtOdjLPOMFlN+XPsRGgjBRmKf
  36396. Irjxwo1p3Po6WAbfAgMBAAGjgbwwgbkwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUGu3+QTmQ
  36397. tCRZvgHyUtVF9lo53BEwZAYDVR0jBF0wW4AUGu3+QTmQtCRZvgHyUtVF9lo53BGhOKQ2MDQxCzAJ
  36398. BgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxETAPBgNVBAMMCENlcnRpZ25hggkA/tzjAQ/J
  36399. SP8wDgYDVR0PAQH/BAQDAgEGMBEGCWCGSAGG+EIBAQQEAwIABzANBgkqhkiG9w0BAQUFAAOCAQEA
  36400. hQMeknH2Qq/ho2Ge6/PAD/Kl1NqV5ta+aDY9fm4fTIrv0Q8hbV6lUmPOEvjvKtpv6zf+EwLHyzs+
  36401. ImvaYS5/1HI93TDhHkxAGYwP15zRgzB7mFncfca5DClMoTOi62c6ZYTTluLtdkVwj7Ur3vkj1klu
  36402. PBS1xp81HlDQwY9qcEQCYsuuHWhBp6pX6FOqB9IG9tUUBguRA3UsbHK1YZWaDYu5Def131TN3ubY
  36403. 1gkIl2PlwS6wt0QmwCbAr1UwnjvVNioZBPRcHv/PLLf/0P2HQBHVESO7SMAhqaQoLf0V+LBOK/Qw
  36404. WyH8EZE0vkHve52Xdf+XlcCWWC/qu0bXu+TZLg==
  36405. -----END CERTIFICATE-----
  36406. Cybertrust Global Root
  36407. ======================
  36408. -----BEGIN CERTIFICATE-----
  36409. MIIDoTCCAomgAwIBAgILBAAAAAABD4WqLUgwDQYJKoZIhvcNAQEFBQAwOzEYMBYGA1UEChMPQ3li
  36410. ZXJ0cnVzdCwgSW5jMR8wHQYDVQQDExZDeWJlcnRydXN0IEdsb2JhbCBSb290MB4XDTA2MTIxNTA4
  36411. MDAwMFoXDTIxMTIxNTA4MDAwMFowOzEYMBYGA1UEChMPQ3liZXJ0cnVzdCwgSW5jMR8wHQYDVQQD
  36412. ExZDeWJlcnRydXN0IEdsb2JhbCBSb290MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
  36413. +Mi8vRRQZhP/8NN57CPytxrHjoXxEnOmGaoQ25yiZXRadz5RfVb23CO21O1fWLE3TdVJDm71aofW
  36414. 0ozSJ8bi/zafmGWgE07GKmSb1ZASzxQG9Dvj1Ci+6A74q05IlG2OlTEQXO2iLb3VOm2yHLtgwEZL
  36415. AfVJrn5GitB0jaEMAs7u/OePuGtm839EAL9mJRQr3RAwHQeWP032a7iPt3sMpTjr3kfb1V05/Iin
  36416. 89cqdPHoWqI7n1C6poxFNcJQZZXcY4Lv3b93TZxiyWNzFtApD0mpSPCzqrdsxacwOUBdrsTiXSZT
  36417. 8M4cIwhhqJQZugRiQOwfOHB3EgZxpzAYXSUnpQIDAQABo4GlMIGiMA4GA1UdDwEB/wQEAwIBBjAP
  36418. BgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBS2CHsNesysIEyGVjJez6tuhS1wVzA/BgNVHR8EODA2
  36419. MDSgMqAwhi5odHRwOi8vd3d3Mi5wdWJsaWMtdHJ1c3QuY29tL2NybC9jdC9jdHJvb3QuY3JsMB8G
  36420. A1UdIwQYMBaAFLYIew16zKwgTIZWMl7Pq26FLXBXMA0GCSqGSIb3DQEBBQUAA4IBAQBW7wojoFRO
  36421. lZfJ+InaRcHUowAl9B8Tq7ejhVhpwjCt2BWKLePJzYFa+HMjWqd8BfP9IjsO0QbE2zZMcwSO5bAi
  36422. 5MXzLqXZI+O4Tkogp24CJJ8iYGd7ix1yCcUxXOl5n4BHPa2hCwcUPUf/A2kaDAtE52Mlp3+yybh2
  36423. hO0j9n0Hq0V+09+zv+mKts2oomcrUtW3ZfA5TGOgkXmTUg9U3YO7n9GPp1Nzw8v/MOx8BLjYRB+T
  36424. X3EJIrduPuocA06dGiBh+4E37F78CkWr1+cXVdCg6mCbpvbjjFspwgZgFJ0tl0ypkxWdYcQBX0jW
  36425. WL1WMRJOEcgh4LMRkWXbtKaIOM5V
  36426. -----END CERTIFICATE-----
  36427. ePKI Root Certification Authority
  36428. =================================
  36429. -----BEGIN CERTIFICATE-----
  36430. MIIFsDCCA5igAwIBAgIQFci9ZUdcr7iXAF7kBtK8nTANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQG
  36431. EwJUVzEjMCEGA1UECgwaQ2h1bmdod2EgVGVsZWNvbSBDby4sIEx0ZC4xKjAoBgNVBAsMIWVQS0kg
  36432. Um9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw0wNDEyMjAwMjMxMjdaFw0zNDEyMjAwMjMx
  36433. MjdaMF4xCzAJBgNVBAYTAlRXMSMwIQYDVQQKDBpDaHVuZ2h3YSBUZWxlY29tIENvLiwgTHRkLjEq
  36434. MCgGA1UECwwhZVBLSSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0B
  36435. AQEFAAOCAg8AMIICCgKCAgEA4SUP7o3biDN1Z82tH306Tm2d0y8U82N0ywEhajfqhFAHSyZbCUNs
  36436. IZ5qyNUD9WBpj8zwIuQf5/dqIjG3LBXy4P4AakP/h2XGtRrBp0xtInAhijHyl3SJCRImHJ7K2RKi
  36437. lTza6We/CKBk49ZCt0Xvl/T29de1ShUCWH2YWEtgvM3XDZoTM1PRYfl61dd4s5oz9wCGzh1NlDiv
  36438. qOx4UXCKXBCDUSH3ET00hl7lSM2XgYI1TBnsZfZrxQWh7kcT1rMhJ5QQCtkkO7q+RBNGMD+XPNjX
  36439. 12ruOzjjK9SXDrkb5wdJfzcq+Xd4z1TtW0ado4AOkUPB1ltfFLqfpo0kR0BZv3I4sjZsN/+Z0V0O
  36440. WQqraffAsgRFelQArr5T9rXn4fg8ozHSqf4hUmTFpmfwdQcGlBSBVcYn5AGPF8Fqcde+S/uUWH1+
  36441. ETOxQvdibBjWzwloPn9s9h6PYq2lY9sJpx8iQkEeb5mKPtf5P0B6ebClAZLSnT0IFaUQAS2zMnao
  36442. lQ2zepr7BxB4EW/hj8e6DyUadCrlHJhBmd8hh+iVBmoKs2pHdmX2Os+PYhcZewoozRrSgx4hxyy/
  36443. vv9haLdnG7t4TY3OZ+XkwY63I2binZB1NJipNiuKmpS5nezMirH4JYlcWrYvjB9teSSnUmjDhDXi
  36444. Zo1jDiVN1Rmy5nk3pyKdVDECAwEAAaNqMGgwHQYDVR0OBBYEFB4M97Zn8uGSJglFwFU5Lnc/Qkqi
  36445. MAwGA1UdEwQFMAMBAf8wOQYEZyoHAAQxMC8wLQIBADAJBgUrDgMCGgUAMAcGBWcqAwAABBRFsMLH
  36446. ClZ87lt4DJX5GFPBphzYEDANBgkqhkiG9w0BAQUFAAOCAgEACbODU1kBPpVJufGBuvl2ICO1J2B0
  36447. 1GqZNF5sAFPZn/KmsSQHRGoqxqWOeBLoR9lYGxMqXnmbnwoqZ6YlPwZpVnPDimZI+ymBV3QGypzq
  36448. KOg4ZyYr8dW1P2WT+DZdjo2NQCCHGervJ8A9tDkPJXtoUHRVnAxZfVo9QZQlUgjgRywVMRnVvwdV
  36449. xrsStZf0X4OFunHB2WyBEXYKCrC/gpf36j36+uwtqSiUO1bd0lEursC9CBWMd1I0ltabrNMdjmEP
  36450. NXubrjlpC2JgQCA2j6/7Nu4tCEoduL+bXPjqpRugc6bY+G7gMwRfaKonh+3ZwZCc7b3jajWvY9+r
  36451. GNm65ulK6lCKD2GTHuItGeIwlDWSXQ62B68ZgI9HkFFLLk3dheLSClIKF5r8GrBQAuUBo2M3IUxE
  36452. xJtRmREOc5wGj1QupyheRDmHVi03vYVElOEMSyycw5KFNGHLD7ibSkNS/jQ6fbjpKdx2qcgw+BRx
  36453. gMYeNkh0IkFch4LoGHGLQYlE535YW6i4jRPpp2zDR+2zGp1iro2C6pSe3VkQw63d4k3jMdXH7Ojy
  36454. sP6SHhYKGvzZ8/gntsm+HbRsZJB/9OTEW9c3rkIO3aQab3yIVMUWbuF6aC74Or8NpDyJO3inTmOD
  36455. BCEIZ43ygknQW/2xzQ+DhNQ+IIX3Sj0rnP0qCglN6oH4EZw=
  36456. -----END CERTIFICATE-----
  36457. certSIGN ROOT CA
  36458. ================
  36459. -----BEGIN CERTIFICATE-----
  36460. MIIDODCCAiCgAwIBAgIGIAYFFnACMA0GCSqGSIb3DQEBBQUAMDsxCzAJBgNVBAYTAlJPMREwDwYD
  36461. VQQKEwhjZXJ0U0lHTjEZMBcGA1UECxMQY2VydFNJR04gUk9PVCBDQTAeFw0wNjA3MDQxNzIwMDRa
  36462. Fw0zMTA3MDQxNzIwMDRaMDsxCzAJBgNVBAYTAlJPMREwDwYDVQQKEwhjZXJ0U0lHTjEZMBcGA1UE
  36463. CxMQY2VydFNJR04gUk9PVCBDQTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALczuX7I
  36464. JUqOtdu0KBuqV5Do0SLTZLrTk+jUrIZhQGpgV2hUhE28alQCBf/fm5oqrl0Hj0rDKH/v+yv6efHH
  36465. rfAQUySQi2bJqIirr1qjAOm+ukbuW3N7LBeCgV5iLKECZbO9xSsAfsT8AzNXDe3i+s5dRdY4zTW2
  36466. ssHQnIFKquSyAVwdj1+ZxLGt24gh65AIgoDzMKND5pCCrlUoSe1b16kQOA7+j0xbm0bqQfWwCHTD
  36467. 0IgztnzXdN/chNFDDnU5oSVAKOp4yw4sLjmdjItuFhwvJoIQ4uNllAoEwF73XVv4EOLQunpL+943
  36468. AAAaWyjj0pxzPjKHmKHJUS/X3qwzs08CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8B
  36469. Af8EBAMCAcYwHQYDVR0OBBYEFOCMm9slSbPxfIbWskKHC9BroNnkMA0GCSqGSIb3DQEBBQUAA4IB
  36470. AQA+0hyJLjX8+HXd5n9liPRyTMks1zJO890ZeUe9jjtbkw9QSSQTaxQGcu8J06Gh40CEyecYMnQ8
  36471. SG4Pn0vU9x7Tk4ZkVJdjclDVVc/6IJMCopvDI5NOFlV2oHB5bc0hH88vLbwZ44gx+FkagQnIl6Z0
  36472. x2DEW8xXjrJ1/RsCCdtZb3KTafcxQdaIOL+Hsr0Wefmq5L6IJd1hJyMctTEHBDa0GpC9oHRxUIlt
  36473. vBTjD4au8as+x6AJzKNI0eDbZOeStc+vckNwi/nDhDwTqn6Sm1dTk/pwwpEOMfmbZ13pljheX7Nz
  36474. TogVZ96edhBiIL5VaZVDADlN9u6wWk5JRFRYX0KD
  36475. -----END CERTIFICATE-----
  36476. GeoTrust Primary Certification Authority - G3
  36477. =============================================
  36478. -----BEGIN CERTIFICATE-----
  36479. MIID/jCCAuagAwIBAgIQFaxulBmyeUtB9iepwxgPHzANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UE
  36480. BhMCVVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA4IEdlb1RydXN0
  36481. IEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFy
  36482. eSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEczMB4XDTA4MDQwMjAwMDAwMFoXDTM3MTIwMTIz
  36483. NTk1OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAo
  36484. YykgMjAwOCBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMT
  36485. LUdlb1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMzCCASIwDQYJKoZI
  36486. hvcNAQEBBQADggEPADCCAQoCggEBANziXmJYHTNXOTIz+uvLh4yn1ErdBojqZI4xmKU4kB6Yzy5j
  36487. K/BGvESyiaHAKAxJcCGVn2TAppMSAmUmhsalifD614SgcK9PGpc/BkTVyetyEH3kMSj7HGHmKAdE
  36488. c5IiaacDiGydY8hS2pgn5whMcD60yRLBxWeDXTPzAxHsatBT4tG6NmCUgLthY2xbF37fQJQeqw3C
  36489. IShwiP/WJmxsYAQlTlV+fe+/lEjetx3dcI0FX4ilm/LC7urRQEFtYjgdVgbFA0dRIBn8exALDmKu
  36490. dlW/X3e+PkkBUz2YJQN2JFodtNuJ6nnltrM7P7pMKEF/BqxqjsHQ9gUdfeZChuOl1UcCAwEAAaNC
  36491. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFMR5yo6hTgMdHNxr
  36492. 2zFblD4/MH8tMA0GCSqGSIb3DQEBCwUAA4IBAQAtxRPPVoB7eni9n64smefv2t+UXglpp+duaIy9
  36493. cr5HqQ6XErhK8WTTOd8lNNTBzU6B8A8ExCSzNJbGpqow32hhc9f5joWJ7w5elShKKiePEI4ufIbE
  36494. Ap7aDHdlDkQNkv39sxY2+hENHYwOB4lqKVb3cvTdFZx3NWZXqxNT2I7BQMXXExZacse3aQHEerGD
  36495. AWh9jUGhlBjBJVz88P6DAod8DQ3PLghcSkANPuyBYeYk28rgDi0Hsj5W3I31QYUHSJsMC8tJP33s
  36496. t/3LjWeJGqvtux6jAAgIFyqCXDFdRootD4abdNlF+9RAsXqqaC2Gspki4cErx5z481+oghLrGREt
  36497. -----END CERTIFICATE-----
  36498. thawte Primary Root CA - G2
  36499. ===========================
  36500. -----BEGIN CERTIFICATE-----
  36501. MIICiDCCAg2gAwIBAgIQNfwmXNmET8k9Jj1Xm67XVjAKBggqhkjOPQQDAzCBhDELMAkGA1UEBhMC
  36502. VVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjE4MDYGA1UECxMvKGMpIDIwMDcgdGhhd3RlLCBJbmMu
  36503. IC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3Qg
  36504. Q0EgLSBHMjAeFw0wNzExMDUwMDAwMDBaFw0zODAxMTgyMzU5NTlaMIGEMQswCQYDVQQGEwJVUzEV
  36505. MBMGA1UEChMMdGhhd3RlLCBJbmMuMTgwNgYDVQQLEy8oYykgMjAwNyB0aGF3dGUsIEluYy4gLSBG
  36506. b3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIGA1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAt
  36507. IEcyMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEotWcgnuVnfFSeIf+iha/BebfowJPDQfGAFG6DAJS
  36508. LSKkQjnE/o/qycG+1E3/n3qe4rF8mq2nhglzh9HnmuN6papu+7qzcMBniKI11KOasf2twu8x+qi5
  36509. 8/sIxpHR+ymVo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU
  36510. mtgAMADna3+FGO6Lts6KDPgR4bswCgYIKoZIzj0EAwMDaQAwZgIxAN344FdHW6fmCsO99YCKlzUN
  36511. G4k8VIZ3KMqh9HneteY4sPBlcIx/AlTCv//YoT7ZzwIxAMSNlPzcU9LcnXgWHxUzI1NS41oxXZ3K
  36512. rr0TKUQNJ1uo52icEvdYPy5yAlejj6EULg==
  36513. -----END CERTIFICATE-----
  36514. thawte Primary Root CA - G3
  36515. ===========================
  36516. -----BEGIN CERTIFICATE-----
  36517. MIIEKjCCAxKgAwIBAgIQYAGXt0an6rS0mtZLL/eQ+zANBgkqhkiG9w0BAQsFADCBrjELMAkGA1UE
  36518. BhMCVVMxFTATBgNVBAoTDHRoYXd0ZSwgSW5jLjEoMCYGA1UECxMfQ2VydGlmaWNhdGlvbiBTZXJ2
  36519. aWNlcyBEaXZpc2lvbjE4MDYGA1UECxMvKGMpIDIwMDggdGhhd3RlLCBJbmMuIC0gRm9yIGF1dGhv
  36520. cml6ZWQgdXNlIG9ubHkxJDAiBgNVBAMTG3RoYXd0ZSBQcmltYXJ5IFJvb3QgQ0EgLSBHMzAeFw0w
  36521. ODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIGuMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMdGhh
  36522. d3RlLCBJbmMuMSgwJgYDVQQLEx9DZXJ0aWZpY2F0aW9uIFNlcnZpY2VzIERpdmlzaW9uMTgwNgYD
  36523. VQQLEy8oYykgMjAwOCB0aGF3dGUsIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTEkMCIG
  36524. A1UEAxMbdGhhd3RlIFByaW1hcnkgUm9vdCBDQSAtIEczMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  36525. MIIBCgKCAQEAsr8nLPvb2FvdeHsbnndmgcs+vHyu86YnmjSjaDFxODNi5PNxZnmxqWWjpYvVj2At
  36526. P0LMqmsywCPLLEHd5N/8YZzic7IilRFDGF/Eth9XbAoFWCLINkw6fKXRz4aviKdEAhN0cXMKQlkC
  36527. +BsUa0Lfb1+6a4KinVvnSr0eAXLbS3ToO39/fR8EtCab4LRarEc9VbjXsCZSKAExQGbY2SS99irY
  36528. 7CFJXJv2eul/VTV+lmuNk5Mny5K76qxAwJ/C+IDPXfRa3M50hqY+bAtTyr2SzhkGcuYMXDhpxwTW
  36529. vGzOW/b3aJzcJRVIiKHpqfiYnODz1TEoYRFsZ5aNOZnLwkUkOQIDAQABo0IwQDAPBgNVHRMBAf8E
  36530. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUrWyqlGCc7eT/+j4KdCtjA/e2Wb8wDQYJ
  36531. KoZIhvcNAQELBQADggEBABpA2JVlrAmSicY59BDlqQ5mU1143vokkbvnRFHfxhY0Cu9qRFHqKweK
  36532. A3rD6z8KLFIWoCtDuSWQP3CpMyVtRRooOyfPqsMpQhvfO0zAMzRbQYi/aytlryjvsvXDqmbOe1bu
  36533. t8jLZ8HJnBoYuMTDSQPxYA5QzUbF83d597YV4Djbxy8ooAw/dyZ02SUS2jHaGh7cKUGRIjxpp7sC
  36534. 8rZcJwOJ9Abqm+RyguOhCcHpABnTPtRwa7pxpqpYrvS76Wy274fMm7v/OeZWYdMKp8RcTGB7BXcm
  36535. er/YB1IsYvdwY9k5vG8cwnncdimvzsUsZAReiDZuMdRAGmI0Nj81Aa6sY6A=
  36536. -----END CERTIFICATE-----
  36537. GeoTrust Primary Certification Authority - G2
  36538. =============================================
  36539. -----BEGIN CERTIFICATE-----
  36540. MIICrjCCAjWgAwIBAgIQPLL0SAoA4v7rJDteYD7DazAKBggqhkjOPQQDAzCBmDELMAkGA1UEBhMC
  36541. VVMxFjAUBgNVBAoTDUdlb1RydXN0IEluYy4xOTA3BgNVBAsTMChjKSAyMDA3IEdlb1RydXN0IElu
  36542. Yy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25seTE2MDQGA1UEAxMtR2VvVHJ1c3QgUHJpbWFyeSBD
  36543. ZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMB4XDTA3MTEwNTAwMDAwMFoXDTM4MDExODIzNTk1
  36544. OVowgZgxCzAJBgNVBAYTAlVTMRYwFAYDVQQKEw1HZW9UcnVzdCBJbmMuMTkwNwYDVQQLEzAoYykg
  36545. MjAwNyBHZW9UcnVzdCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxNjA0BgNVBAMTLUdl
  36546. b1RydXN0IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjB2MBAGByqGSM49AgEG
  36547. BSuBBAAiA2IABBWx6P0DFUPlrOuHNxFi79KDNlJ9RVcLSo17VDs6bl8VAsBQps8lL33KSLjHUGMc
  36548. KiEIfJo22Av+0SbFWDEwKCXzXV2juLaltJLtbCyf691DiaI8S0iRHVDsJt/WYC69IaNCMEAwDwYD
  36549. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFBVfNVdRVfslsq0DafwBo/q+
  36550. EVXVMAoGCCqGSM49BAMDA2cAMGQCMGSWWaboCd6LuvpaiIjwH5HTRqjySkwCY/tsXzjbLkGTqQ7m
  36551. ndwxHLKgpxgceeHHNgIwOlavmnRs9vuD4DPTCF+hnMJbn0bWtsuRBmOiBuczrD6ogRLQy7rQkgu2
  36552. npaqBA+K
  36553. -----END CERTIFICATE-----
  36554. VeriSign Universal Root Certification Authority
  36555. ===============================================
  36556. -----BEGIN CERTIFICATE-----
  36557. MIIEuTCCA6GgAwIBAgIQQBrEZCGzEyEDDrvkEhrFHTANBgkqhkiG9w0BAQsFADCBvTELMAkGA1UE
  36558. BhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBO
  36559. ZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwOCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVk
  36560. IHVzZSBvbmx5MTgwNgYDVQQDEy9WZXJpU2lnbiBVbml2ZXJzYWwgUm9vdCBDZXJ0aWZpY2F0aW9u
  36561. IEF1dGhvcml0eTAeFw0wODA0MDIwMDAwMDBaFw0zNzEyMDEyMzU5NTlaMIG9MQswCQYDVQQGEwJV
  36562. UzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlTaWduIFRydXN0IE5ldHdv
  36563. cmsxOjA4BgNVBAsTMShjKSAyMDA4IFZlcmlTaWduLCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNl
  36564. IG9ubHkxODA2BgNVBAMTL1ZlcmlTaWduIFVuaXZlcnNhbCBSb290IENlcnRpZmljYXRpb24gQXV0
  36565. aG9yaXR5MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAx2E3XrEBNNti1xWb/1hajCMj
  36566. 1mCOkdeQmIN65lgZOIzF9uVkhbSicfvtvbnazU0AtMgtc6XHaXGVHzk8skQHnOgO+k1KxCHfKWGP
  36567. MiJhgsWHH26MfF8WIFFE0XBPV+rjHOPMee5Y2A7Cs0WTwCznmhcrewA3ekEzeOEz4vMQGn+HLL72
  36568. 9fdC4uW/h2KJXwBL38Xd5HVEMkE6HnFuacsLdUYI0crSK5XQz/u5QGtkjFdN/BMReYTtXlT2NJ8I
  36569. AfMQJQYXStrxHXpma5hgZqTZ79IugvHw7wnqRMkVauIDbjPTrJ9VAMf2CGqUuV/c4DPxhGD5WycR
  36570. tPwW8rtWaoAljQIDAQABo4GyMIGvMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMG0G
  36571. CCsGAQUFBwEMBGEwX6FdoFswWTBXMFUWCWltYWdlL2dpZjAhMB8wBwYFKw4DAhoEFI/l0xqGrI2O
  36572. a8PPgGrUSBgsexkuMCUWI2h0dHA6Ly9sb2dvLnZlcmlzaWduLmNvbS92c2xvZ28uZ2lmMB0GA1Ud
  36573. DgQWBBS2d/ppSEefUxLVwuoHMnYH0ZcHGTANBgkqhkiG9w0BAQsFAAOCAQEASvj4sAPmLGd75JR3
  36574. Y8xuTPl9Dg3cyLk1uXBPY/ok+myDjEedO2Pzmvl2MpWRsXe8rJq+seQxIcaBlVZaDrHC1LGmWazx
  36575. Y8u4TB1ZkErvkBYoH1quEPuBUDgMbMzxPcP1Y+Oz4yHJJDnp/RVmRvQbEdBNc6N9Rvk97ahfYtTx
  36576. P/jgdFcrGJ2BtMQo2pSXpXDrrB2+BxHw1dvd5Yzw1TKwg+ZX4o+/vqGqvz0dtdQ46tewXDpPaj+P
  36577. wGZsY6rp2aQW9IHRlRQOfc2VNNnSj3BzgXucfr2YYdhFh5iQxeuGMMY1v/D/w1WIg0vvBZIGcfK4
  36578. mJO37M2CYfE45k+XmCpajQ==
  36579. -----END CERTIFICATE-----
  36580. VeriSign Class 3 Public Primary Certification Authority - G4
  36581. ============================================================
  36582. -----BEGIN CERTIFICATE-----
  36583. MIIDhDCCAwqgAwIBAgIQL4D+I4wOIg9IZxIokYesszAKBggqhkjOPQQDAzCByjELMAkGA1UEBhMC
  36584. VVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3
  36585. b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVz
  36586. ZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmlj
  36587. YXRpb24gQXV0aG9yaXR5IC0gRzQwHhcNMDcxMTA1MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCByjEL
  36588. MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBU
  36589. cnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNyBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRo
  36590. b3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5
  36591. IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzQwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAASnVnp8
  36592. Utpkmw4tXNherJI9/gHmGUo9FANL+mAnINmDiWn6VMaaGF5VKmTeBvaNSjutEDxlPZCIBIngMGGz
  36593. rl0Bp3vefLK+ymVhAIau2o970ImtTR1ZmkGxvEeA3J5iw/mjgbIwga8wDwYDVR0TAQH/BAUwAwEB
  36594. /zAOBgNVHQ8BAf8EBAMCAQYwbQYIKwYBBQUHAQwEYTBfoV2gWzBZMFcwVRYJaW1hZ2UvZ2lmMCEw
  36595. HzAHBgUrDgMCGgQUj+XTGoasjY5rw8+AatRIGCx7GS4wJRYjaHR0cDovL2xvZ28udmVyaXNpZ24u
  36596. Y29tL3ZzbG9nby5naWYwHQYDVR0OBBYEFLMWkf3upm7ktS5Jj4d4gYDs5bG1MAoGCCqGSM49BAMD
  36597. A2gAMGUCMGYhDBgmYFo4e1ZC4Kf8NoRRkSAsdk1DPcQdhCPQrNZ8NQbOzWm9kA3bbEhCHQ6qQgIx
  36598. AJw9SDkjOVgaFRJZap7v1VmyHVIsmXHNxynfGyphe3HR3vPA5Q06Sqotp9iGKt0uEA==
  36599. -----END CERTIFICATE-----
  36600. NetLock Arany (Class Gold) Főtanúsítvány
  36601. ========================================
  36602. -----BEGIN CERTIFICATE-----
  36603. MIIEFTCCAv2gAwIBAgIGSUEs5AAQMA0GCSqGSIb3DQEBCwUAMIGnMQswCQYDVQQGEwJIVTERMA8G
  36604. A1UEBwwIQnVkYXBlc3QxFTATBgNVBAoMDE5ldExvY2sgS2Z0LjE3MDUGA1UECwwuVGFuw7pzw610
  36605. dsOhbnlraWFkw7NrIChDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzKTE1MDMGA1UEAwwsTmV0TG9jayBB
  36606. cmFueSAoQ2xhc3MgR29sZCkgRsWRdGFuw7pzw610dsOhbnkwHhcNMDgxMjExMTUwODIxWhcNMjgx
  36607. MjA2MTUwODIxWjCBpzELMAkGA1UEBhMCSFUxETAPBgNVBAcMCEJ1ZGFwZXN0MRUwEwYDVQQKDAxO
  36608. ZXRMb2NrIEtmdC4xNzA1BgNVBAsMLlRhbsO6c8OtdHbDoW55a2lhZMOzayAoQ2VydGlmaWNhdGlv
  36609. biBTZXJ2aWNlcykxNTAzBgNVBAMMLE5ldExvY2sgQXJhbnkgKENsYXNzIEdvbGQpIEbFkXRhbsO6
  36610. c8OtdHbDoW55MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxCRec75LbRTDofTjl5Bu
  36611. 0jBFHjzuZ9lk4BqKf8owyoPjIMHj9DrTlF8afFttvzBPhCf2nx9JvMaZCpDyD/V/Q4Q3Y1GLeqVw
  36612. /HpYzY6b7cNGbIRwXdrzAZAj/E4wqX7hJ2Pn7WQ8oLjJM2P+FpD/sLj916jAwJRDC7bVWaaeVtAk
  36613. H3B5r9s5VA1lddkVQZQBr17s9o3x/61k/iCa11zr/qYfCGSji3ZVrR47KGAuhyXoqq8fxmRGILdw
  36614. fzzeSNuWU7c5d+Qa4scWhHaXWy+7GRWF+GmF9ZmnqfI0p6m2pgP8b4Y9VHx2BJtr+UBdADTHLpl1
  36615. neWIA6pN+APSQnbAGwIDAKiLo0UwQzASBgNVHRMBAf8ECDAGAQH/AgEEMA4GA1UdDwEB/wQEAwIB
  36616. BjAdBgNVHQ4EFgQUzPpnk/C2uNClwB7zU/2MU9+D15YwDQYJKoZIhvcNAQELBQADggEBAKt/7hwW
  36617. qZw8UQCgwBEIBaeZ5m8BiFRhbvG5GK1Krf6BQCOUL/t1fC8oS2IkgYIL9WHxHG64YTjrgfpioTta
  36618. YtOUZcTh5m2C+C8lcLIhJsFyUR+MLMOEkMNaj7rP9KdlpeuY0fsFskZ1FSNqb4VjMIDw1Z4fKRzC
  36619. bLBQWV2QWzuoDTDPv31/zvGdg73JRm4gpvlhUbohL3u+pRVjodSVh/GeufOJ8z2FuLjbvrW5Kfna
  36620. NwUASZQDhETnv0Mxz3WLJdH0pmT1kvarBes96aULNmLazAZfNou2XjG4Kvte9nHfRCaexOYNkbQu
  36621. dZWAUWpLMKawYqGT8ZvYzsRjdT9ZR7E=
  36622. -----END CERTIFICATE-----
  36623. Hongkong Post Root CA 1
  36624. =======================
  36625. -----BEGIN CERTIFICATE-----
  36626. MIIDMDCCAhigAwIBAgICA+gwDQYJKoZIhvcNAQEFBQAwRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoT
  36627. DUhvbmdrb25nIFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMB4XDTAzMDUx
  36628. NTA1MTMxNFoXDTIzMDUxNTA0NTIyOVowRzELMAkGA1UEBhMCSEsxFjAUBgNVBAoTDUhvbmdrb25n
  36629. IFBvc3QxIDAeBgNVBAMTF0hvbmdrb25nIFBvc3QgUm9vdCBDQSAxMIIBIjANBgkqhkiG9w0BAQEF
  36630. AAOCAQ8AMIIBCgKCAQEArP84tulmAknjorThkPlAj3n54r15/gK97iSSHSL22oVyaf7XPwnU3ZG1
  36631. ApzQjVrhVcNQhrkpJsLj2aDxaQMoIIBFIi1WpztUlVYiWR8o3x8gPW2iNr4joLFutbEnPzlTCeqr
  36632. auh0ssJlXI6/fMN4hM2eFvz1Lk8gKgifd/PFHsSaUmYeSF7jEAaPIpjhZY4bXSNmO7ilMlHIhqqh
  36633. qZ5/dpTCpmy3QfDVyAY45tQM4vM7TG1QjMSDJ8EThFk9nnV0ttgCXjqQesBCNnLsak3c78QA3xMY
  36634. V18meMjWCnl3v/evt3a5pQuEF10Q6m/hq5URX208o1xNg1vysxmKgIsLhwIDAQABoyYwJDASBgNV
  36635. HRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIBxjANBgkqhkiG9w0BAQUFAAOCAQEADkbVPK7i
  36636. h9legYsCmEEIjEy82tvuJxuC52pF7BaLT4Wg87JwvVqWuspube5Gi27nKi6Wsxkz67SfqLI37pio
  36637. l7Yutmcn1KZJ/RyTZXaeQi/cImyaT/JaFTmxcdcrUehtHJjA2Sr0oYJ71clBoiMBdDhViw+5Lmei
  36638. IAQ32pwL0xch4I+XeTRvhEgCIDMb5jREn5Fw9IBehEPCKdJsEhTkYY2sEJCehFC78JZvRZ+K88ps
  36639. T/oROhUVRsPNH4NbLUES7VBnQRM9IauUiqpOfMGx+6fWtScvl6tu4B3i0RwsH0Ti/L6RoZz71ilT
  36640. c4afU9hDDl3WY4JxHYB0yvbiAmvZWg==
  36641. -----END CERTIFICATE-----
  36642. SecureSign RootCA11
  36643. ===================
  36644. -----BEGIN CERTIFICATE-----
  36645. MIIDbTCCAlWgAwIBAgIBATANBgkqhkiG9w0BAQUFADBYMQswCQYDVQQGEwJKUDErMCkGA1UEChMi
  36646. SmFwYW4gQ2VydGlmaWNhdGlvbiBTZXJ2aWNlcywgSW5jLjEcMBoGA1UEAxMTU2VjdXJlU2lnbiBS
  36647. b290Q0ExMTAeFw0wOTA0MDgwNDU2NDdaFw0yOTA0MDgwNDU2NDdaMFgxCzAJBgNVBAYTAkpQMSsw
  36648. KQYDVQQKEyJKYXBhbiBDZXJ0aWZpY2F0aW9uIFNlcnZpY2VzLCBJbmMuMRwwGgYDVQQDExNTZWN1
  36649. cmVTaWduIFJvb3RDQTExMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA/XeqpRyQBTvL
  36650. TJszi1oURaTnkBbR31fSIRCkF/3frNYfp+TbfPfs37gD2pRY/V1yfIw/XwFndBWW4wI8h9uuywGO
  36651. wvNmxoVF9ALGOrVisq/6nL+k5tSAMJjzDbaTj6nU2DbysPyKyiyhFTOVMdrAG/LuYpmGYz+/3ZMq
  36652. g6h2uRMft85OQoWPIucuGvKVCbIFtUROd6EgvanyTgp9UK31BQ1FT0Zx/Sg+U/sE2C3XZR1KG/rP
  36653. O7AxmjVuyIsG0wCR8pQIZUyxNAYAeoni8McDWc/V1uinMrPmmECGxc0nEovMe863ETxiYAcjPitA
  36654. bpSACW22s293bzUIUPsCh8U+iQIDAQABo0IwQDAdBgNVHQ4EFgQUW/hNT7KlhtQ60vFjmqC+CfZX
  36655. t94wDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEFBQADggEBAKCh
  36656. OBZmLqdWHyGcBvod7bkixTgm2E5P7KN/ed5GIaGHd48HCJqypMWvDzKYC3xmKbabfSVSSUOrTC4r
  36657. bnpwrxYO4wJs+0LmGJ1F2FXI6Dvd5+H0LgscNFxsWEr7jIhQX5Ucv+2rIrVls4W6ng+4reV6G4pQ
  36658. Oh29Dbx7VFALuUKvVaAYga1lme++5Jy/xIWrQbJUb9wlze144o4MjQlJ3WN7WmmWAiGovVJZ6X01
  36659. y8hSyn+B/tlr0/cR7SXf+Of5pPpyl4RTDaXQMhhRdlkUbA/r7F+AjHVDg8OFmP9Mni0N5HeDk061
  36660. lgeLKBObjBmNQSdJQO7e5iNEOdyhIta6A/I=
  36661. -----END CERTIFICATE-----
  36662. Microsec e-Szigno Root CA 2009
  36663. ==============================
  36664. -----BEGIN CERTIFICATE-----
  36665. MIIECjCCAvKgAwIBAgIJAMJ+QwRORz8ZMA0GCSqGSIb3DQEBCwUAMIGCMQswCQYDVQQGEwJIVTER
  36666. MA8GA1UEBwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jv
  36667. c2VjIGUtU3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5o
  36668. dTAeFw0wOTA2MTYxMTMwMThaFw0yOTEyMzAxMTMwMThaMIGCMQswCQYDVQQGEwJIVTERMA8GA1UE
  36669. BwwIQnVkYXBlc3QxFjAUBgNVBAoMDU1pY3Jvc2VjIEx0ZC4xJzAlBgNVBAMMHk1pY3Jvc2VjIGUt
  36670. U3ppZ25vIFJvb3QgQ0EgMjAwOTEfMB0GCSqGSIb3DQEJARYQaW5mb0BlLXN6aWduby5odTCCASIw
  36671. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAOn4j/NjrdqG2KfgQvvPkd6mJviZpWNwrZuuyjNA
  36672. fW2WbqEORO7hE52UQlKavXWFdCyoDh2Tthi3jCyoz/tccbna7P7ofo/kLx2yqHWH2Leh5TvPmUpG
  36673. 0IMZfcChEhyVbUr02MelTTMuhTlAdX4UfIASmFDHQWe4oIBhVKZsTh/gnQ4H6cm6M+f+wFUoLAKA
  36674. pxn1ntxVUwOXewdI/5n7N4okxFnMUBBjjqqpGrCEGob5X7uxUG6k0QrM1XF+H6cbfPVTbiJfyyvm
  36675. 1HxdrtbCxkzlBQHZ7Vf8wSN5/PrIJIOV87VqUQHQd9bpEqH5GoP7ghu5sJf0dgYzQ0mg/wu1+rUC
  36676. AwEAAaOBgDB+MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBTLD8bf
  36677. QkPMPcu1SCOhGnqmKrs0aDAfBgNVHSMEGDAWgBTLD8bfQkPMPcu1SCOhGnqmKrs0aDAbBgNVHREE
  36678. FDASgRBpbmZvQGUtc3ppZ25vLmh1MA0GCSqGSIb3DQEBCwUAA4IBAQDJ0Q5eLtXMs3w+y/w9/w0o
  36679. lZMEyL/azXm4Q5DwpL7v8u8hmLzU1F0G9u5C7DBsoKqpyvGvivo/C3NqPuouQH4frlRheesuCDfX
  36680. I/OMn74dseGkddug4lQUsbocKaQY9hK6ohQU4zE1yED/t+AFdlfBHFny+L/k7SViXITwfn4fs775
  36681. tyERzAMBVnCnEJIeGzSBHq2cGsMEPO0CYdYeBvNfOofyK/FFh+U9rNHHV4S9a67c2Pm2G2JwCz02
  36682. yULyMtd6YebS2z3PyKnJm9zbWETXbzivf3jTo60adbocwTZ8jx5tHMN1Rq41Bab2XD0h7lbwyYIi
  36683. LXpUq3DDfSJlgnCW
  36684. -----END CERTIFICATE-----
  36685. GlobalSign Root CA - R3
  36686. =======================
  36687. -----BEGIN CERTIFICATE-----
  36688. MIIDXzCCAkegAwIBAgILBAAAAAABIVhTCKIwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UECxMXR2xv
  36689. YmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
  36690. bFNpZ24wHhcNMDkwMzE4MTAwMDAwWhcNMjkwMzE4MTAwMDAwWjBMMSAwHgYDVQQLExdHbG9iYWxT
  36691. aWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFsU2ln
  36692. bjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMwldpB5BngiFvXAg7aEyiie/QV2EcWt
  36693. iHL8RgJDx7KKnQRfJMsuS+FggkbhUqsMgUdwbN1k0ev1LKMPgj0MK66X17YUhhB5uzsTgHeMCOFJ
  36694. 0mpiLx9e+pZo34knlTifBtc+ycsmWQ1z3rDI6SYOgxXG71uL0gRgykmmKPZpO/bLyCiR5Z2KYVc3
  36695. rHQU3HTgOu5yLy6c+9C7v/U9AOEGM+iCK65TpjoWc4zdQQ4gOsC0p6Hpsk+QLjJg6VfLuQSSaGjl
  36696. OCZgdbKfd/+RFO+uIEn8rUAVSNECMWEZXriX7613t2Saer9fwRPvm2L7DWzgVGkWqQPabumDk3F2
  36697. xmmFghcCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  36698. FI/wS3+oLkUkrk1Q+mOai97i3Ru8MA0GCSqGSIb3DQEBCwUAA4IBAQBLQNvAUKr+yAzv95ZURUm7
  36699. lgAJQayzE4aGKAczymvmdLm6AC2upArT9fHxD4q/c2dKg8dEe3jgr25sbwMpjjM5RcOO5LlXbKr8
  36700. EpbsU8Yt5CRsuZRj+9xTaGdWPoO4zzUhw8lo/s7awlOqzJCK6fBdRoyV3XpYKBovHd7NADdBj+1E
  36701. bddTKJd+82cEHhXXipa0095MJ6RMG3NzdvQXmcIfeg7jLQitChws/zyrVQ4PkX4268NXSb7hLi18
  36702. YIvDQVETI53O9zJrlAGomecsMx86OyXShkDOOyyGeMlhLxS67ttVb9+E7gUJTb0o2HLO02JQZR7r
  36703. kpeDMdmztcpHWD9f
  36704. -----END CERTIFICATE-----
  36705. Autoridad de Certificacion Firmaprofesional CIF A62634068
  36706. =========================================================
  36707. -----BEGIN CERTIFICATE-----
  36708. MIIGFDCCA/ygAwIBAgIIU+w77vuySF8wDQYJKoZIhvcNAQEFBQAwUTELMAkGA1UEBhMCRVMxQjBA
  36709. BgNVBAMMOUF1dG9yaWRhZCBkZSBDZXJ0aWZpY2FjaW9uIEZpcm1hcHJvZmVzaW9uYWwgQ0lGIEE2
  36710. MjYzNDA2ODAeFw0wOTA1MjAwODM4MTVaFw0zMDEyMzEwODM4MTVaMFExCzAJBgNVBAYTAkVTMUIw
  36711. QAYDVQQDDDlBdXRvcmlkYWQgZGUgQ2VydGlmaWNhY2lvbiBGaXJtYXByb2Zlc2lvbmFsIENJRiBB
  36712. NjI2MzQwNjgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKlmuO6vj78aI14H9M2uDD
  36713. Utd9thDIAl6zQyrET2qyyhxdKJp4ERppWVevtSBC5IsP5t9bpgOSL/UR5GLXMnE42QQMcas9UX4P
  36714. B99jBVzpv5RvwSmCwLTaUbDBPLutN0pcyvFLNg4kq7/DhHf9qFD0sefGL9ItWY16Ck6WaVICqjaY
  36715. 7Pz6FIMMNx/Jkjd/14Et5cS54D40/mf0PmbR0/RAz15iNA9wBj4gGFrO93IbJWyTdBSTo3OxDqqH
  36716. ECNZXyAFGUftaI6SEspd/NYrspI8IM/hX68gvqB2f3bl7BqGYTM+53u0P6APjqK5am+5hyZvQWyI
  36717. plD9amML9ZMWGxmPsu2bm8mQ9QEM3xk9Dz44I8kvjwzRAv4bVdZO0I08r0+k8/6vKtMFnXkIoctX
  36718. MbScyJCyZ/QYFpM6/EfY0XiWMR+6KwxfXZmtY4laJCB22N/9q06mIqqdXuYnin1oKaPnirjaEbsX
  36719. LZmdEyRG98Xi2J+Of8ePdG1asuhy9azuJBCtLxTa/y2aRnFHvkLfuwHb9H/TKI8xWVvTyQKmtFLK
  36720. bpf7Q8UIJm+K9Lv9nyiqDdVF8xM6HdjAeI9BZzwelGSuewvF6NkBiDkal4ZkQdU7hwxu+g/GvUgU
  36721. vzlN1J5Bto+WHWOWk9mVBngxaJ43BjuAiUVhOSPHG0SjFeUc+JIwuwIDAQABo4HvMIHsMBIGA1Ud
  36722. EwEB/wQIMAYBAf8CAQEwDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRlzeurNR4APn7VdMActHNH
  36723. DhpkLzCBpgYDVR0gBIGeMIGbMIGYBgRVHSAAMIGPMC8GCCsGAQUFBwIBFiNodHRwOi8vd3d3LmZp
  36724. cm1hcHJvZmVzaW9uYWwuY29tL2NwczBcBggrBgEFBQcCAjBQHk4AUABhAHMAZQBvACAAZABlACAA
  36725. bABhACAAQgBvAG4AYQBuAG8AdgBhACAANAA3ACAAQgBhAHIAYwBlAGwAbwBuAGEAIAAwADgAMAAx
  36726. ADcwDQYJKoZIhvcNAQEFBQADggIBABd9oPm03cXF661LJLWhAqvdpYhKsg9VSytXjDvlMd3+xDLx
  36727. 51tkljYyGOylMnfX40S2wBEqgLk9am58m9Ot/MPWo+ZkKXzR4Tgegiv/J2Wv+xYVxC5xhOW1//qk
  36728. R71kMrv2JYSiJ0L1ILDCExARzRAVukKQKtJE4ZYm6zFIEv0q2skGz3QeqUvVhyj5eTSSPi5E6PaP
  36729. T481PyWzOdxjKpBrIF/EUhJOlywqrJ2X3kjyo2bbwtKDlaZmp54lD+kLM5FlClrD2VQS3a/DTg4f
  36730. Jl4N3LON7NWBcN7STyQF82xO9UxJZo3R/9ILJUFI/lGExkKvgATP0H5kSeTy36LssUzAKh3ntLFl
  36731. osS88Zj0qnAHY7S42jtM+kAiMFsRpvAFDsYCA0irhpuF3dvd6qJ2gHN99ZwExEWN57kci57q13XR
  36732. crHedUTnQn3iV2t93Jm8PYMo6oCTjcVMZcFwgbg4/EMxsvYDNEeyrPsiBsse3RdHHF9mudMaotoR
  36733. saS8I8nkvof/uZS2+F0gStRf571oe2XyFR7SOqkt6dhrJKyXWERHrVkY8SFlcN7ONGCoQPHzPKTD
  36734. KCOM/iczQ0CgFzzr6juwcqajuUpLXhZI9LK8yIySxZ2frHI2vDSANGupi5LAuBft7HZT9SQBjLMi
  36735. 6Et8Vcad+qMUu2WFbm5PEn4KPJ2V
  36736. -----END CERTIFICATE-----
  36737. Izenpe.com
  36738. ==========
  36739. -----BEGIN CERTIFICATE-----
  36740. MIIF8TCCA9mgAwIBAgIQALC3WhZIX7/hy/WL1xnmfTANBgkqhkiG9w0BAQsFADA4MQswCQYDVQQG
  36741. EwJFUzEUMBIGA1UECgwLSVpFTlBFIFMuQS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wHhcNMDcxMjEz
  36742. MTMwODI4WhcNMzcxMjEzMDgyNzI1WjA4MQswCQYDVQQGEwJFUzEUMBIGA1UECgwLSVpFTlBFIFMu
  36743. QS4xEzARBgNVBAMMCkl6ZW5wZS5jb20wggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDJ
  36744. 03rKDx6sp4boFmVqscIbRTJxldn+EFvMr+eleQGPicPK8lVx93e+d5TzcqQsRNiekpsUOqHnJJAK
  36745. ClaOxdgmlOHZSOEtPtoKct2jmRXagaKH9HtuJneJWK3W6wyyQXpzbm3benhB6QiIEn6HLmYRY2xU
  36746. +zydcsC8Lv/Ct90NduM61/e0aL6i9eOBbsFGb12N4E3GVFWJGjMxCrFXuaOKmMPsOzTFlUFpfnXC
  36747. PCDFYbpRR6AgkJOhkEvzTnyFRVSa0QUmQbC1TR0zvsQDyCV8wXDbO/QJLVQnSKwv4cSsPsjLkkxT
  36748. OTcj7NMB+eAJRE1NZMDhDVqHIrytG6P+JrUV86f8hBnp7KGItERphIPzidF0BqnMC9bC3ieFUCbK
  36749. F7jJeodWLBoBHmy+E60QrLUk9TiRodZL2vG70t5HtfG8gfZZa88ZU+mNFctKy6lvROUbQc/hhqfK
  36750. 0GqfvEyNBjNaooXlkDWgYlwWTvDjovoDGrQscbNYLN57C9saD+veIR8GdwYDsMnvmfzAuU8Lhij+
  36751. 0rnq49qlw0dpEuDb8PYZi+17cNcC1u2HGCgsBCRMd+RIihrGO5rUD8r6ddIBQFqNeb+Lz0vPqhbB
  36752. leStTIo+F5HUsWLlguWABKQDfo2/2n+iD5dPDNMN+9fR5XJ+HMh3/1uaD7euBUbl8agW7EekFwID
  36753. AQABo4H2MIHzMIGwBgNVHREEgagwgaWBD2luZm9AaXplbnBlLmNvbaSBkTCBjjFHMEUGA1UECgw+
  36754. SVpFTlBFIFMuQS4gLSBDSUYgQTAxMzM3MjYwLVJNZXJjLlZpdG9yaWEtR2FzdGVpeiBUMTA1NSBG
  36755. NjIgUzgxQzBBBgNVBAkMOkF2ZGEgZGVsIE1lZGl0ZXJyYW5lbyBFdG9yYmlkZWEgMTQgLSAwMTAx
  36756. MCBWaXRvcmlhLUdhc3RlaXowDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  36757. BBYEFB0cZQ6o8iV7tJHP5LGx5r1VdGwFMA0GCSqGSIb3DQEBCwUAA4ICAQB4pgwWSp9MiDrAyw6l
  36758. Fn2fuUhfGI8NYjb2zRlrrKvV9pF9rnHzP7MOeIWblaQnIUdCSnxIOvVFfLMMjlF4rJUT3sb9fbga
  36759. kEyrkgPH7UIBzg/YsfqikuFgba56awmqxinuaElnMIAkejEWOVt+8Rwu3WwJrfIxwYJOubv5vr8q
  36760. hT/AQKM6WfxZSzwoJNu0FXWuDYi6LnPAvViH5ULy617uHjAimcs30cQhbIHsvm0m5hzkQiCeR7Cs
  36761. g1lwLDXWrzY0tM07+DKo7+N4ifuNRSzanLh+QBxh5z6ikixL8s36mLYp//Pye6kfLqCTVyvehQP5
  36762. aTfLnnhqBbTFMXiJ7HqnheG5ezzevh55hM6fcA5ZwjUukCox2eRFekGkLhObNA5me0mrZJfQRsN5
  36763. nXJQY6aYWwa9SG3YOYNw6DXwBdGqvOPbyALqfP2C2sJbUjWumDqtujWTI6cfSN01RpiyEGjkpTHC
  36764. ClguGYEQyVB1/OpaFs4R1+7vUIgtYf8/QnMFlEPVjjxOAToZpR9GTnfQXeWBIiGH/pR9hNiTrdZo
  36765. Q0iy2+tzJOeRf1SktoA+naM8THLCV8Sg1Mw4J87VBp6iSNnpn86CcDaTmjvfliHjWbcM2pE38P1Z
  36766. WrOZyGlsQyYBNWNgVYkDOnXYukrZVP/u3oDYLdE41V4tC5h9Pmzb/CaIxw==
  36767. -----END CERTIFICATE-----
  36768. Chambers of Commerce Root - 2008
  36769. ================================
  36770. -----BEGIN CERTIFICATE-----
  36771. MIIHTzCCBTegAwIBAgIJAKPaQn6ksa7aMA0GCSqGSIb3DQEBBQUAMIGuMQswCQYDVQQGEwJFVTFD
  36772. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  36773. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  36774. QS4xKTAnBgNVBAMTIENoYW1iZXJzIG9mIENvbW1lcmNlIFJvb3QgLSAyMDA4MB4XDTA4MDgwMTEy
  36775. Mjk1MFoXDTM4MDczMTEyMjk1MFowga4xCzAJBgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNl
  36776. ZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNhbWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQF
  36777. EwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENhbWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJl
  36778. cnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDgwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoIC
  36779. AQCvAMtwNyuAWko6bHiUfaN/Gh/2NdW928sNRHI+JrKQUrpjOyhYb6WzbZSm891kDFX29ufyIiKA
  36780. XuFixrYp4YFs8r/lfTJqVKAyGVn+H4vXPWCGhSRv4xGzdz4gljUha7MI2XAuZPeEklPWDrCQiorj
  36781. h40G072QDuKZoRuGDtqaCrsLYVAGUvGef3bsyw/QHg3PmTA9HMRFEFis1tPo1+XqxQEHd9ZR5gN/
  36782. ikilTWh1uem8nk4ZcfUyS5xtYBkL+8ydddy/Js2Pk3g5eXNeJQ7KXOt3EgfLZEFHcpOrUMPrCXZk
  36783. NNI5t3YRCQ12RcSprj1qr7V9ZS+UWBDsXHyvfuK2GNnQm05aSd+pZgvMPMZ4fKecHePOjlO+Bd5g
  36784. D2vlGts/4+EhySnB8esHnFIbAURRPHsl18TlUlRdJQfKFiC4reRB7noI/plvg6aRArBsNlVq5331
  36785. lubKgdaX8ZSD6e2wsWsSaR6s+12pxZjptFtYer49okQ6Y1nUCyXeG0+95QGezdIp1Z8XGQpvvwyQ
  36786. 0wlf2eOKNcx5Wk0ZN5K3xMGtr/R5JJqyAQuxr1yW84Ay+1w9mPGgP0revq+ULtlVmhduYJ1jbLhj
  36787. ya6BXBg14JC7vjxPNyK5fuvPnnchpj04gftI2jE9K+OJ9dC1vX7gUMQSibMjmhAxhduub+84Mxh2
  36788. EQIDAQABo4IBbDCCAWgwEgYDVR0TAQH/BAgwBgEB/wIBDDAdBgNVHQ4EFgQU+SSsD7K1+HnA+mCI
  36789. G8TZTQKeFxkwgeMGA1UdIwSB2zCB2IAU+SSsD7K1+HnA+mCIG8TZTQKeFxmhgbSkgbEwga4xCzAJ
  36790. BgNVBAYTAkVVMUMwQQYDVQQHEzpNYWRyaWQgKHNlZSBjdXJyZW50IGFkZHJlc3MgYXQgd3d3LmNh
  36791. bWVyZmlybWEuY29tL2FkZHJlc3MpMRIwEAYDVQQFEwlBODI3NDMyODcxGzAZBgNVBAoTEkFDIENh
  36792. bWVyZmlybWEgUy5BLjEpMCcGA1UEAxMgQ2hhbWJlcnMgb2YgQ29tbWVyY2UgUm9vdCAtIDIwMDiC
  36793. CQCj2kJ+pLGu2jAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUH
  36794. AgEWHGh0dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAJASryI1
  36795. wqM58C7e6bXpeHxIvj99RZJe6dqxGfwWPJ+0W2aeaufDuV2I6A+tzyMP3iU6XsxPpcG1Lawk0lgH
  36796. 3qLPaYRgM+gQDROpI9CF5Y57pp49chNyM/WqfcZjHwj0/gF/JM8rLFQJ3uIrbZLGOU8W6jx+ekbU
  36797. RWpGqOt1glanq6B8aBMz9p0w8G8nOSQjKpD9kCk18pPfNKXG9/jvjA9iSnyu0/VU+I22mlaHFoI6
  36798. M6taIgj3grrqLuBHmrS1RaMFO9ncLkVAO+rcf+g769HsJtg1pDDFOqxXnrN2pSB7+R5KBWIBpih1
  36799. YJeSDW4+TTdDDZIVnBgizVGZoCkaPF+KMjNbMMeJL0eYD6MDxvbxrN8y8NmBGuScvfaAFPDRLLmF
  36800. 9dijscilIeUcE5fuDr3fKanvNFNb0+RqE4QGtjICxFKuItLcsiFCGtpA8CnJ7AoMXOLQusxI0zcK
  36801. zBIKinmwPQN/aUv0NCB9szTqjktk9T79syNnFQ0EuPAtwQlRPLJsFfClI9eDdOTlLsn+mCdCxqvG
  36802. nrDQWzilm1DefhiYtUU79nm06PcaewaD+9CL2rvHvRirCG88gGtAPxkZumWK5r7VXNM21+9AUiRg
  36803. OGcEMeyP84LG3rlV8zsxkVrctQgVrXYlCg17LofiDKYGvCYQbTed7N14jHyAxfDZd0jQ
  36804. -----END CERTIFICATE-----
  36805. Global Chambersign Root - 2008
  36806. ==============================
  36807. -----BEGIN CERTIFICATE-----
  36808. MIIHSTCCBTGgAwIBAgIJAMnN0+nVfSPOMA0GCSqGSIb3DQEBBQUAMIGsMQswCQYDVQQGEwJFVTFD
  36809. MEEGA1UEBxM6TWFkcmlkIChzZWUgY3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNv
  36810. bS9hZGRyZXNzKTESMBAGA1UEBRMJQTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMu
  36811. QS4xJzAlBgNVBAMTHkdsb2JhbCBDaGFtYmVyc2lnbiBSb290IC0gMjAwODAeFw0wODA4MDExMjMx
  36812. NDBaFw0zODA3MzExMjMxNDBaMIGsMQswCQYDVQQGEwJFVTFDMEEGA1UEBxM6TWFkcmlkIChzZWUg
  36813. Y3VycmVudCBhZGRyZXNzIGF0IHd3dy5jYW1lcmZpcm1hLmNvbS9hZGRyZXNzKTESMBAGA1UEBRMJ
  36814. QTgyNzQzMjg3MRswGQYDVQQKExJBQyBDYW1lcmZpcm1hIFMuQS4xJzAlBgNVBAMTHkdsb2JhbCBD
  36815. aGFtYmVyc2lnbiBSb290IC0gMjAwODCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMDf
  36816. VtPkOpt2RbQT2//BthmLN0EYlVJH6xedKYiONWwGMi5HYvNJBL99RDaxccy9Wglz1dmFRP+RVyXf
  36817. XjaOcNFccUMd2drvXNL7G706tcuto8xEpw2uIRU/uXpbknXYpBI4iRmKt4DS4jJvVpyR1ogQC7N0
  36818. ZJJ0YPP2zxhPYLIj0Mc7zmFLmY/CDNBAspjcDahOo7kKrmCgrUVSY7pmvWjg+b4aqIG7HkF4ddPB
  36819. /gBVsIdU6CeQNR1MM62X/JcumIS/LMmjv9GYERTtY/jKmIhYF5ntRQOXfjyGHoiMvvKRhI9lNNgA
  36820. TH23MRdaKXoKGCQwoze1eqkBfSbW+Q6OWfH9GzO1KTsXO0G2Id3UwD2ln58fQ1DJu7xsepeY7s2M
  36821. H/ucUa6LcL0nn3HAa6x9kGbo1106DbDVwo3VyJ2dwW3Q0L9R5OP4wzg2rtandeavhENdk5IMagfe
  36822. Ox2YItaswTXbo6Al/3K1dh3ebeksZixShNBFks4c5eUzHdwHU1SjqoI7mjcv3N2gZOnm3b2u/GSF
  36823. HTynyQbehP9r6GsaPMWis0L7iwk+XwhSx2LE1AVxv8Rk5Pihg+g+EpuoHtQ2TS9x9o0o9oOpE9Jh
  36824. wZG7SMA0j0GMS0zbaRL/UJScIINZc+18ofLx/d33SdNDWKBWY8o9PeU1VlnpDsogzCtLkykPAgMB
  36825. AAGjggFqMIIBZjASBgNVHRMBAf8ECDAGAQH/AgEMMB0GA1UdDgQWBBS5CcqcHtvTbDprru1U8VuT
  36826. BjUuXjCB4QYDVR0jBIHZMIHWgBS5CcqcHtvTbDprru1U8VuTBjUuXqGBsqSBrzCBrDELMAkGA1UE
  36827. BhMCRVUxQzBBBgNVBAcTOk1hZHJpZCAoc2VlIGN1cnJlbnQgYWRkcmVzcyBhdCB3d3cuY2FtZXJm
  36828. aXJtYS5jb20vYWRkcmVzcykxEjAQBgNVBAUTCUE4Mjc0MzI4NzEbMBkGA1UEChMSQUMgQ2FtZXJm
  36829. aXJtYSBTLkEuMScwJQYDVQQDEx5HbG9iYWwgQ2hhbWJlcnNpZ24gUm9vdCAtIDIwMDiCCQDJzdPp
  36830. 1X0jzjAOBgNVHQ8BAf8EBAMCAQYwPQYDVR0gBDYwNDAyBgRVHSAAMCowKAYIKwYBBQUHAgEWHGh0
  36831. dHA6Ly9wb2xpY3kuY2FtZXJmaXJtYS5jb20wDQYJKoZIhvcNAQEFBQADggIBAICIf3DekijZBZRG
  36832. /5BXqfEv3xoNa/p8DhxJJHkn2EaqbylZUohwEurdPfWbU1Rv4WCiqAm57OtZfMY18dwY6fFn5a+6
  36833. ReAJ3spED8IXDneRRXozX1+WLGiLwUePmJs9wOzL9dWCkoQ10b42OFZyMVtHLaoXpGNR6woBrX/s
  36834. dZ7LoR/xfxKxueRkf2fWIyr0uDldmOghp+G9PUIadJpwr2hsUF1Jz//7Dl3mLEfXgTpZALVza2Mg
  36835. 9jFFCDkO9HB+QHBaP9BrQql0PSgvAm11cpUJjUhjxsYjV5KTXjXBjfkK9yydYhz2rXzdpjEetrHH
  36836. foUm+qRqtdpjMNHvkzeyZi99Bffnt0uYlDXA2TopwZ2yUDMdSqlapskD7+3056huirRXhOukP9Du
  36837. qqqHW2Pok+JrqNS4cnhrG+055F3Lm6qH1U9OAP7Zap88MQ8oAgF9mOinsKJknnn4SPIVqczmyETr
  36838. P3iZ8ntxPjzxmKfFGBI/5rsoM0LpRQp8bfKGeS/Fghl9CYl8slR2iK7ewfPM4W7bMdaTrpmg7yVq
  36839. c5iJWzouE4gev8CSlDQb4ye3ix5vQv/n6TebUB0tovkC7stYWDpxvGjjqsGvHCgfotwjZT+B6q6Z
  36840. 09gwzxMNTxXJhLynSC34MCN32EZLeW32jO06f2ARePTpm67VVMB0gNELQp/B
  36841. -----END CERTIFICATE-----
  36842. Go Daddy Root Certificate Authority - G2
  36843. ========================================
  36844. -----BEGIN CERTIFICATE-----
  36845. MIIDxTCCAq2gAwIBAgIBADANBgkqhkiG9w0BAQsFADCBgzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  36846. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAYBgNVBAoTEUdvRGFkZHkuY29tLCBJbmMu
  36847. MTEwLwYDVQQDEyhHbyBEYWRkeSBSb290IENlcnRpZmljYXRlIEF1dGhvcml0eSAtIEcyMB4XDTA5
  36848. MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgYMxCzAJBgNVBAYTAlVTMRAwDgYDVQQIEwdBcml6
  36849. b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMRowGAYDVQQKExFHb0RhZGR5LmNvbSwgSW5jLjExMC8G
  36850. A1UEAxMoR28gRGFkZHkgUm9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZI
  36851. hvcNAQEBBQADggEPADCCAQoCggEBAL9xYgjx+lk09xvJGKP3gElY6SKDE6bFIEMBO4Tx5oVJnyfq
  36852. 9oQbTqC023CYxzIBsQU+B07u9PpPL1kwIuerGVZr4oAH/PMWdYA5UXvl+TW2dE6pjYIT5LY/qQOD
  36853. +qK+ihVqf94Lw7YZFAXK6sOoBJQ7RnwyDfMAZiLIjWltNowRGLfTshxgtDj6AozO091GB94KPutd
  36854. fMh8+7ArU6SSYmlRJQVhGkSBjCypQ5Yj36w6gZoOKcUcqeldHraenjAKOc7xiID7S13MMuyFYkMl
  36855. NAJWJwGRtDtwKj9useiciAF9n9T521NtYJ2/LOdYq7hfRvzOxBsDPAnrSTFcaUaz4EcCAwEAAaNC
  36856. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFDqahQcQZyi27/a9
  36857. BUFuIMGU2g/eMA0GCSqGSIb3DQEBCwUAA4IBAQCZ21151fmXWWcDYfF+OwYxdS2hII5PZYe096ac
  36858. vNjpL9DbWu7PdIxztDhC2gV7+AJ1uP2lsdeu9tfeE8tTEH6KRtGX+rcuKxGrkLAngPnon1rpN5+r
  36859. 5N9ss4UXnT3ZJE95kTXWXwTrgIOrmgIttRD02JDHBHNA7XIloKmf7J6raBKZV8aPEjoJpL1E/QYV
  36860. N8Gb5DKj7Tjo2GTzLH4U/ALqn83/B2gX2yKQOC16jdFU8WnjXzPKej17CuPKf1855eJ1usV2GDPO
  36861. LPAvTK33sefOT6jEm0pUBsV/fdUID+Ic/n4XuKxe9tQWskMJDE32p2u0mYRlynqI4uJEvlz36hz1
  36862. -----END CERTIFICATE-----
  36863. Starfield Root Certificate Authority - G2
  36864. =========================================
  36865. -----BEGIN CERTIFICATE-----
  36866. MIID3TCCAsWgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBjzELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  36867. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  36868. b2dpZXMsIEluYy4xMjAwBgNVBAMTKVN0YXJmaWVsZCBSb290IENlcnRpZmljYXRlIEF1dGhvcml0
  36869. eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgY8xCzAJBgNVBAYTAlVTMRAw
  36870. DgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZmllbGQg
  36871. VGVjaG5vbG9naWVzLCBJbmMuMTIwMAYDVQQDEylTdGFyZmllbGQgUm9vdCBDZXJ0aWZpY2F0ZSBB
  36872. dXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAL3twQP89o/8ArFv
  36873. W59I2Z154qK3A2FWGMNHttfKPTUuiUP3oWmb3ooa/RMgnLRJdzIpVv257IzdIvpy3Cdhl+72WoTs
  36874. bhm5iSzchFvVdPtrX8WJpRBSiUZV9Lh1HOZ/5FSuS/hVclcCGfgXcVnrHigHdMWdSL5stPSksPNk
  36875. N3mSwOxGXn/hbVNMYq/NHwtjuzqd+/x5AJhhdM8mgkBj87JyahkNmcrUDnXMN/uLicFZ8WJ/X7Nf
  36876. ZTD4p7dNdloedl40wOiWVpmKs/B/pM293DIxfJHP4F8R+GuqSVzRmZTRouNjWwl2tVZi4Ut0HZbU
  36877. JtQIBFnQmA4O5t78w+wfkPECAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  36878. AQYwHQYDVR0OBBYEFHwMMh+n2TB/xH1oo2Kooc6rB1snMA0GCSqGSIb3DQEBCwUAA4IBAQARWfol
  36879. TwNvlJk7mh+ChTnUdgWUXuEok21iXQnCoKjUsHU48TRqneSfioYmUeYs0cYtbpUgSpIB7LiKZ3sx
  36880. 4mcujJUDJi5DnUox9g61DLu34jd/IroAow57UvtruzvE03lRTs2Q9GcHGcg8RnoNAX3FWOdt5oUw
  36881. F5okxBDgBPfg8n/Uqgr/Qh037ZTlZFkSIHc40zI+OIF1lnP6aI+xy84fxez6nH7PfrHxBy22/L/K
  36882. pL/QlwVKvOoYKAKQvVR4CSFx09F9HdkWsKlhPdAKACL8x3vLCWRFCztAgfd9fDL1mMpYjn0q7pBZ
  36883. c2T5NnReJaH1ZgUufzkVqSr7UIuOhWn0
  36884. -----END CERTIFICATE-----
  36885. Starfield Services Root Certificate Authority - G2
  36886. ==================================================
  36887. -----BEGIN CERTIFICATE-----
  36888. MIID7zCCAtegAwIBAgIBADANBgkqhkiG9w0BAQsFADCBmDELMAkGA1UEBhMCVVMxEDAOBgNVBAgT
  36889. B0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxJTAjBgNVBAoTHFN0YXJmaWVsZCBUZWNobm9s
  36890. b2dpZXMsIEluYy4xOzA5BgNVBAMTMlN0YXJmaWVsZCBTZXJ2aWNlcyBSb290IENlcnRpZmljYXRl
  36891. IEF1dGhvcml0eSAtIEcyMB4XDTA5MDkwMTAwMDAwMFoXDTM3MTIzMTIzNTk1OVowgZgxCzAJBgNV
  36892. BAYTAlVTMRAwDgYDVQQIEwdBcml6b25hMRMwEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxT
  36893. dGFyZmllbGQgVGVjaG5vbG9naWVzLCBJbmMuMTswOQYDVQQDEzJTdGFyZmllbGQgU2VydmljZXMg
  36894. Um9vdCBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
  36895. AQoCggEBANUMOsQq+U7i9b4Zl1+OiFOxHz/Lz58gE20pOsgPfTz3a3Y4Y9k2YKibXlwAgLIvWX/2
  36896. h/klQ4bnaRtSmpDhcePYLQ1Ob/bISdm28xpWriu2dBTrz/sm4xq6HZYuajtYlIlHVv8loJNwU4Pa
  36897. hHQUw2eeBGg6345AWh1KTs9DkTvnVtYAcMtS7nt9rjrnvDH5RfbCYM8TWQIrgMw0R9+53pBlbQLP
  36898. LJGmpufehRhJfGZOozptqbXuNC66DQO4M99H67FrjSXZm86B0UVGMpZwh94CDklDhbZsc7tk6mFB
  36899. rMnUVN+HL8cisibMn1lUaJ/8viovxFUcdUBgF4UCVTmLfwUCAwEAAaNCMEAwDwYDVR0TAQH/BAUw
  36900. AwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJxfAN+qAdcwKziIorhtSpzyEZGDMA0GCSqG
  36901. SIb3DQEBCwUAA4IBAQBLNqaEd2ndOxmfZyMIbw5hyf2E3F/YNoHN2BtBLZ9g3ccaaNnRbobhiCPP
  36902. E95Dz+I0swSdHynVv/heyNXBve6SbzJ08pGCL72CQnqtKrcgfU28elUSwhXqvfdqlS5sdJ/PHLTy
  36903. xQGjhdByPq1zqwubdQxtRbeOlKyWN7Wg0I8VRw7j6IPdj/3vQQF3zCepYoUz8jcI73HPdwbeyBkd
  36904. iEDPfUYd/x7H4c7/I9vG+o1VTqkC50cRRj70/b17KSa7qWFiNyi2LSr2EIZkyXCn0q23KXB56jza
  36905. YyWf/Wi3MOxw+3WKt21gZ7IeyLnp2KhvAotnDU0mV3HaIPzBSlCNsSi6
  36906. -----END CERTIFICATE-----
  36907. AffirmTrust Commercial
  36908. ======================
  36909. -----BEGIN CERTIFICATE-----
  36910. MIIDTDCCAjSgAwIBAgIId3cGJyapsXwwDQYJKoZIhvcNAQELBQAwRDELMAkGA1UEBhMCVVMxFDAS
  36911. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMB4XDTEw
  36912. MDEyOTE0MDYwNloXDTMwMTIzMTE0MDYwNlowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  36913. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBDb21tZXJjaWFsMIIBIjANBgkqhkiG9w0BAQEF
  36914. AAOCAQ8AMIIBCgKCAQEA9htPZwcroRX1BiLLHwGy43NFBkRJLLtJJRTWzsO3qyxPxkEylFf6Eqdb
  36915. DuKPHx6GGaeqtS25Xw2Kwq+FNXkyLbscYjfysVtKPcrNcV/pQr6U6Mje+SJIZMblq8Yrba0F8PrV
  36916. C8+a5fBQpIs7R6UjW3p6+DM/uO+Zl+MgwdYoic+U+7lF7eNAFxHUdPALMeIrJmqbTFeurCA+ukV6
  36917. BfO9m2kVrn1OIGPENXY6BwLJN/3HR+7o8XYdcxXyl6S1yHp52UKqK39c/s4mT6NmgTWvRLpUHhww
  36918. MmWd5jyTXlBOeuM61G7MGvv50jeuJCqrVwMiKA1JdX+3KNp1v47j3A55MQIDAQABo0IwQDAdBgNV
  36919. HQ4EFgQUnZPGU4teyq8/nx4P5ZmVvCT2lI8wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  36920. AQYwDQYJKoZIhvcNAQELBQADggEBAFis9AQOzcAN/wr91LoWXym9e2iZWEnStB03TX8nfUYGXUPG
  36921. hi4+c7ImfU+TqbbEKpqrIZcUsd6M06uJFdhrJNTxFq7YpFzUf1GO7RgBsZNjvbz4YYCanrHOQnDi
  36922. qX0GJX0nof5v7LMeJNrjS1UaADs1tDvZ110w/YETifLCBivtZ8SOyUOyXGsViQK8YvxO8rUzqrJv
  36923. 0wqiUOP2O+guRMLbZjipM1ZI8W0bM40NjD9gN53Tym1+NH4Nn3J2ixufcv1SNUFFApYvHLKac0kh
  36924. sUlHRUe072o0EclNmsxZt9YCnlpOZbWUrhvfKbAW8b8Angc6F2S1BLUjIZkKlTuXfO8=
  36925. -----END CERTIFICATE-----
  36926. AffirmTrust Networking
  36927. ======================
  36928. -----BEGIN CERTIFICATE-----
  36929. MIIDTDCCAjSgAwIBAgIIfE8EORzUmS0wDQYJKoZIhvcNAQEFBQAwRDELMAkGA1UEBhMCVVMxFDAS
  36930. BgNVBAoMC0FmZmlybVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMB4XDTEw
  36931. MDEyOTE0MDgyNFoXDTMwMTIzMTE0MDgyNFowRDELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmly
  36932. bVRydXN0MR8wHQYDVQQDDBZBZmZpcm1UcnVzdCBOZXR3b3JraW5nMIIBIjANBgkqhkiG9w0BAQEF
  36933. AAOCAQ8AMIIBCgKCAQEAtITMMxcua5Rsa2FSoOujz3mUTOWUgJnLVWREZY9nZOIG41w3SfYvm4SE
  36934. Hi3yYJ0wTsyEheIszx6e/jarM3c1RNg1lho9Nuh6DtjVR6FqaYvZ/Ls6rnla1fTWcbuakCNrmreI
  36935. dIcMHl+5ni36q1Mr3Lt2PpNMCAiMHqIjHNRqrSK6mQEubWXLviRmVSRLQESxG9fhwoXA3hA/Pe24
  36936. /PHxI1Pcv2WXb9n5QHGNfb2V1M6+oF4nI979ptAmDgAp6zxG8D1gvz9Q0twmQVGeFDdCBKNwV6gb
  36937. h+0t+nvujArjqWaJGctB+d1ENmHP4ndGyH329JKBNv3bNPFyfvMMFr20FQIDAQABo0IwQDAdBgNV
  36938. HQ4EFgQUBx/S55zawm6iQLSwelAQUHTEyL0wDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  36939. AQYwDQYJKoZIhvcNAQEFBQADggEBAIlXshZ6qML91tmbmzTCnLQyFE2npN/svqe++EPbkTfOtDIu
  36940. UFUaNU52Q3Eg75N3ThVwLofDwR1t3Mu1J9QsVtFSUzpE0nPIxBsFZVpikpzuQY0x2+c06lkh1QF6
  36941. 12S4ZDnNye2v7UsDSKegmQGA3GWjNq5lWUhPgkvIZfFXHeVZLgo/bNjR9eUJtGxUAArgFU2HdW23
  36942. WJZa3W3SAKD0m0i+wzekujbgfIeFlxoVot4uolu9rxj5kFDNcFn4J2dHy8egBzp90SxdbBk6ZrV9
  36943. /ZFvgrG+CJPbFEfxojfHRZ48x3evZKiT3/Zpg4Jg8klCNO1aAFSFHBY2kgxc+qatv9s=
  36944. -----END CERTIFICATE-----
  36945. AffirmTrust Premium
  36946. ===================
  36947. -----BEGIN CERTIFICATE-----
  36948. MIIFRjCCAy6gAwIBAgIIbYwURrGmCu4wDQYJKoZIhvcNAQEMBQAwQTELMAkGA1UEBhMCVVMxFDAS
  36949. BgNVBAoMC0FmZmlybVRydXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMB4XDTEwMDEy
  36950. OTE0MTAzNloXDTQwMTIzMTE0MTAzNlowQTELMAkGA1UEBhMCVVMxFDASBgNVBAoMC0FmZmlybVRy
  36951. dXN0MRwwGgYDVQQDDBNBZmZpcm1UcnVzdCBQcmVtaXVtMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  36952. MIICCgKCAgEAxBLfqV/+Qd3d9Z+K4/as4Tx4mrzY8H96oDMq3I0gW64tb+eT2TZwamjPjlGjhVtn
  36953. BKAQJG9dKILBl1fYSCkTtuG+kU3fhQxTGJoeJKJPj/CihQvL9Cl/0qRY7iZNyaqoe5rZ+jjeRFcV
  36954. 5fiMyNlI4g0WJx0eyIOFJbe6qlVBzAMiSy2RjYvmia9mx+n/K+k8rNrSs8PhaJyJ+HoAVt70VZVs
  36955. +7pk3WKL3wt3MutizCaam7uqYoNMtAZ6MMgpv+0GTZe5HMQxK9VfvFMSF5yZVylmd2EhMQcuJUmd
  36956. GPLu8ytxjLW6OQdJd/zvLpKQBY0tL3d770O/Nbua2Plzpyzy0FfuKE4mX4+QaAkvuPjcBukumj5R
  36957. p9EixAqnOEhss/n/fauGV+O61oV4d7pD6kh/9ti+I20ev9E2bFhc8e6kGVQa9QPSdubhjL08s9NI
  36958. S+LI+H+SqHZGnEJlPqQewQcDWkYtuJfzt9WyVSHvutxMAJf7FJUnM7/oQ0dG0giZFmA7mn7S5u04
  36959. 6uwBHjxIVkkJx0w3AJ6IDsBz4W9m6XJHMD4Q5QsDyZpCAGzFlH5hxIrff4IaC1nEWTJ3s7xgaVY5
  36960. /bQGeyzWZDbZvUjthB9+pSKPKrhC9IK31FOQeE4tGv2Bb0TXOwF0lkLgAOIua+rF7nKsu7/+6qqo
  36961. +Nz2snmKtmcCAwEAAaNCMEAwHQYDVR0OBBYEFJ3AZ6YMItkm9UWrpmVSESfYRaxjMA8GA1UdEwEB
  36962. /wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBDAUAA4ICAQCzV00QYk465KzquByv
  36963. MiPIs0laUZx2KI15qldGF9X1Uva3ROgIRL8YhNILgM3FEv0AVQVhh0HctSSePMTYyPtwni94loMg
  36964. Nt58D2kTiKV1NpgIpsbfrM7jWNa3Pt668+s0QNiigfV4Py/VpfzZotReBA4Xrf5B8OWycvpEgjNC
  36965. 6C1Y91aMYj+6QrCcDFx+LmUmXFNPALJ4fqENmS2NuB2OosSw/WDQMKSOyARiqcTtNd56l+0OOF6S
  36966. L5Nwpamcb6d9Ex1+xghIsV5n61EIJenmJWtSKZGc0jlzCFfemQa0W50QBuHCAKi4HEoCChTQwUHK
  36967. +4w1IX2COPKpVJEZNZOUbWo6xbLQu4mGk+ibyQ86p3q4ofB4Rvr8Ny/lioTz3/4E2aFooC8k4gmV
  36968. BtWVyuEklut89pMFu+1z6S3RdTnX5yTb2E5fQ4+e0BQ5v1VwSJlXMbSc7kqYA5YwH2AG7hsj/oFg
  36969. IxpHYoWlzBk0gG+zrBrjn/B7SK3VAdlntqlyk+otZrWyuOQ9PLLvTIzq6we/qzWaVYa8GKa1qF60
  36970. g2xraUDTn9zxw2lrueFtCfTxqlB2Cnp9ehehVZZCmTEJ3WARjQUwfuaORtGdFNrHF+QFlozEJLUb
  36971. zxQHskD4o55BhrwE0GuWyCqANP2/7waj3VjFhT0+j/6eKeC2uAloGRwYQw==
  36972. -----END CERTIFICATE-----
  36973. AffirmTrust Premium ECC
  36974. =======================
  36975. -----BEGIN CERTIFICATE-----
  36976. MIIB/jCCAYWgAwIBAgIIdJclisc/elQwCgYIKoZIzj0EAwMwRTELMAkGA1UEBhMCVVMxFDASBgNV
  36977. BAoMC0FmZmlybVRydXN0MSAwHgYDVQQDDBdBZmZpcm1UcnVzdCBQcmVtaXVtIEVDQzAeFw0xMDAx
  36978. MjkxNDIwMjRaFw00MDEyMzExNDIwMjRaMEUxCzAJBgNVBAYTAlVTMRQwEgYDVQQKDAtBZmZpcm1U
  36979. cnVzdDEgMB4GA1UEAwwXQWZmaXJtVHJ1c3QgUHJlbWl1bSBFQ0MwdjAQBgcqhkjOPQIBBgUrgQQA
  36980. IgNiAAQNMF4bFZ0D0KF5Nbc6PJJ6yhUczWLznCZcBz3lVPqj1swS6vQUX+iOGasvLkjmrBhDeKzQ
  36981. N8O9ss0s5kfiGuZjuD0uL3jET9v0D6RoTFVya5UdThhClXjMNzyR4ptlKymjQjBAMB0GA1UdDgQW
  36982. BBSaryl6wBE1NSZRMADDav5A1a7WPDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAK
  36983. BggqhkjOPQQDAwNnADBkAjAXCfOHiFBar8jAQr9HX/VsaobgxCd05DhT1wV/GzTjxi+zygk8N53X
  36984. 57hG8f2h4nECMEJZh0PUUd+60wkyWs6Iflc9nF9Ca/UHLbXwgpP5WW+uZPpY5Yse42O+tYHNbwKM
  36985. eQ==
  36986. -----END CERTIFICATE-----
  36987. Certum Trusted Network CA
  36988. =========================
  36989. -----BEGIN CERTIFICATE-----
  36990. MIIDuzCCAqOgAwIBAgIDBETAMA0GCSqGSIb3DQEBBQUAMH4xCzAJBgNVBAYTAlBMMSIwIAYDVQQK
  36991. ExlVbml6ZXRvIFRlY2hub2xvZ2llcyBTLkEuMScwJQYDVQQLEx5DZXJ0dW0gQ2VydGlmaWNhdGlv
  36992. biBBdXRob3JpdHkxIjAgBgNVBAMTGUNlcnR1bSBUcnVzdGVkIE5ldHdvcmsgQ0EwHhcNMDgxMDIy
  36993. MTIwNzM3WhcNMjkxMjMxMTIwNzM3WjB+MQswCQYDVQQGEwJQTDEiMCAGA1UEChMZVW5pemV0byBU
  36994. ZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  36995. MSIwIAYDVQQDExlDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENBMIIBIjANBgkqhkiG9w0BAQEFAAOC
  36996. AQ8AMIIBCgKCAQEA4/t9o3K6wvDJFIf1awFO4W5AB7ptJ11/91sts1rHUV+rpDKmYYe2bg+G0jAC
  36997. l/jXaVehGDldamR5xgFZrDwxSjh80gTSSyjoIF87B6LMTXPb865Px1bVWqeWifrzq2jUI4ZZJ88J
  36998. J7ysbnKDHDBy3+Ci6dLhdHUZvSqeexVUBBvXQzmtVSjF4hq79MDkrjhJM8x2hZ85RdKknvISjFH4
  36999. fOQtf/WsX+sWn7Et0brMkUJ3TCXJkDhv2/DM+44el1k+1WBO5gUo7Ul5E0u6SNsv+XLTOcr+H9g0
  37000. cvW0QM8xAcPs3hEtF10fuFDRXhmnad4HMyjKUJX5p1TLVIZQRan5SQIDAQABo0IwQDAPBgNVHRMB
  37001. Af8EBTADAQH/MB0GA1UdDgQWBBQIds3LB/8k9sXN7buQvOKEN0Z19zAOBgNVHQ8BAf8EBAMCAQYw
  37002. DQYJKoZIhvcNAQEFBQADggEBAKaorSLOAT2mo/9i0Eidi15ysHhE49wcrwn9I0j6vSrEuVUEtRCj
  37003. jSfeC4Jj0O7eDDd5QVsisrCaQVymcODU0HfLI9MA4GxWL+FpDQ3Zqr8hgVDZBqWo/5U30Kr+4rP1
  37004. mS1FhIrlQgnXdAIv94nYmem8J9RHjboNRhx3zxSkHLmkMcScKHQDNP8zGSal6Q10tz6XxnboJ5aj
  37005. Zt3hrvJBW8qYVoNzcOSGGtIxQbovvi0TWnZvTuhOgQ4/WwMioBK+ZlgRSssDxLQqKi2WF+A5VLxI
  37006. 03YnnZotBqbJ7DnSq9ufmgsnAjUpsUCV5/nonFWIGUbWtzT1fs45mtk48VH3Tyw=
  37007. -----END CERTIFICATE-----
  37008. TWCA Root Certification Authority
  37009. =================================
  37010. -----BEGIN CERTIFICATE-----
  37011. MIIDezCCAmOgAwIBAgIBATANBgkqhkiG9w0BAQUFADBfMQswCQYDVQQGEwJUVzESMBAGA1UECgwJ
  37012. VEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NBIFJvb3QgQ2VydGlmaWNh
  37013. dGlvbiBBdXRob3JpdHkwHhcNMDgwODI4MDcyNDMzWhcNMzAxMjMxMTU1OTU5WjBfMQswCQYDVQQG
  37014. EwJUVzESMBAGA1UECgwJVEFJV0FOLUNBMRAwDgYDVQQLDAdSb290IENBMSowKAYDVQQDDCFUV0NB
  37015. IFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK
  37016. AoIBAQCwfnK4pAOU5qfeCTiRShFAh6d8WWQUe7UREN3+v9XAu1bihSX0NXIP+FPQQeFEAcK0HMMx
  37017. QhZHhTMidrIKbw/lJVBPhYa+v5guEGcevhEFhgWQxFnQfHgQsIBct+HHK3XLfJ+utdGdIzdjp9xC
  37018. oi2SBBtQwXu4PhvJVgSLL1KbralW6cH/ralYhzC2gfeXRfwZVzsrb+RH9JlF/h3x+JejiB03HFyP
  37019. 4HYlmlD4oFT/RJB2I9IyxsOrBr/8+7/zrX2SYgJbKdM1o5OaQ2RgXbL6Mv87BK9NQGr5x+PvI/1r
  37020. y+UPizgN7gr8/g+YnzAx3WxSZfmLgb4i4RxYA7qRG4kHAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIB
  37021. BjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqOFsmjd6LWvJPelSDGRjjCDWmujANBgkqhkiG
  37022. 9w0BAQUFAAOCAQEAPNV3PdrfibqHDAhUaiBQkr6wQT25JmSDCi/oQMCXKCeCMErJk/9q56YAf4lC
  37023. mtYR5VPOL8zy2gXE/uJQxDqGfczafhAJO5I1KlOy/usrBdlsXebQ79NqZp4VKIV66IIArB6nCWlW
  37024. QtNoURi+VJq/REG6Sb4gumlc7rh3zc5sH62Dlhh9DrUUOYTxKOkto557HnpyWoOzeW/vtPzQCqVY
  37025. T0bf+215WfKEIlKuD8z7fDvnaspHYcN6+NOSBB+4IIThNlQWx0DeO4pz3N/GCUzf7Nr/1FNCocny
  37026. Yh0igzyXxfkZYiesZSLX0zzG5Y6yU8xJzrww/nsOM5D77dIUkR8Hrw==
  37027. -----END CERTIFICATE-----
  37028. Security Communication RootCA2
  37029. ==============================
  37030. -----BEGIN CERTIFICATE-----
  37031. MIIDdzCCAl+gAwIBAgIBADANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJKUDElMCMGA1UEChMc
  37032. U0VDT00gVHJ1c3QgU3lzdGVtcyBDTy4sTFRELjEnMCUGA1UECxMeU2VjdXJpdHkgQ29tbXVuaWNh
  37033. dGlvbiBSb290Q0EyMB4XDTA5MDUyOTA1MDAzOVoXDTI5MDUyOTA1MDAzOVowXTELMAkGA1UEBhMC
  37034. SlAxJTAjBgNVBAoTHFNFQ09NIFRydXN0IFN5c3RlbXMgQ08uLExURC4xJzAlBgNVBAsTHlNlY3Vy
  37035. aXR5IENvbW11bmljYXRpb24gUm9vdENBMjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  37036. ANAVOVKxUrO6xVmCxF1SrjpDZYBLx/KWvNs2l9amZIyoXvDjChz335c9S672XewhtUGrzbl+dp++
  37037. +T42NKA7wfYxEUV0kz1XgMX5iZnK5atq1LXaQZAQwdbWQonCv/Q4EpVMVAX3NuRFg3sUZdbcDE3R
  37038. 3n4MqzvEFb46VqZab3ZpUql6ucjrappdUtAtCms1FgkQhNBqyjoGADdH5H5XTz+L62e4iKrFvlNV
  37039. spHEfbmwhRkGeC7bYRr6hfVKkaHnFtWOojnflLhwHyg/i/xAXmODPIMqGplrz95Zajv8bxbXH/1K
  37040. EOtOghY6rCcMU/Gt1SSwawNQwS08Ft1ENCcadfsCAwEAAaNCMEAwHQYDVR0OBBYEFAqFqXdlBZh8
  37041. QIH4D5csOPEK7DzPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEB
  37042. CwUAA4IBAQBMOqNErLlFsceTfsgLCkLfZOoc7llsCLqJX2rKSpWeeo8HxdpFcoJxDjrSzG+ntKEj
  37043. u/Ykn8sX/oymzsLS28yN/HH8AynBbF0zX2S2ZTuJbxh2ePXcokgfGT+Ok+vx+hfuzU7jBBJV1uXk
  37044. 3fs+BXziHV7Gp7yXT2g69ekuCkO2r1dcYmh8t/2jioSgrGK+KwmHNPBqAbubKVY8/gA3zyNs8U6q
  37045. tnRGEmyR7jTV7JqR50S+kDFy1UkC9gLl9B/rfNmWVan/7Ir5mUf/NVoCqgTLiluHcSmRvaS0eg29
  37046. mvVXIwAHIRc/SjnRBUkLp7Y3gaVdjKozXoEofKd9J+sAro03
  37047. -----END CERTIFICATE-----
  37048. EC-ACC
  37049. ======
  37050. -----BEGIN CERTIFICATE-----
  37051. MIIFVjCCBD6gAwIBAgIQ7is969Qh3hSoYqwE893EATANBgkqhkiG9w0BAQUFADCB8zELMAkGA1UE
  37052. BhMCRVMxOzA5BgNVBAoTMkFnZW5jaWEgQ2F0YWxhbmEgZGUgQ2VydGlmaWNhY2lvIChOSUYgUS0w
  37053. ODAxMTc2LUkpMSgwJgYDVQQLEx9TZXJ2ZWlzIFB1YmxpY3MgZGUgQ2VydGlmaWNhY2lvMTUwMwYD
  37054. VQQLEyxWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5ldC92ZXJhcnJlbCAoYykwMzE1MDMGA1UE
  37055. CxMsSmVyYXJxdWlhIEVudGl0YXRzIGRlIENlcnRpZmljYWNpbyBDYXRhbGFuZXMxDzANBgNVBAMT
  37056. BkVDLUFDQzAeFw0wMzAxMDcyMzAwMDBaFw0zMTAxMDcyMjU5NTlaMIHzMQswCQYDVQQGEwJFUzE7
  37057. MDkGA1UEChMyQWdlbmNpYSBDYXRhbGFuYSBkZSBDZXJ0aWZpY2FjaW8gKE5JRiBRLTA4MDExNzYt
  37058. SSkxKDAmBgNVBAsTH1NlcnZlaXMgUHVibGljcyBkZSBDZXJ0aWZpY2FjaW8xNTAzBgNVBAsTLFZl
  37059. Z2V1IGh0dHBzOi8vd3d3LmNhdGNlcnQubmV0L3ZlcmFycmVsIChjKTAzMTUwMwYDVQQLEyxKZXJh
  37060. cnF1aWEgRW50aXRhdHMgZGUgQ2VydGlmaWNhY2lvIENhdGFsYW5lczEPMA0GA1UEAxMGRUMtQUND
  37061. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAsyLHT+KXQpWIR4NA9h0X84NzJB5R85iK
  37062. w5K4/0CQBXCHYMkAqbWUZRkiFRfCQ2xmRJoNBD45b6VLeqpjt4pEndljkYRm4CgPukLjbo73FCeT
  37063. ae6RDqNfDrHrZqJyTxIThmV6PttPB/SnCWDaOkKZx7J/sxaVHMf5NLWUhdWZXqBIoH7nF2W4onW4
  37064. HvPlQn2v7fOKSGRdghST2MDk/7NQcvJ29rNdQlB50JQ+awwAvthrDk4q7D7SzIKiGGUzE3eeml0a
  37065. E9jD2z3Il3rucO2n5nzbcc8tlGLfbdb1OL4/pYUKGbio2Al1QnDE6u/LDsg0qBIimAy4E5S2S+zw
  37066. 0JDnJwIDAQABo4HjMIHgMB0GA1UdEQQWMBSBEmVjX2FjY0BjYXRjZXJ0Lm5ldDAPBgNVHRMBAf8E
  37067. BTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUoMOLRKo3pUW/l4Ba0fF4opvpXY0wfwYD
  37068. VR0gBHgwdjB0BgsrBgEEAfV4AQMBCjBlMCwGCCsGAQUFBwIBFiBodHRwczovL3d3dy5jYXRjZXJ0
  37069. Lm5ldC92ZXJhcnJlbDA1BggrBgEFBQcCAjApGidWZWdldSBodHRwczovL3d3dy5jYXRjZXJ0Lm5l
  37070. dC92ZXJhcnJlbCAwDQYJKoZIhvcNAQEFBQADggEBAKBIW4IB9k1IuDlVNZyAelOZ1Vr/sXE7zDkJ
  37071. lF7W2u++AVtd0x7Y/X1PzaBB4DSTv8vihpw3kpBWHNzrKQXlxJ7HNd+KDM3FIUPpqojlNcAZQmNa
  37072. Al6kSBg6hW/cnbw/nZzBh7h6YQjpdwt/cKt63dmXLGQehb+8dJahw3oS7AwaboMMPOhyRp/7SNVe
  37073. l+axofjk70YllJyJ22k4vuxcDlbHZVHlUIiIv0LVKz3l+bqeLrPK9HOSAgu+TGbrIP65y7WZf+a2
  37074. E/rKS03Z7lNGBjvGTq2TWoF+bCpLagVFjPIhpDGQh2xlnJ2lYJU6Un/10asIbvPuW/mIPX64b24D
  37075. 5EI=
  37076. -----END CERTIFICATE-----
  37077. Hellenic Academic and Research Institutions RootCA 2011
  37078. =======================================================
  37079. -----BEGIN CERTIFICATE-----
  37080. MIIEMTCCAxmgAwIBAgIBADANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMCR1IxRDBCBgNVBAoT
  37081. O0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9y
  37082. aXR5MUAwPgYDVQQDEzdIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  37083. IFJvb3RDQSAyMDExMB4XDTExMTIwNjEzNDk1MloXDTMxMTIwMTEzNDk1MlowgZUxCzAJBgNVBAYT
  37084. AkdSMUQwQgYDVQQKEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25z
  37085. IENlcnQuIEF1dGhvcml0eTFAMD4GA1UEAxM3SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNo
  37086. IEluc3RpdHV0aW9ucyBSb290Q0EgMjAxMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
  37087. AKlTAOMupvaO+mDYLZU++CwqVE7NuYRhlFhPjz2L5EPzdYmNUeTDN9KKiE15HrcS3UN4SoqS5tdI
  37088. 1Q+kOilENbgH9mgdVc04UfCMJDGFr4PJfel3r+0ae50X+bOdOFAPplp5kYCvN66m0zH7tSYJnTxa
  37089. 71HFK9+WXesyHgLacEnsbgzImjeN9/E2YEsmLIKe0HjzDQ9jpFEw4fkrJxIH2Oq9GGKYsFk3fb7u
  37090. 8yBRQlqD75O6aRXxYp2fmTmCobd0LovUxQt7L/DICto9eQqakxylKHJzkUOap9FNhYS5qXSPFEDH
  37091. 3N6sQWRstBmbAmNtJGSPRLIl6s5ddAxjMlyNh+UCAwEAAaOBiTCBhjAPBgNVHRMBAf8EBTADAQH/
  37092. MAsGA1UdDwQEAwIBBjAdBgNVHQ4EFgQUppFC/RNhSiOeCKQp5dgTBCPuQSUwRwYDVR0eBEAwPqA8
  37093. MAWCAy5ncjAFggMuZXUwBoIELmVkdTAGggQub3JnMAWBAy5ncjAFgQMuZXUwBoEELmVkdTAGgQQu
  37094. b3JnMA0GCSqGSIb3DQEBBQUAA4IBAQAf73lB4XtuP7KMhjdCSk4cNx6NZrokgclPEg8hwAOXhiVt
  37095. XdMiKahsog2p6z0GW5k6x8zDmjR/qw7IThzh+uTczQ2+vyT+bOdrwg3IBp5OjWEopmr95fZi6hg8
  37096. TqBTnbI6nOulnJEWtk2C4AwFSKls9cz4y51JtPACpf1wA+2KIaWuE4ZJwzNzvoc7dIsXRSZMFpGD
  37097. /md9zU1jZ/rzAxKWeAaNsWftjj++n08C9bMJL/NMh98qy5V8AcysNnq/onN694/BtZqhFLKPM58N
  37098. 7yLcZnuEvUUXBj08yrl3NI/K6s8/MT7jiOOASSXIl7WdmplNsDz4SgCbZN2fOUvRJ9e4
  37099. -----END CERTIFICATE-----
  37100. Actalis Authentication Root CA
  37101. ==============================
  37102. -----BEGIN CERTIFICATE-----
  37103. MIIFuzCCA6OgAwIBAgIIVwoRl0LE48wwDQYJKoZIhvcNAQELBQAwazELMAkGA1UEBhMCSVQxDjAM
  37104. BgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlzIFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UE
  37105. AwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290IENBMB4XDTExMDkyMjExMjIwMloXDTMwMDky
  37106. MjExMjIwMlowazELMAkGA1UEBhMCSVQxDjAMBgNVBAcMBU1pbGFuMSMwIQYDVQQKDBpBY3RhbGlz
  37107. IFMucC5BLi8wMzM1ODUyMDk2NzEnMCUGA1UEAwweQWN0YWxpcyBBdXRoZW50aWNhdGlvbiBSb290
  37108. IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAp8bEpSmkLO/lGMWwUKNvUTufClrJ
  37109. wkg4CsIcoBh/kbWHuUA/3R1oHwiD1S0eiKD4j1aPbZkCkpAW1V8IbInX4ay8IMKx4INRimlNAJZa
  37110. by/ARH6jDuSRzVju3PvHHkVH3Se5CAGfpiEd9UEtL0z9KK3giq0itFZljoZUj5NDKd45RnijMCO6
  37111. zfB9E1fAXdKDa0hMxKufgFpbOr3JpyI/gCczWw63igxdBzcIy2zSekciRDXFzMwujt0q7bd9Zg1f
  37112. YVEiVRvjRuPjPdA1YprbrxTIW6HMiRvhMCb8oJsfgadHHwTrozmSBp+Z07/T6k9QnBn+locePGX2
  37113. oxgkg4YQ51Q+qDp2JE+BIcXjDwL4k5RHILv+1A7TaLndxHqEguNTVHnd25zS8gebLra8Pu2Fbe8l
  37114. EfKXGkJh90qX6IuxEAf6ZYGyojnP9zz/GPvG8VqLWeICrHuS0E4UT1lF9gxeKF+w6D9Fz8+vm2/7
  37115. hNN3WpVvrJSEnu68wEqPSpP4RCHiMUVhUE4Q2OM1fEwZtN4Fv6MGn8i1zeQf1xcGDXqVdFUNaBr8
  37116. EBtiZJ1t4JWgw5QHVw0U5r0F+7if5t+L4sbnfpb2U8WANFAoWPASUHEXMLrmeGO89LKtmyuy/uE5
  37117. jF66CyCU3nuDuP/jVo23Eek7jPKxwV2dpAtMK9myGPW1n0sCAwEAAaNjMGEwHQYDVR0OBBYEFFLY
  37118. iDrIn3hm7YnzezhwlMkCAjbQMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUUtiIOsifeGbt
  37119. ifN7OHCUyQICNtAwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3DQEBCwUAA4ICAQALe3KHwGCmSUyI
  37120. WOYdiPcUZEim2FgKDk8TNd81HdTtBjHIgT5q1d07GjLukD0R0i70jsNjLiNmsGe+b7bAEzlgqqI0
  37121. JZN1Ut6nna0Oh4lScWoWPBkdg/iaKWW+9D+a2fDzWochcYBNy+A4mz+7+uAwTc+G02UQGRjRlwKx
  37122. K3JCaKygvU5a2hi/a5iB0P2avl4VSM0RFbnAKVy06Ij3Pjaut2L9HmLecHgQHEhb2rykOLpn7VU+
  37123. Xlff1ANATIGk0k9jpwlCCRT8AKnCgHNPLsBA2RF7SOp6AsDT6ygBJlh0wcBzIm2Tlf05fbsq4/aC
  37124. 4yyXX04fkZT6/iyj2HYauE2yOE+b+h1IYHkm4vP9qdCa6HCPSXrW5b0KDtst842/6+OkfcvHlXHo
  37125. 2qN8xcL4dJIEG4aspCJTQLas/kx2z/uUMsA1n3Y/buWQbqCmJqK4LL7RK4X9p2jIugErsWx0Hbhz
  37126. lefut8cl8ABMALJ+tguLHPPAUJ4lueAI3jZm/zel0btUZCzJJ7VLkn5l/9Mt4blOvH+kQSGQQXem
  37127. OR/qnuOf0GZvBeyqdn6/axag67XH/JJULysRJyU3eExRarDzzFhdFPFqSBX/wge2sY0PjlxQRrM9
  37128. vwGYT7JZVEc+NHt4bVaTLnPqZih4zR0Uv6CPLy64Lo7yFIrM6bV8+2ydDKXhlg==
  37129. -----END CERTIFICATE-----
  37130. Trustis FPS Root CA
  37131. ===================
  37132. -----BEGIN CERTIFICATE-----
  37133. MIIDZzCCAk+gAwIBAgIQGx+ttiD5JNM2a/fH8YygWTANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQG
  37134. EwJHQjEYMBYGA1UEChMPVHJ1c3RpcyBMaW1pdGVkMRwwGgYDVQQLExNUcnVzdGlzIEZQUyBSb290
  37135. IENBMB4XDTAzMTIyMzEyMTQwNloXDTI0MDEyMTExMzY1NFowRTELMAkGA1UEBhMCR0IxGDAWBgNV
  37136. BAoTD1RydXN0aXMgTGltaXRlZDEcMBoGA1UECxMTVHJ1c3RpcyBGUFMgUm9vdCBDQTCCASIwDQYJ
  37137. KoZIhvcNAQEBBQADggEPADCCAQoCggEBAMVQe547NdDfxIzNjpvto8A2mfRC6qc+gIMPpqdZh8mQ
  37138. RUN+AOqGeSoDvT03mYlmt+WKVoaTnGhLaASMk5MCPjDSNzoiYYkchU59j9WvezX2fihHiTHcDnlk
  37139. H5nSW7r+f2C/revnPDgpai/lkQtV/+xvWNUtyd5MZnGPDNcE2gfmHhjjvSkCqPoc4Vu5g6hBSLwa
  37140. cY3nYuUtsuvffM/bq1rKMfFMIvMFE/eC+XN5DL7XSxzA0RU8k0Fk0ea+IxciAIleH2ulrG6nS4zt
  37141. o3Lmr2NNL4XSFDWaLk6M6jKYKIahkQlBOrTh4/L68MkKokHdqeMDx4gVOxzUGpTXn2RZEm0CAwEA
  37142. AaNTMFEwDwYDVR0TAQH/BAUwAwEB/zAfBgNVHSMEGDAWgBS6+nEleYtXQSUhhgtx67JkDoshZzAd
  37143. BgNVHQ4EFgQUuvpxJXmLV0ElIYYLceuyZA6LIWcwDQYJKoZIhvcNAQEFBQADggEBAH5Y//01GX2c
  37144. GE+esCu8jowU/yyg2kdbw++BLa8F6nRIW/M+TgfHbcWzk88iNVy2P3UnXwmWzaD+vkAMXBJV+JOC
  37145. yinpXj9WV4s4NvdFGkwozZ5BuO1WTISkQMi4sKUraXAEasP41BIy+Q7DsdwyhEQsb8tGD+pmQQ9P
  37146. 8Vilpg0ND2HepZ5dfWWhPBfnqFVO76DH7cZEf1T1o+CP8HxVIo8ptoGj4W1OLBuAZ+ytIJ8MYmHV
  37147. l/9D7S3B2l0pKoU/rGXuhg8FjZBf3+6f9L/uHfuY5H+QK4R4EA5sSVPvFVtlRkpdr7r7OnIdzfYl
  37148. iB6XzCGcKQENZetX2fNXlrtIzYE=
  37149. -----END CERTIFICATE-----
  37150. Buypass Class 2 Root CA
  37151. =======================
  37152. -----BEGIN CERTIFICATE-----
  37153. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  37154. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMiBSb290IENBMB4X
  37155. DTEwMTAyNjA4MzgwM1oXDTQwMTAyNjA4MzgwM1owTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  37156. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDIgUm9vdCBDQTCCAiIw
  37157. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBANfHXvfBB9R3+0Mh9PT1aeTuMgHbo4Yf5FkNuud1
  37158. g1Lr6hxhFUi7HQfKjK6w3Jad6sNgkoaCKHOcVgb/S2TwDCo3SbXlzwx87vFKu3MwZfPVL4O2fuPn
  37159. 9Z6rYPnT8Z2SdIrkHJasW4DptfQxh6NR/Md+oW+OU3fUl8FVM5I+GC911K2GScuVr1QGbNgGE41b
  37160. /+EmGVnAJLqBcXmQRFBoJJRfuLMR8SlBYaNByyM21cHxMlAQTn/0hpPshNOOvEu/XAFOBz3cFIqU
  37161. CqTqc/sLUegTBxj6DvEr0VQVfTzh97QZQmdiXnfgolXsttlpF9U6r0TtSsWe5HonfOV116rLJeff
  37162. awrbD02TTqigzXsu8lkBarcNuAeBfos4GzjmCleZPe4h6KP1DBbdi+w0jpwqHAAVF41og9JwnxgI
  37163. zRFo1clrUs3ERo/ctfPYV3Me6ZQ5BL/T3jjetFPsaRyifsSP5BtwrfKi+fv3FmRmaZ9JUaLiFRhn
  37164. Bkp/1Wy1TbMz4GHrXb7pmA8y1x1LPC5aAVKRCfLf6o3YBkBjqhHk/sM3nhRSP/TizPJhk9H9Z2vX
  37165. Uq6/aKtAQ6BXNVN48FP4YUIHZMbXb5tMOA1jrGKvNouicwoN9SG9dKpN6nIDSdvHXx1iY8f93ZHs
  37166. M+71bbRuMGjeyNYmsHVee7QHIJihdjK4TWxPAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  37167. VR0OBBYEFMmAd+BikoL1RpzzuvdMw964o605MA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  37168. AAOCAgEAU18h9bqwOlI5LJKwbADJ784g7wbylp7ppHR/ehb8t/W2+xUbP6umwHJdELFx7rxP462s
  37169. A20ucS6vxOOto70MEae0/0qyexAQH6dXQbLArvQsWdZHEIjzIVEpMMpghq9Gqx3tOluwlN5E40EI
  37170. osHsHdb9T7bWR9AUC8rmyrV7d35BH16Dx7aMOZawP5aBQW9gkOLo+fsicdl9sz1Gv7SEr5AcD48S
  37171. aq/v7h56rgJKihcrdv6sVIkkLE8/trKnToyokZf7KcZ7XC25y2a2t6hbElGFtQl+Ynhw/qlqYLYd
  37172. DnkM/crqJIByw5c/8nerQyIKx+u2DISCLIBrQYoIwOula9+ZEsuK1V6ADJHgJgg2SMX6OBE1/yWD
  37173. LfJ6v9r9jv6ly0UsH8SIU653DtmadsWOLB2jutXsMq7Aqqz30XpN69QH4kj3Io6wpJ9qzo6ysmD0
  37174. oyLQI+uUWnpp3Q+/QFesa1lQ2aOZ4W7+jQF5JyMV3pKdewlNWudLSDBaGOYKbeaP4NK75t98biGC
  37175. wWg5TbSYWGZizEqQXsP6JwSxeRV0mcy+rSDeJmAc61ZRpqPq5KM/p/9h3PFaTWwyI0PurKju7koS
  37176. CTxdccK+efrCh2gdC/1cacwG0Jp9VJkqyTkaGa9LKkPzY11aWOIv4x3kqdbQCtCev9eBCfHJxyYN
  37177. rJgWVqA=
  37178. -----END CERTIFICATE-----
  37179. Buypass Class 3 Root CA
  37180. =======================
  37181. -----BEGIN CERTIFICATE-----
  37182. MIIFWTCCA0GgAwIBAgIBAjANBgkqhkiG9w0BAQsFADBOMQswCQYDVQQGEwJOTzEdMBsGA1UECgwU
  37183. QnV5cGFzcyBBUy05ODMxNjMzMjcxIDAeBgNVBAMMF0J1eXBhc3MgQ2xhc3MgMyBSb290IENBMB4X
  37184. DTEwMTAyNjA4Mjg1OFoXDTQwMTAyNjA4Mjg1OFowTjELMAkGA1UEBhMCTk8xHTAbBgNVBAoMFEJ1
  37185. eXBhc3MgQVMtOTgzMTYzMzI3MSAwHgYDVQQDDBdCdXlwYXNzIENsYXNzIDMgUm9vdCBDQTCCAiIw
  37186. DQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAKXaCpUWUOOV8l6ddjEGMnqb8RB2uACatVI2zSRH
  37187. sJ8YZLya9vrVediQYkwiL944PdbgqOkcLNt4EemOaFEVcsfzM4fkoF0LXOBXByow9c3EN3coTRiR
  37188. 5r/VUv1xLXA+58bEiuPwKAv0dpihi4dVsjoT/Lc+JzeOIuOoTyrvYLs9tznDDgFHmV0ST9tD+leh
  37189. 7fmdvhFHJlsTmKtdFoqwNxxXnUX/iJY2v7vKB3tvh2PX0DJq1l1sDPGzbjniazEuOQAnFN44wOwZ
  37190. ZoYS6J1yFhNkUsepNxz9gjDthBgd9K5c/3ATAOux9TN6S9ZV+AWNS2mw9bMoNlwUxFFzTWsL8TQH
  37191. 2xc519woe2v1n/MuwU8XKhDzzMro6/1rqy6any2CbgTUUgGTLT2G/H783+9CHaZr77kgxve9oKeV
  37192. /afmiSTYzIw0bOIjL9kSGiG5VZFvC5F5GQytQIgLcOJ60g7YaEi7ghM5EFjp2CoHxhLbWNvSO1UQ
  37193. RwUVZ2J+GGOmRj8JDlQyXr8NYnon74Do29lLBlo3WiXQCBJ31G8JUJc9yB3D34xFMFbG02SrZvPA
  37194. Xpacw8Tvw3xrizp5f7NJzz3iiZ+gMEuFuZyUJHmPfWupRWgPK9Dx2hzLabjKSWJtyNBjYt1gD1iq
  37195. j6G8BaVmos8bdrKEZLFMOVLAMLrwjEsCsLa3AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wHQYD
  37196. VR0OBBYEFEe4zf/lb+74suwvTg75JbCOPGvDMA4GA1UdDwEB/wQEAwIBBjANBgkqhkiG9w0BAQsF
  37197. AAOCAgEAACAjQTUEkMJAYmDv4jVM1z+s4jSQuKFvdvoWFqRINyzpkMLyPPgKn9iB5btb2iUspKdV
  37198. cSQy9sgL8rxq+JOssgfCX5/bzMiKqr5qb+FJEMwx14C7u8jYog5kV+qi9cKpMRXSIGrs/CIBKM+G
  37199. uIAeqcwRpTzyFrNHnfzSgCHEy9BHcEGhyoMZCCxt8l13nIoUE9Q2HJLw5QY33KbmkJs4j1xrG0aG
  37200. Q0JfPgEHU1RdZX33inOhmlRaHylDFCfChQ+1iHsaO5S3HWCntZznKWlXWpuTekMwGwPXYshApqr8
  37201. ZORK15FTAaggiG6cX0S5y2CBNOxv033aSF/rtJC8LakcC6wc1aJoIIAE1vyxjy+7SjENSoYc6+I2
  37202. KSb12tjE8nVhz36udmNKekBlk4f4HoCMhuWG1o8O/FMsYOgWYRqiPkN7zTlgVGr18okmAWiDSKIz
  37203. 6MkEkbIRNBE+6tBDGR8Dk5AM/1E9V/RBbuHLoL7ryWPNbczk+DaqaJ3tvV2XcEQNtg413OEMXbug
  37204. UZTLfhbrES+jkkXITHHZvMmZUldGL1DPvTVp9D0VzgalLA8+9oG6lLvDu79leNKGef9JOxqDDPDe
  37205. eOzI8k1MGt6CKfjBWtrt7uYnXuhF0J0cUahoq0Tj0Itq4/g7u9xN12TyUb7mqqta6THuBrxzvxNi
  37206. Cp/HuZc=
  37207. -----END CERTIFICATE-----
  37208. T-TeleSec GlobalRoot Class 3
  37209. ============================
  37210. -----BEGIN CERTIFICATE-----
  37211. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  37212. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  37213. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwHhcNMDgx
  37214. MDAxMTAyOTU2WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  37215. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  37216. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDMwggEiMA0GCSqGSIb3
  37217. DQEBAQUAA4IBDwAwggEKAoIBAQC9dZPwYiJvJK7genasfb3ZJNW4t/zN8ELg63iIVl6bmlQdTQyK
  37218. 9tPPcPRStdiTBONGhnFBSivwKixVA9ZIw+A5OO3yXDw/RLyTPWGrTs0NvvAgJ1gORH8EGoel15YU
  37219. NpDQSXuhdfsaa3Ox+M6pCSzyU9XDFES4hqX2iys52qMzVNn6chr3IhUciJFrf2blw2qAsCTz34ZF
  37220. iP0Zf3WHHx+xGwpzJFu5ZeAsVMhg02YXP+HMVDNzkQI6pn97djmiH5a2OK61yJN0HZ65tOVgnS9W
  37221. 0eDrXltMEnAMbEQgqxHY9Bn20pxSN+f6tsIxO0rUFJmtxxr1XV/6B7h8DR/Wgx6zAgMBAAGjQjBA
  37222. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS1A/d2O2GCahKqGFPr
  37223. AyGUv/7OyjANBgkqhkiG9w0BAQsFAAOCAQEAVj3vlNW92nOyWL6ukK2YJ5f+AbGwUgC4TeQbIXQb
  37224. fsDuXmkqJa9c1h3a0nnJ85cp4IaH3gRZD/FZ1GSFS5mvJQQeyUapl96Cshtwn5z2r3Ex3XsFpSzT
  37225. ucpH9sry9uetuUg/vBa3wW306gmv7PO15wWeph6KU1HWk4HMdJP2udqmJQV0eVp+QD6CSyYRMG7h
  37226. P0HHRwA11fXT91Q+gT3aSWqas+8QPebrb9HIIkfLzM8BMZLZGOMivgkeGj5asuRrDFR6fUNOuIml
  37227. e9eiPZaGzPImNC1qkp2aGtAw4l1OBLBfiyB+d8E9lYLRRpo7PHi4b6HQDWSieB4pTpPDpFQUWw==
  37228. -----END CERTIFICATE-----
  37229. D-TRUST Root Class 3 CA 2 2009
  37230. ==============================
  37231. -----BEGIN CERTIFICATE-----
  37232. MIIEMzCCAxugAwIBAgIDCYPzMA0GCSqGSIb3DQEBCwUAME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37233. DAxELVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTAe
  37234. Fw0wOTExMDUwODM1NThaFw0yOTExMDUwODM1NThaME0xCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxE
  37235. LVRydXN0IEdtYkgxJzAlBgNVBAMMHkQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgMjAwOTCCASIw
  37236. DQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANOySs96R+91myP6Oi/WUEWJNTrGa9v+2wBoqOAD
  37237. ER03UAifTUpolDWzU9GUY6cgVq/eUXjsKj3zSEhQPgrfRlWLJ23DEE0NkVJD2IfgXU42tSHKXzlA
  37238. BF9bfsyjxiupQB7ZNoTWSPOSHjRGICTBpFGOShrvUD9pXRl/RcPHAY9RySPocq60vFYJfxLLHLGv
  37239. KZAKyVXMD9O0Gu1HNVpK7ZxzBCHQqr0ME7UAyiZsxGsMlFqVlNpQmvH/pStmMaTJOKDfHR+4CS7z
  37240. p+hnUquVH+BGPtikw8paxTGA6Eian5Rp/hnd2HN8gcqW3o7tszIFZYQ05ub9VxC1X3a/L7AQDcUC
  37241. AwEAAaOCARowggEWMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFP3aFMSfMN4hvR5COfyrYyNJ
  37242. 4PGEMA4GA1UdDwEB/wQEAwIBBjCB0wYDVR0fBIHLMIHIMIGAoH6gfIZ6bGRhcDovL2RpcmVjdG9y
  37243. eS5kLXRydXN0Lm5ldC9DTj1ELVRSVVNUJTIwUm9vdCUyMENsYXNzJTIwMyUyMENBJTIwMiUyMDIw
  37244. MDksTz1ELVRydXN0JTIwR21iSCxDPURFP2NlcnRpZmljYXRlcmV2b2NhdGlvbmxpc3QwQ6BBoD+G
  37245. PWh0dHA6Ly93d3cuZC10cnVzdC5uZXQvY3JsL2QtdHJ1c3Rfcm9vdF9jbGFzc18zX2NhXzJfMjAw
  37246. OS5jcmwwDQYJKoZIhvcNAQELBQADggEBAH+X2zDI36ScfSF6gHDOFBJpiBSVYEQBrLLpME+bUMJm
  37247. 2H6NMLVwMeniacfzcNsgFYbQDfC+rAF1hM5+n02/t2A7nPPKHeJeaNijnZflQGDSNiH+0LS4F9p0
  37248. o3/U37CYAqxva2ssJSRyoWXuJVrl5jLn8t+rSfrzkGkj2wTZ51xY/GXUl77M/C4KzCUqNQT4YJEV
  37249. dT1B/yMfGchs64JTBKbkTCJNjYy6zltz7GRUUG3RnFX7acM2w4y8PIWmawomDeCTmGCufsYkl4ph
  37250. X5GOZpIJhzbNi5stPvZR1FDUWSi9g/LMKHtThm3YJohw1+qRzT65ysCQblrGXnRl11z+o+I=
  37251. -----END CERTIFICATE-----
  37252. D-TRUST Root Class 3 CA 2 EV 2009
  37253. =================================
  37254. -----BEGIN CERTIFICATE-----
  37255. MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37256. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  37257. OTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUwNDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQK
  37258. DAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAw
  37259. OTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfS
  37260. egpnljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM03TP1YtHh
  37261. zRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6ZqQTMFexgaDbtCHu39b+T
  37262. 7WYxg4zGcTSHThfqr4uRjRxWQa4iN1438h3Z0S0NL2lRp75mpoo6Kr3HGrHhFPC+Oh25z1uxav60
  37263. sUYgovseO3Dvk5h9jHOW8sXvhXCtKSb8HgQ+HKDYD8tSg2J87otTlZCpV6LqYQXY+U3EJ/pure35
  37264. 11H3a6UCAwEAAaOCASQwggEgMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFNOUikxiEyoZLsyv
  37265. cop9NteaHNxnMA4GA1UdDwEB/wQEAwIBBjCB3QYDVR0fBIHVMIHSMIGHoIGEoIGBhn9sZGFwOi8v
  37266. ZGlyZWN0b3J5LmQtdHJ1c3QubmV0L0NOPUQtVFJVU1QlMjBSb290JTIwQ2xhc3MlMjAzJTIwQ0El
  37267. MjAyJTIwRVYlMjAyMDA5LE89RC1UcnVzdCUyMEdtYkgsQz1ERT9jZXJ0aWZpY2F0ZXJldm9jYXRp
  37268. b25saXN0MEagRKBChkBodHRwOi8vd3d3LmQtdHJ1c3QubmV0L2NybC9kLXRydXN0X3Jvb3RfY2xh
  37269. c3NfM19jYV8yX2V2XzIwMDkuY3JsMA0GCSqGSIb3DQEBCwUAA4IBAQA07XtaPKSUiO8aEXUHL7P+
  37270. PPoeUSbrh/Yp3uDx1MYkCenBz1UbtDDZzhr+BlGmFaQt77JLvyAoJUnRpjZ3NOhk31KxEcdzes05
  37271. nsKtjHEh8lprr988TlWvsoRlFIm5d8sqMb7Po23Pb0iUMkZv53GMoKaEGTcH8gNFCSuGdXzfX2lX
  37272. ANtu2KZyIktQ1HWYVt+3GP9DQ1CuekR78HlR10M9p9OB0/DJT7naxpeG0ILD5EJt/rDiZE4OJudA
  37273. NCa1CInXCGNjOCd1HjPqbqjdn5lPdE2BiYBL3ZqXKVwvvoFBuYz/6n1gBp7N1z3TLqMVvKjmJuVv
  37274. w9y4AyHqnxbxLFS1
  37275. -----END CERTIFICATE-----
  37276. CA Disig Root R2
  37277. ================
  37278. -----BEGIN CERTIFICATE-----
  37279. MIIFaTCCA1GgAwIBAgIJAJK4iNuwisFjMA0GCSqGSIb3DQEBCwUAMFIxCzAJBgNVBAYTAlNLMRMw
  37280. EQYDVQQHEwpCcmF0aXNsYXZhMRMwEQYDVQQKEwpEaXNpZyBhLnMuMRkwFwYDVQQDExBDQSBEaXNp
  37281. ZyBSb290IFIyMB4XDTEyMDcxOTA5MTUzMFoXDTQyMDcxOTA5MTUzMFowUjELMAkGA1UEBhMCU0sx
  37282. EzARBgNVBAcTCkJyYXRpc2xhdmExEzARBgNVBAoTCkRpc2lnIGEucy4xGTAXBgNVBAMTEENBIERp
  37283. c2lnIFJvb3QgUjIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCio8QACdaFXS1tFPbC
  37284. w3OeNcJxVX6B+6tGUODBfEl45qt5WDza/3wcn9iXAng+a0EE6UG9vgMsRfYvZNSrXaNHPWSb6Wia
  37285. xswbP7q+sos0Ai6YVRn8jG+qX9pMzk0DIaPY0jSTVpbLTAwAFjxfGs3Ix2ymrdMxp7zo5eFm1tL7
  37286. A7RBZckQrg4FY8aAamkw/dLukO8NJ9+flXP04SXabBbeQTg06ov80egEFGEtQX6sx3dOy1FU+16S
  37287. GBsEWmjGycT6txOgmLcRK7fWV8x8nhfRyyX+hk4kLlYMeE2eARKmK6cBZW58Yh2EhN/qwGu1pSqV
  37288. g8NTEQxzHQuyRpDRQjrOQG6Vrf/GlK1ul4SOfW+eioANSW1z4nuSHsPzwfPrLgVv2RvPN3YEyLRa
  37289. 5Beny912H9AZdugsBbPWnDTYltxhh5EF5EQIM8HauQhl1K6yNg3ruji6DOWbnuuNZt2Zz9aJQfYE
  37290. koopKW1rOhzndX0CcQ7zwOe9yxndnWCywmZgtrEE7snmhrmaZkCo5xHtgUUDi/ZnWejBBhG93c+A
  37291. Ak9lQHhcR1DIm+YfgXvkRKhbhZri3lrVx/k6RGZL5DJUfORsnLMOPReisjQS1n6yqEm70XooQL6i
  37292. Fh/f5DcfEXP7kAplQ6INfPgGAVUzfbANuPT1rqVCV3w2EYx7XsQDnYx5nQIDAQABo0IwQDAPBgNV
  37293. HRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUtZn4r7CU9eMg1gqtzk5WpC5u
  37294. Qu0wDQYJKoZIhvcNAQELBQADggIBACYGXnDnZTPIgm7ZnBc6G3pmsgH2eDtpXi/q/075KMOYKmFM
  37295. tCQSin1tERT3nLXK5ryeJ45MGcipvXrA1zYObYVybqjGom32+nNjf7xueQgcnYqfGopTpti72TVV
  37296. sRHFqQOzVju5hJMiXn7B9hJSi+osZ7z+Nkz1uM/Rs0mSO9MpDpkblvdhuDvEK7Z4bLQjb/D907Je
  37297. dR+Zlais9trhxTF7+9FGs9K8Z7RiVLoJ92Owk6Ka+elSLotgEqv89WBW7xBci8QaQtyDW2QOy7W8
  37298. 1k/BfDxujRNt+3vrMNDcTa/F1balTFtxyegxvug4BkihGuLq0t4SOVga/4AOgnXmt8kHbA7v/zjx
  37299. mHHEt38OFdAlab0inSvtBfZGR6ztwPDUO+Ls7pZbkBNOHlY667DvlruWIxG68kOGdGSVyCh13x01
  37300. utI3gzhTODY7z2zp+WsO0PsE6E9312UBeIYMej4hYvF/Y3EMyZ9E26gnonW+boE+18DrG5gPcFw0
  37301. sorMwIUY6256s/daoQe/qUKS82Ail+QUoQebTnbAjn39pCXHR+3/H3OszMOl6W8KjptlwlCFtaOg
  37302. UxLMVYdh84GuEEZhvUQhuMI9dM9+JDX6HAcOmz0iyu8xL4ysEr3vQCj8KWefshNPZiTEUxnpHikV
  37303. 7+ZtsH8tZ/3zbBt1RqPlShfppNcL
  37304. -----END CERTIFICATE-----
  37305. ACCVRAIZ1
  37306. =========
  37307. -----BEGIN CERTIFICATE-----
  37308. MIIH0zCCBbugAwIBAgIIXsO3pkN/pOAwDQYJKoZIhvcNAQEFBQAwQjESMBAGA1UEAwwJQUNDVlJB
  37309. SVoxMRAwDgYDVQQLDAdQS0lBQ0NWMQ0wCwYDVQQKDARBQ0NWMQswCQYDVQQGEwJFUzAeFw0xMTA1
  37310. MDUwOTM3MzdaFw0zMDEyMzEwOTM3MzdaMEIxEjAQBgNVBAMMCUFDQ1ZSQUlaMTEQMA4GA1UECwwH
  37311. UEtJQUNDVjENMAsGA1UECgwEQUNDVjELMAkGA1UEBhMCRVMwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  37312. DwAwggIKAoICAQCbqau/YUqXry+XZpp0X9DZlv3P4uRm7x8fRzPCRKPfmt4ftVTdFXxpNRFvu8gM
  37313. jmoYHtiP2Ra8EEg2XPBjs5BaXCQ316PWywlxufEBcoSwfdtNgM3802/J+Nq2DoLSRYWoG2ioPej0
  37314. RGy9ocLLA76MPhMAhN9KSMDjIgro6TenGEyxCQ0jVn8ETdkXhBilyNpAlHPrzg5XPAOBOp0KoVdD
  37315. aaxXbXmQeOW1tDvYvEyNKKGno6e6Ak4l0Squ7a4DIrhrIA8wKFSVf+DuzgpmndFALW4ir50awQUZ
  37316. 0m/A8p/4e7MCQvtQqR0tkw8jq8bBD5L/0KIV9VMJcRz/RROE5iZe+OCIHAr8Fraocwa48GOEAqDG
  37317. WuzndN9wrqODJerWx5eHk6fGioozl2A3ED6XPm4pFdahD9GILBKfb6qkxkLrQaLjlUPTAYVtjrs7
  37318. 8yM2x/474KElB0iryYl0/wiPgL/AlmXz7uxLaL2diMMxs0Dx6M/2OLuc5NF/1OVYm3z61PMOm3WR
  37319. 5LpSLhl+0fXNWhn8ugb2+1KoS5kE3fj5tItQo05iifCHJPqDQsGH+tUtKSpacXpkatcnYGMN285J
  37320. 9Y0fkIkyF/hzQ7jSWpOGYdbhdQrqeWZ2iE9x6wQl1gpaepPluUsXQA+xtrn13k/c4LOsOxFwYIRK
  37321. Q26ZIMApcQrAZQIDAQABo4ICyzCCAscwfQYIKwYBBQUHAQEEcTBvMEwGCCsGAQUFBzAChkBodHRw
  37322. Oi8vd3d3LmFjY3YuZXMvZmlsZWFkbWluL0FyY2hpdm9zL2NlcnRpZmljYWRvcy9yYWl6YWNjdjEu
  37323. Y3J0MB8GCCsGAQUFBzABhhNodHRwOi8vb2NzcC5hY2N2LmVzMB0GA1UdDgQWBBTSh7Tj3zcnk1X2
  37324. VuqB5TbMjB4/vTAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFNKHtOPfNyeTVfZW6oHlNsyM
  37325. Hj+9MIIBcwYDVR0gBIIBajCCAWYwggFiBgRVHSAAMIIBWDCCASIGCCsGAQUFBwICMIIBFB6CARAA
  37326. QQB1AHQAbwByAGkAZABhAGQAIABkAGUAIABDAGUAcgB0AGkAZgBpAGMAYQBjAGkA8wBuACAAUgBh
  37327. AO0AegAgAGQAZQAgAGwAYQAgAEEAQwBDAFYAIAAoAEEAZwBlAG4AYwBpAGEAIABkAGUAIABUAGUA
  37328. YwBuAG8AbABvAGcA7QBhACAAeQAgAEMAZQByAHQAaQBmAGkAYwBhAGMAaQDzAG4AIABFAGwAZQBj
  37329. AHQAcgDzAG4AaQBjAGEALAAgAEMASQBGACAAUQA0ADYAMAAxADEANQA2AEUAKQAuACAAQwBQAFMA
  37330. IABlAG4AIABoAHQAdABwADoALwAvAHcAdwB3AC4AYQBjAGMAdgAuAGUAczAwBggrBgEFBQcCARYk
  37331. aHR0cDovL3d3dy5hY2N2LmVzL2xlZ2lzbGFjaW9uX2MuaHRtMFUGA1UdHwROMEwwSqBIoEaGRGh0
  37332. dHA6Ly93d3cuYWNjdi5lcy9maWxlYWRtaW4vQXJjaGl2b3MvY2VydGlmaWNhZG9zL3JhaXphY2N2
  37333. MV9kZXIuY3JsMA4GA1UdDwEB/wQEAwIBBjAXBgNVHREEEDAOgQxhY2N2QGFjY3YuZXMwDQYJKoZI
  37334. hvcNAQEFBQADggIBAJcxAp/n/UNnSEQU5CmH7UwoZtCPNdpNYbdKl02125DgBS4OxnnQ8pdpD70E
  37335. R9m+27Up2pvZrqmZ1dM8MJP1jaGo/AaNRPTKFpV8M9xii6g3+CfYCS0b78gUJyCpZET/LtZ1qmxN
  37336. YEAZSUNUY9rizLpm5U9EelvZaoErQNV/+QEnWCzI7UiRfD+mAM/EKXMRNt6GGT6d7hmKG9Ww7Y49
  37337. nCrADdg9ZuM8Db3VlFzi4qc1GwQA9j9ajepDvV+JHanBsMyZ4k0ACtrJJ1vnE5Bc5PUzolVt3OAJ
  37338. TS+xJlsndQAJxGJ3KQhfnlmstn6tn1QwIgPBHnFk/vk4CpYY3QIUrCPLBhwepH2NDd4nQeit2hW3
  37339. sCPdK6jT2iWH7ehVRE2I9DZ+hJp4rPcOVkkO1jMl1oRQQmwgEh0q1b688nCBpHBgvgW1m54ERL5h
  37340. I6zppSSMEYCUWqKiuUnSwdzRp+0xESyeGabu4VXhwOrPDYTkF7eifKXeVSUG7szAh1xA2syVP1Xg
  37341. Nce4hL60Xc16gwFy7ofmXx2utYXGJt/mwZrpHgJHnyqobalbz+xFd3+YJ5oyXSrjhO7FmGYvliAd
  37342. 3djDJ9ew+f7Zfc3Qn48LFFhRny+Lwzgt3uiP1o2HpPVWQxaZLPSkVrQ0uGE3ycJYgBugl6H8WY3p
  37343. EfbRD0tVNEYqi4Y7
  37344. -----END CERTIFICATE-----
  37345. TWCA Global Root CA
  37346. ===================
  37347. -----BEGIN CERTIFICATE-----
  37348. MIIFQTCCAymgAwIBAgICDL4wDQYJKoZIhvcNAQELBQAwUTELMAkGA1UEBhMCVFcxEjAQBgNVBAoT
  37349. CVRBSVdBTi1DQTEQMA4GA1UECxMHUm9vdCBDQTEcMBoGA1UEAxMTVFdDQSBHbG9iYWwgUm9vdCBD
  37350. QTAeFw0xMjA2MjcwNjI4MzNaFw0zMDEyMzExNTU5NTlaMFExCzAJBgNVBAYTAlRXMRIwEAYDVQQK
  37351. EwlUQUlXQU4tQ0ExEDAOBgNVBAsTB1Jvb3QgQ0ExHDAaBgNVBAMTE1RXQ0EgR2xvYmFsIFJvb3Qg
  37352. Q0EwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCwBdvI64zEbooh745NnHEKH1Jw7W2C
  37353. nJfF10xORUnLQEK1EjRsGcJ0pDFfhQKX7EMzClPSnIyOt7h52yvVavKOZsTuKwEHktSz0ALfUPZV
  37354. r2YOy+BHYC8rMjk1Ujoog/h7FsYYuGLWRyWRzvAZEk2tY/XTP3VfKfChMBwqoJimFb3u/Rk28OKR
  37355. Q4/6ytYQJ0lM793B8YVwm8rqqFpD/G2Gb3PpN0Wp8DbHzIh1HrtsBv+baz4X7GGqcXzGHaL3SekV
  37356. tTzWoWH1EfcFbx39Eb7QMAfCKbAJTibc46KokWofwpFFiFzlmLhxpRUZyXx1EcxwdE8tmx2RRP1W
  37357. KKD+u4ZqyPpcC1jcxkt2yKsi2XMPpfRaAok/T54igu6idFMqPVMnaR1sjjIsZAAmY2E2TqNGtz99
  37358. sy2sbZCilaLOz9qC5wc0GZbpuCGqKX6mOL6OKUohZnkfs8O1CWfe1tQHRvMq2uYiN2DLgbYPoA/p
  37359. yJV/v1WRBXrPPRXAb94JlAGD1zQbzECl8LibZ9WYkTunhHiVJqRaCPgrdLQABDzfuBSO6N+pjWxn
  37360. kjMdwLfS7JLIvgm/LCkFbwJrnu+8vyq8W8BQj0FwcYeyTbcEqYSjMq+u7msXi7Kx/mzhkIyIqJdI
  37361. zshNy/MGz19qCkKxHh53L46g5pIOBvwFItIm4TFRfTLcDwIDAQABoyMwITAOBgNVHQ8BAf8EBAMC
  37362. AQYwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAgEAXzSBdu+WHdXltdkCY4QWwa6g
  37363. cFGn90xHNcgL1yg9iXHZqjNB6hQbbCEAwGxCGX6faVsgQt+i0trEfJdLjbDorMjupWkEmQqSpqsn
  37364. LhpNgb+E1HAerUf+/UqdM+DyucRFCCEK2mlpc3INvjT+lIutwx4116KD7+U4x6WFH6vPNOw/KP4M
  37365. 8VeGTslV9xzU2KV9Bnpv1d8Q34FOIWWxtuEXeZVFBs5fzNxGiWNoRI2T9GRwoD2dKAXDOXC4Ynsg
  37366. /eTb6QihuJ49CcdP+yz4k3ZB3lLg4VfSnQO8d57+nile98FRYB/e2guyLXW3Q0iT5/Z5xoRdgFlg
  37367. lPx4mI88k1HtQJAH32RjJMtOcQWh15QaiDLxInQirqWm2BJpTGCjAu4r7NRjkgtevi92a6O2JryP
  37368. A9gK8kxkRr05YuWW6zRjESjMlfGt7+/cgFhI6Uu46mWs6fyAtbXIRfmswZ/ZuepiiI7E8UuDEq3m
  37369. i4TWnsLrgxifarsbJGAzcMzs9zLzXNl5fe+epP7JI8Mk7hWSsT2RTyaGvWZzJBPqpK5jwa19hAM8
  37370. EHiGG3njxPPyBJUgriOCxLM6AGK/5jYk4Ve6xx6QddVfP5VhK8E7zeWzaGHQRiapIVJpLesux+t3
  37371. zqY6tQMzT3bR51xUAV3LePTJDL/PEo4XLSNolOer/qmyKwbQBM0=
  37372. -----END CERTIFICATE-----
  37373. TeliaSonera Root CA v1
  37374. ======================
  37375. -----BEGIN CERTIFICATE-----
  37376. MIIFODCCAyCgAwIBAgIRAJW+FqD3LkbxezmCcvqLzZYwDQYJKoZIhvcNAQEFBQAwNzEUMBIGA1UE
  37377. CgwLVGVsaWFTb25lcmExHzAdBgNVBAMMFlRlbGlhU29uZXJhIFJvb3QgQ0EgdjEwHhcNMDcxMDE4
  37378. MTIwMDUwWhcNMzIxMDE4MTIwMDUwWjA3MRQwEgYDVQQKDAtUZWxpYVNvbmVyYTEfMB0GA1UEAwwW
  37379. VGVsaWFTb25lcmEgUm9vdCBDQSB2MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAMK+
  37380. 6yfwIaPzaSZVfp3FVRaRXP3vIb9TgHot0pGMYzHw7CTww6XScnwQbfQ3t+XmfHnqjLWCi65ItqwA
  37381. 3GV17CpNX8GH9SBlK4GoRz6JI5UwFpB/6FcHSOcZrr9FZ7E3GwYq/t75rH2D+1665I+XZ75Ljo1k
  37382. B1c4VWk0Nj0TSO9P4tNmHqTPGrdeNjPUtAa9GAH9d4RQAEX1jF3oI7x+/jXh7VB7qTCNGdMJjmhn
  37383. Xb88lxhTuylixcpecsHHltTbLaC0H2kD7OriUPEMPPCs81Mt8Bz17Ww5OXOAFshSsCPN4D7c3TxH
  37384. oLs1iuKYaIu+5b9y7tL6pe0S7fyYGKkmdtwoSxAgHNN/Fnct7W+A90m7UwW7XWjH1Mh1Fj+JWov3
  37385. F0fUTPHSiXk+TT2YqGHeOh7S+F4D4MHJHIzTjU3TlTazN19jY5szFPAtJmtTfImMMsJu7D0hADnJ
  37386. oWjiUIMusDor8zagrC/kb2HCUQk5PotTubtn2txTuXZZNp1D5SDgPTJghSJRt8czu90VL6R4pgd7
  37387. gUY2BIbdeTXHlSw7sKMXNeVzH7RcWe/a6hBle3rQf5+ztCo3O3CLm1u5K7fsslESl1MpWtTwEhDc
  37388. TwK7EpIvYtQ/aUN8Ddb8WHUBiJ1YFkveupD/RwGJBmr2X7KQarMCpgKIv7NHfirZ1fpoeDVNAgMB
  37389. AAGjPzA9MA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQDAgEGMB0GA1UdDgQWBBTwj1k4ALP1j5qW
  37390. DNXr+nuqF+gTEjANBgkqhkiG9w0BAQUFAAOCAgEAvuRcYk4k9AwI//DTDGjkk0kiP0Qnb7tt3oNm
  37391. zqjMDfz1mgbldxSR651Be5kqhOX//CHBXfDkH1e3damhXwIm/9fH907eT/j3HEbAek9ALCI18Bmx
  37392. 0GtnLLCo4MBANzX2hFxc469CeP6nyQ1Q6g2EdvZR74NTxnr/DlZJLo961gzmJ1TjTQpgcmLNkQfW
  37393. pb/ImWvtxBnmq0wROMVvMeJuScg/doAmAyYp4Db29iBT4xdwNBedY2gea+zDTYa4EzAvXUYNR0PV
  37394. G6pZDrlcjQZIrXSHX8f8MVRBE+LHIQ6e4B4N4cB7Q4WQxYpYxmUKeFfyxiMPAdkgS94P+5KFdSpc
  37395. c41teyWRyu5FrgZLAMzTsVlQ2jqIOylDRl6XK1TOU2+NSueW+r9xDkKLfP0ooNBIytrEgUy7onOT
  37396. JsjrDNYmiLbAJM+7vVvrdX3pCI6GMyx5dwlppYn8s3CQh3aP0yK7Qs69cwsgJirQmz1wHiRszYd2
  37397. qReWt88NkvuOGKmYSdGe/mBEciG5Ge3C9THxOUiIkCR1VBatzvT4aRRkOfujuLpwQMcnHL/EVlP6
  37398. Y2XQ8xwOFvVrhlhNGNTkDY6lnVuR3HYkUD/GKvvZt5y11ubQ2egZixVxSK236thZiNSQvxaz2ems
  37399. WWFUyBy6ysHK4bkgTI86k4mloMy/0/Z1pHWWbVY=
  37400. -----END CERTIFICATE-----
  37401. E-Tugra Certification Authority
  37402. ===============================
  37403. -----BEGIN CERTIFICATE-----
  37404. MIIGSzCCBDOgAwIBAgIIamg+nFGby1MwDQYJKoZIhvcNAQELBQAwgbIxCzAJBgNVBAYTAlRSMQ8w
  37405. DQYDVQQHDAZBbmthcmExQDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamls
  37406. ZXJpIHZlIEhpem1ldGxlcmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBN
  37407. ZXJrZXppMSgwJgYDVQQDDB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MB4XDTEzMDMw
  37408. NTEyMDk0OFoXDTIzMDMwMzEyMDk0OFowgbIxCzAJBgNVBAYTAlRSMQ8wDQYDVQQHDAZBbmthcmEx
  37409. QDA+BgNVBAoMN0UtVHXEn3JhIEVCRyBCaWxpxZ9pbSBUZWtub2xvamlsZXJpIHZlIEhpem1ldGxl
  37410. cmkgQS7Fni4xJjAkBgNVBAsMHUUtVHVncmEgU2VydGlmaWthc3lvbiBNZXJrZXppMSgwJgYDVQQD
  37411. DB9FLVR1Z3JhIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  37412. MIICCgKCAgEA4vU/kwVRHoViVF56C/UYB4Oufq9899SKa6VjQzm5S/fDxmSJPZQuVIBSOTkHS0vd
  37413. hQd2h8y/L5VMzH2nPbxHD5hw+IyFHnSOkm0bQNGZDbt1bsipa5rAhDGvykPL6ys06I+XawGb1Q5K
  37414. CKpbknSFQ9OArqGIW66z6l7LFpp3RMih9lRozt6Plyu6W0ACDGQXwLWTzeHxE2bODHnv0ZEoq1+g
  37415. ElIwcxmOj+GMB6LDu0rw6h8VqO4lzKRG+Bsi77MOQ7osJLjFLFzUHPhdZL3Dk14opz8n8Y4e0ypQ
  37416. BaNV2cvnOVPAmJ6MVGKLJrD3fY185MaeZkJVgkfnsliNZvcHfC425lAcP9tDJMW/hkd5s3kc91r0
  37417. E+xs+D/iWR+V7kI+ua2oMoVJl0b+SzGPWsutdEcf6ZG33ygEIqDUD13ieU/qbIWGvaimzuT6w+Gz
  37418. rt48Ue7LE3wBf4QOXVGUnhMMti6lTPk5cDZvlsouDERVxcr6XQKj39ZkjFqzAQqptQpHF//vkUAq
  37419. jqFGOjGY5RH8zLtJVor8udBhmm9lbObDyz51Sf6Pp+KJxWfXnUYTTjF2OySznhFlhqt/7x3U+Lzn
  37420. rFpct1pHXFXOVbQicVtbC/DP3KBhZOqp12gKY6fgDT+gr9Oq0n7vUaDmUStVkhUXU8u3Zg5mTPj5
  37421. dUyQ5xJwx0UCAwEAAaNjMGEwHQYDVR0OBBYEFC7j27JJ0JxUeVz6Jyr+zE7S6E5UMA8GA1UdEwEB
  37422. /wQFMAMBAf8wHwYDVR0jBBgwFoAULuPbsknQnFR5XPonKv7MTtLoTlQwDgYDVR0PAQH/BAQDAgEG
  37423. MA0GCSqGSIb3DQEBCwUAA4ICAQAFNzr0TbdF4kV1JI+2d1LoHNgQk2Xz8lkGpD4eKexd0dCrfOAK
  37424. kEh47U6YA5n+KGCRHTAduGN8qOY1tfrTYXbm1gdLymmasoR6d5NFFxWfJNCYExL/u6Au/U5Mh/jO
  37425. XKqYGwXgAEZKgoClM4so3O0409/lPun++1ndYYRP0lSWE2ETPo+Aab6TR7U1Q9Jauz1c77NCR807
  37426. VRMGsAnb/WP2OogKmW9+4c4bU2pEZiNRCHu8W1Ki/QY3OEBhj0qWuJA3+GbHeJAAFS6LrVE1Uweo
  37427. a2iu+U48BybNCAVwzDk/dr2l02cmAYamU9JgO3xDf1WKvJUawSg5TB9D0pH0clmKuVb8P7Sd2nCc
  37428. dlqMQ1DujjByTd//SffGqWfZbawCEeI6FiWnWAjLb1NBnEg4R2gz0dfHj9R0IdTDBZB6/86WiLEV
  37429. KV0jq9BgoRJP3vQXzTLlyb/IQ639Lo7xr+L0mPoSHyDYwKcMhcWQ9DstliaxLL5Mq+ux0orJ23gT
  37430. Dx4JnW2PAJ8C2sH6H3p6CcRK5ogql5+Ji/03X186zjhZhkuvcQu02PJwT58yE+Owp1fl2tpDy4Q0
  37431. 8ijE6m30Ku/Ba3ba+367hTzSU8JNvnHhRdH9I2cNE3X7z2VnIp2usAnRCf8dNL/+I5c30jn6PQ0G
  37432. C7TbO6Orb1wdtn7os4I07QZcJA==
  37433. -----END CERTIFICATE-----
  37434. T-TeleSec GlobalRoot Class 2
  37435. ============================
  37436. -----BEGIN CERTIFICATE-----
  37437. MIIDwzCCAqugAwIBAgIBATANBgkqhkiG9w0BAQsFADCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoM
  37438. IlQtU3lzdGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBU
  37439. cnVzdCBDZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwHhcNMDgx
  37440. MDAxMTA0MDE0WhcNMzMxMDAxMjM1OTU5WjCBgjELMAkGA1UEBhMCREUxKzApBgNVBAoMIlQtU3lz
  37441. dGVtcyBFbnRlcnByaXNlIFNlcnZpY2VzIEdtYkgxHzAdBgNVBAsMFlQtU3lzdGVtcyBUcnVzdCBD
  37442. ZW50ZXIxJTAjBgNVBAMMHFQtVGVsZVNlYyBHbG9iYWxSb290IENsYXNzIDIwggEiMA0GCSqGSIb3
  37443. DQEBAQUAA4IBDwAwggEKAoIBAQCqX9obX+hzkeXaXPSi5kfl82hVYAUdAqSzm1nzHoqvNK38DcLZ
  37444. SBnuaY/JIPwhqgcZ7bBcrGXHX+0CfHt8LRvWurmAwhiCFoT6ZrAIxlQjgeTNuUk/9k9uN0goOA/F
  37445. vudocP05l03Sx5iRUKrERLMjfTlH6VJi1hKTXrcxlkIF+3anHqP1wvzpesVsqXFP6st4vGCvx970
  37446. 2cu+fjOlbpSD8DT6IavqjnKgP6TeMFvvhk1qlVtDRKgQFRzlAVfFmPHmBiiRqiDFt1MmUUOyCxGV
  37447. WOHAD3bZwI18gfNycJ5v/hqO2V81xrJvNHy+SE/iWjnX2J14np+GPgNeGYtEotXHAgMBAAGjQjBA
  37448. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBS/WSA2AHmgoCJrjNXy
  37449. YdK4LMuCSjANBgkqhkiG9w0BAQsFAAOCAQEAMQOiYQsfdOhyNsZt+U2e+iKo4YFWz827n+qrkRk4
  37450. r6p8FU3ztqONpfSO9kSpp+ghla0+AGIWiPACuvxhI+YzmzB6azZie60EI4RYZeLbK4rnJVM3YlNf
  37451. vNoBYimipidx5joifsFvHZVwIEoHNN/q/xWA5brXethbdXwFeilHfkCoMRN3zUA7tFFHei4R40cR
  37452. 3p1m0IvVVGb6g1XqfMIpiRvpb7PO4gWEyS8+eIVibslfwXhjdFjASBgMmTnrpMwatXlajRWc2BQN
  37453. 9noHV8cigwUtPJslJj0Ys6lDfMjIq2SPDqO/nBudMNva0Bkuqjzx+zOAduTNrRlPBSeOE6Fuwg==
  37454. -----END CERTIFICATE-----
  37455. Atos TrustedRoot 2011
  37456. =====================
  37457. -----BEGIN CERTIFICATE-----
  37458. MIIDdzCCAl+gAwIBAgIIXDPLYixfszIwDQYJKoZIhvcNAQELBQAwPDEeMBwGA1UEAwwVQXRvcyBU
  37459. cnVzdGVkUm9vdCAyMDExMQ0wCwYDVQQKDARBdG9zMQswCQYDVQQGEwJERTAeFw0xMTA3MDcxNDU4
  37460. MzBaFw0zMDEyMzEyMzU5NTlaMDwxHjAcBgNVBAMMFUF0b3MgVHJ1c3RlZFJvb3QgMjAxMTENMAsG
  37461. A1UECgwEQXRvczELMAkGA1UEBhMCREUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCV
  37462. hTuXbyo7LjvPpvMpNb7PGKw+qtn4TaA+Gke5vJrf8v7MPkfoepbCJI419KkM/IL9bcFyYie96mvr
  37463. 54rMVD6QUM+A1JX76LWC1BTFtqlVJVfbsVD2sGBkWXppzwO3bw2+yj5vdHLqqjAqc2K+SZFhyBH+
  37464. DgMq92og3AIVDV4VavzjgsG1xZ1kCWyjWZgHJ8cblithdHFsQ/H3NYkQ4J7sVaE3IqKHBAUsR320
  37465. HLliKWYoyrfhk/WklAOZuXCFteZI6o1Q/NnezG8HDt0Lcp2AMBYHlT8oDv3FdU9T1nSatCQujgKR
  37466. z3bFmx5VdJx4IbHwLfELn8LVlhgf8FQieowHAgMBAAGjfTB7MB0GA1UdDgQWBBSnpQaxLKYJYO7R
  37467. l+lwrrw7GWzbITAPBgNVHRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFKelBrEspglg7tGX6XCuvDsZ
  37468. bNshMBgGA1UdIAQRMA8wDQYLKwYBBAGwLQMEAQEwDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEB
  37469. CwUAA4IBAQAmdzTblEiGKkGdLD4GkGDEjKwLVLgfuXvTBznk+j57sj1O7Z8jvZfza1zv7v1Apt+h
  37470. k6EKhqzvINB5Ab149xnYJDE0BAGmuhWawyfc2E8PzBhj/5kPDpFrdRbhIfzYJsdHt6bPWHJxfrrh
  37471. TZVHO8mvbaG0weyJ9rQPOLXiZNwlz6bb65pcmaHFCN795trV1lpFDMS3wrUU77QR/w4VtfX128a9
  37472. 61qn8FYiqTxlVMYVqL2Gns2Dlmh6cYGJ4Qvh6hEbaAjMaZ7snkGeRDImeuKHCnE96+RapNLbxc3G
  37473. 3mB/ufNPRJLvKrcYPqcZ2Qt9sTdBQrC6YB3y/gkRsPCHe6ed
  37474. -----END CERTIFICATE-----
  37475. QuoVadis Root CA 1 G3
  37476. =====================
  37477. -----BEGIN CERTIFICATE-----
  37478. MIIFYDCCA0igAwIBAgIUeFhfLq0sGUvjNwc1NBMotZbUZZMwDQYJKoZIhvcNAQELBQAwSDELMAkG
  37479. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37480. b3QgQ0EgMSBHMzAeFw0xMjAxMTIxNzI3NDRaFw00MjAxMTIxNzI3NDRaMEgxCzAJBgNVBAYTAkJN
  37481. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDEg
  37482. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCgvlAQjunybEC0BJyFuTHK3C3kEakE
  37483. PBtVwedYMB0ktMPvhd6MLOHBPd+C5k+tR4ds7FtJwUrVu4/sh6x/gpqG7D0DmVIB0jWerNrwU8lm
  37484. PNSsAgHaJNM7qAJGr6Qc4/hzWHa39g6QDbXwz8z6+cZM5cOGMAqNF34168Xfuw6cwI2H44g4hWf6
  37485. Pser4BOcBRiYz5P1sZK0/CPTz9XEJ0ngnjybCKOLXSoh4Pw5qlPafX7PGglTvF0FBM+hSo+LdoIN
  37486. ofjSxxR3W5A2B4GbPgb6Ul5jxaYA/qXpUhtStZI5cgMJYr2wYBZupt0lwgNm3fME0UDiTouG9G/l
  37487. g6AnhF4EwfWQvTA9xO+oabw4m6SkltFi2mnAAZauy8RRNOoMqv8hjlmPSlzkYZqn0ukqeI1RPToV
  37488. 7qJZjqlc3sX5kCLliEVx3ZGZbHqfPT2YfF72vhZooF6uCyP8Wg+qInYtyaEQHeTTRCOQiJ/GKubX
  37489. 9ZqzWB4vMIkIG1SitZgj7Ah3HJVdYdHLiZxfokqRmu8hqkkWCKi9YSgxyXSthfbZxbGL0eUQMk1f
  37490. iyA6PEkfM4VZDdvLCXVDaXP7a3F98N/ETH3Goy7IlXnLc6KOTk0k+17kBL5yG6YnLUlamXrXXAkg
  37491. t3+UuU/xDRxeiEIbEbfnkduebPRq34wGmAOtzCjvpUfzUwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37492. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUo5fW816iEOGrRZ88F2Q87gFwnMwwDQYJKoZI
  37493. hvcNAQELBQADggIBABj6W3X8PnrHX3fHyt/PX8MSxEBd1DKquGrX1RUVRpgjpeaQWxiZTOOtQqOC
  37494. MTaIzen7xASWSIsBx40Bz1szBpZGZnQdT+3Btrm0DWHMY37XLneMlhwqI2hrhVd2cDMT/uFPpiN3
  37495. GPoajOi9ZcnPP/TJF9zrx7zABC4tRi9pZsMbj/7sPtPKlL92CiUNqXsCHKnQO18LwIE6PWThv6ct
  37496. Tr1NxNgpxiIY0MWscgKCP6o6ojoilzHdCGPDdRS5YCgtW2jgFqlmgiNR9etT2DGbe+m3nUvriBbP
  37497. +V04ikkwj+3x6xn0dxoxGE1nVGwvb2X52z3sIexe9PSLymBlVNFxZPT5pqOBMzYzcfCkeF9OrYMh
  37498. 3jRJjehZrJ3ydlo28hP0r+AJx2EqbPfgna67hkooby7utHnNkDPDs3b69fBsnQGQ+p6Q9pxyz0fa
  37499. wx/kNSBT8lTR32GDpgLiJTjehTItXnOQUl1CxM49S+H5GYQd1aJQzEH7QRTDvdbJWqNjZgKAvQU6
  37500. O0ec7AAmTPWIUb+oI38YB7AL7YsmoWTTYUrrXJ/es69nA7Mf3W1daWhpq1467HxpvMc7hU6eFbm0
  37501. FU/DlXpY18ls6Wy58yljXrQs8C097Vpl4KlbQMJImYFtnh8GKjwStIsPm6Ik8KaN1nrgS7ZklmOV
  37502. hMJKzRwuJIczYOXD
  37503. -----END CERTIFICATE-----
  37504. QuoVadis Root CA 2 G3
  37505. =====================
  37506. -----BEGIN CERTIFICATE-----
  37507. MIIFYDCCA0igAwIBAgIURFc0JFuBiZs18s64KztbpybwdSgwDQYJKoZIhvcNAQELBQAwSDELMAkG
  37508. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37509. b3QgQ0EgMiBHMzAeFw0xMjAxMTIxODU5MzJaFw00MjAxMTIxODU5MzJaMEgxCzAJBgNVBAYTAkJN
  37510. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDIg
  37511. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQChriWyARjcV4g/Ruv5r+LrI3HimtFh
  37512. ZiFfqq8nUeVuGxbULX1QsFN3vXg6YOJkApt8hpvWGo6t/x8Vf9WVHhLL5hSEBMHfNrMWn4rjyduY
  37513. NM7YMxcoRvynyfDStNVNCXJJ+fKH46nafaF9a7I6JaltUkSs+L5u+9ymc5GQYaYDFCDy54ejiK2t
  37514. oIz/pgslUiXnFgHVy7g1gQyjO/Dh4fxaXc6AcW34Sas+O7q414AB+6XrW7PFXmAqMaCvN+ggOp+o
  37515. MiwMzAkd056OXbxMmO7FGmh77FOm6RQ1o9/NgJ8MSPsc9PG/Srj61YxxSscfrf5BmrODXfKEVu+l
  37516. V0POKa2Mq1W/xPtbAd0jIaFYAI7D0GoT7RPjEiuA3GfmlbLNHiJuKvhB1PLKFAeNilUSxmn1uIZo
  37517. L1NesNKqIcGY5jDjZ1XHm26sGahVpkUG0CM62+tlXSoREfA7T8pt9DTEceT/AFr2XK4jYIVz8eQQ
  37518. sSWu1ZK7E8EM4DnatDlXtas1qnIhO4M15zHfeiFuuDIIfR0ykRVKYnLP43ehvNURG3YBZwjgQQvD
  37519. 6xVu+KQZ2aKrr+InUlYrAoosFCT5v0ICvybIxo/gbjh9Uy3l7ZizlWNof/k19N+IxWA1ksB8aRxh
  37520. lRbQ694Lrz4EEEVlWFA4r0jyWbYW8jwNkALGcC4BrTwV1wIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37521. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQU7edvdlq/YOxJW8ald7tyFnGbxD0wDQYJKoZI
  37522. hvcNAQELBQADggIBAJHfgD9DCX5xwvfrs4iP4VGyvD11+ShdyLyZm3tdquXK4Qr36LLTn91nMX66
  37523. AarHakE7kNQIXLJgapDwyM4DYvmL7ftuKtwGTTwpD4kWilhMSA/ohGHqPHKmd+RCroijQ1h5fq7K
  37524. pVMNqT1wvSAZYaRsOPxDMuHBR//47PERIjKWnML2W2mWeyAMQ0GaW/ZZGYjeVYg3UQt4XAoeo0L9
  37525. x52ID8DyeAIkVJOviYeIyUqAHerQbj5hLja7NQ4nlv1mNDthcnPxFlxHBlRJAHpYErAK74X9sbgz
  37526. dWqTHBLmYF5vHX/JHyPLhGGfHoJE+V+tYlUkmlKY7VHnoX6XOuYvHxHaU4AshZ6rNRDbIl9qxV6X
  37527. U/IyAgkwo1jwDQHVcsaxfGl7w/U2Rcxhbl5MlMVerugOXou/983g7aEOGzPuVBj+D77vfoRrQ+Nw
  37528. mNtddbINWQeFFSM51vHfqSYP1kjHs6Yi9TM3WpVHn3u6GBVv/9YUZINJ0gpnIdsPNWNgKCLjsZWD
  37529. zYWm3S8P52dSbrsvhXz1SnPnxT7AvSESBT/8twNJAlvIJebiVDj1eYeMHVOyToV7BjjHLPj4sHKN
  37530. JeV3UvQDHEimUF+IIDBu8oJDqz2XhOdT+yHBTw8imoa4WSr2Rz0ZiC3oheGe7IUIarFsNMkd7Egr
  37531. O3jtZsSOeWmD3n+M
  37532. -----END CERTIFICATE-----
  37533. QuoVadis Root CA 3 G3
  37534. =====================
  37535. -----BEGIN CERTIFICATE-----
  37536. MIIFYDCCA0igAwIBAgIULvWbAiin23r/1aOp7r0DoM8Sah0wDQYJKoZIhvcNAQELBQAwSDELMAkG
  37537. A1UEBhMCQk0xGTAXBgNVBAoTEFF1b1ZhZGlzIExpbWl0ZWQxHjAcBgNVBAMTFVF1b1ZhZGlzIFJv
  37538. b3QgQ0EgMyBHMzAeFw0xMjAxMTIyMDI2MzJaFw00MjAxMTIyMDI2MzJaMEgxCzAJBgNVBAYTAkJN
  37539. MRkwFwYDVQQKExBRdW9WYWRpcyBMaW1pdGVkMR4wHAYDVQQDExVRdW9WYWRpcyBSb290IENBIDMg
  37540. RzMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCzyw4QZ47qFJenMioKVjZ/aEzHs286
  37541. IxSR/xl/pcqs7rN2nXrpixurazHb+gtTTK/FpRp5PIpM/6zfJd5O2YIyC0TeytuMrKNuFoM7pmRL
  37542. Mon7FhY4futD4tN0SsJiCnMK3UmzV9KwCoWdcTzeo8vAMvMBOSBDGzXRU7Ox7sWTaYI+FrUoRqHe
  37543. 6okJ7UO4BUaKhvVZR74bbwEhELn9qdIoyhA5CcoTNs+cra1AdHkrAj80//ogaX3T7mH1urPnMNA3
  37544. I4ZyYUUpSFlob3emLoG+B01vr87ERRORFHAGjx+f+IdpsQ7vw4kZ6+ocYfx6bIrc1gMLnia6Et3U
  37545. VDmrJqMz6nWB2i3ND0/kA9HvFZcba5DFApCTZgIhsUfei5pKgLlVj7WiL8DWM2fafsSntARE60f7
  37546. 5li59wzweyuxwHApw0BiLTtIadwjPEjrewl5qW3aqDCYz4ByA4imW0aucnl8CAMhZa634RylsSqi
  37547. Md5mBPfAdOhx3v89WcyWJhKLhZVXGqtrdQtEPREoPHtht+KPZ0/l7DxMYIBpVzgeAVuNVejH38DM
  37548. dyM0SXV89pgR6y3e7UEuFAUCf+D+IOs15xGsIs5XPd7JMG0QA4XN8f+MFrXBsj6IbGB/kE+V9/Yt
  37549. rQE5BwT6dYB9v0lQ7e/JxHwc64B+27bQ3RP+ydOc17KXqQIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  37550. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUxhfQvKjqAkPyGwaZXSuQILnXnOQwDQYJKoZI
  37551. hvcNAQELBQADggIBADRh2Va1EodVTd2jNTFGu6QHcrxfYWLopfsLN7E8trP6KZ1/AvWkyaiTt3px
  37552. KGmPc+FSkNrVvjrlt3ZqVoAh313m6Tqe5T72omnHKgqwGEfcIHB9UqM+WXzBusnIFUBhynLWcKzS
  37553. t/Ac5IYp8M7vaGPQtSCKFWGafoaYtMnCdvvMujAWzKNhxnQT5WvvoxXqA/4Ti2Tk08HS6IT7SdEQ
  37554. TXlm66r99I0xHnAUrdzeZxNMgRVhvLfZkXdxGYFgu/BYpbWcC/ePIlUnwEsBbTuZDdQdm2NnL9Du
  37555. DcpmvJRPpq3t/O5jrFc/ZSXPsoaP0Aj/uHYUbt7lJ+yreLVTubY/6CD50qi+YUbKh4yE8/nxoGib
  37556. Ih6BJpsQBJFxwAYf3KDTuVan45gtf4Od34wrnDKOMpTwATwiKp9Dwi7DmDkHOHv8XgBCH/MyJnmD
  37557. hPbl8MFREsALHgQjDFSlTC9JxUrRtm5gDWv8a4uFJGS3iQ6rJUdbPM9+Sb3H6QrG2vd+DhcI00iX
  37558. 0HGS8A85PjRqHH3Y8iKuu2n0M7SmSFXRDw4m6Oy2Cy2nhTXN/VnIn9HNPlopNLk9hM6xZdRZkZFW
  37559. dSHBd575euFgndOtBBj0fOtek49TSiIp+EgrPk2GrFt/ywaZWWDYWGWVjUTR939+J399roD1B0y2
  37560. PpxxVJkES/1Y+Zj0
  37561. -----END CERTIFICATE-----
  37562. DigiCert Assured ID Root G2
  37563. ===========================
  37564. -----BEGIN CERTIFICATE-----
  37565. MIIDljCCAn6gAwIBAgIQC5McOtY5Z+pnI7/Dr5r0SzANBgkqhkiG9w0BAQsFADBlMQswCQYDVQQG
  37566. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQw
  37567. IgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIwHhcNMTMwODAxMTIwMDAwWhcNMzgw
  37568. MTE1MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQL
  37569. ExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzIw
  37570. ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZ5ygvUj82ckmIkzTz+GoeMVSAn61UQbVH
  37571. 35ao1K+ALbkKz3X9iaV9JPrjIgwrvJUXCzO/GU1BBpAAvQxNEP4HteccbiJVMWWXvdMX0h5i89vq
  37572. bFCMP4QMls+3ywPgym2hFEwbid3tALBSfK+RbLE4E9HpEgjAALAcKxHad3A2m67OeYfcgnDmCXRw
  37573. VWmvo2ifv922ebPynXApVfSr/5Vh88lAbx3RvpO704gqu52/clpWcTs/1PPRCv4o76Pu2ZmvA9OP
  37574. YLfykqGxvYmJHzDNw6YuYjOuFgJ3RFrngQo8p0Quebg/BLxcoIfhG69Rjs3sLPr4/m3wOnyqi+Rn
  37575. lTGNAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTO
  37576. w0q5mVXyuNtgv6l+vVa1lzan1jANBgkqhkiG9w0BAQsFAAOCAQEAyqVVjOPIQW5pJ6d1Ee88hjZv
  37577. 0p3GeDgdaZaikmkuOGybfQTUiaWxMTeKySHMq2zNixya1r9I0jJmwYrA8y8678Dj1JGG0VDjA9tz
  37578. d29KOVPt3ibHtX2vK0LRdWLjSisCx1BL4GnilmwORGYQRI+tBev4eaymG+g3NJ1TyWGqolKvSnAW
  37579. hsI6yLETcDbYz+70CjTVW0z9B5yiutkBclzzTcHdDrEcDcRjvq30FPuJ7KJBDkzMyFdA0G4Dqs0M
  37580. jomZmWzwPDCvON9vvKO+KSAnq3T/EyJ43pdSVR6DtVQgA+6uwE9W3jfMw3+qBCe703e4YtsXfJwo
  37581. IhNzbM8m9Yop5w==
  37582. -----END CERTIFICATE-----
  37583. DigiCert Assured ID Root G3
  37584. ===========================
  37585. -----BEGIN CERTIFICATE-----
  37586. MIICRjCCAc2gAwIBAgIQC6Fa+h3foLVJRK/NJKBs7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  37587. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYD
  37588. VQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  37589. MTIwMDAwWjBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  37590. d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBBc3N1cmVkIElEIFJvb3QgRzMwdjAQ
  37591. BgcqhkjOPQIBBgUrgQQAIgNiAAQZ57ysRGXtzbg/WPuNsVepRC0FFfLvC/8QdJ+1YlJfZn4f5dwb
  37592. RXkLzMZTCp2NXQLZqVneAlr2lSoOjThKiknGvMYDOAdfVdp+CW7if17QRSAPWXYQ1qAk8C3eNvJs
  37593. KTmjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBTL0L2p4ZgF
  37594. UaFNN6KDec6NHSrkhDAKBggqhkjOPQQDAwNnADBkAjAlpIFFAmsSS3V0T8gj43DydXLefInwz5Fy
  37595. YZ5eEJJZVrmDxxDnOOlYJjZ91eQ0hjkCMHw2U/Aw5WJjOpnitqM7mzT6HtoQknFekROn3aRukswy
  37596. 1vUhZscv6pZjamVFkpUBtA==
  37597. -----END CERTIFICATE-----
  37598. DigiCert Global Root G2
  37599. =======================
  37600. -----BEGIN CERTIFICATE-----
  37601. MIIDjjCCAnagAwIBAgIQAzrx5qcRqaC7KGSxHQn65TANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQG
  37602. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAw
  37603. HgYDVQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMjAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUx
  37604. MjAwMDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3
  37605. dy5kaWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEcyMIIBIjANBgkq
  37606. hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuzfNNNx7a8myaJCtSnX/RrohCgiN9RlUyfuI2/Ou8jqJ
  37607. kTx65qsGGmvPrC3oXgkkRLpimn7Wo6h+4FR1IAWsULecYxpsMNzaHxmx1x7e/dfgy5SDN67sH0NO
  37608. 3Xss0r0upS/kqbitOtSZpLYl6ZtrAGCSYP9PIUkY92eQq2EGnI/yuum06ZIya7XzV+hdG82MHauV
  37609. BJVJ8zUtluNJbd134/tJS7SsVQepj5WztCO7TG1F8PapspUwtP1MVYwnSlcUfIKdzXOS0xZKBgyM
  37610. UNGPHgm+F6HmIcr9g+UQvIOlCsRnKPZzFBQ9RnbDhxSJITRNrw9FDKZJobq7nMWxM4MphQIDAQAB
  37611. o0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUTiJUIBiV5uNu
  37612. 5g/6+rkS7QYXjzkwDQYJKoZIhvcNAQELBQADggEBAGBnKJRvDkhj6zHd6mcY1Yl9PMWLSn/pvtsr
  37613. F9+wX3N3KjITOYFnQoQj8kVnNeyIv/iPsGEMNKSuIEyExtv4NeF22d+mQrvHRAiGfzZ0JFrabA0U
  37614. WTW98kndth/Jsw1HKj2ZL7tcu7XUIOGZX1NGFdtom/DzMNU+MeKNhJ7jitralj41E6Vf8PlwUHBH
  37615. QRFXGU7Aj64GxJUTFy8bJZ918rGOmaFvE7FBcf6IKshPECBV1/MUReXgRPTqh5Uykw7+U0b6LJ3/
  37616. iyK5S9kJRaTepLiaWN0bfVKfjllDiIGknibVb63dDcY3fe0Dkhvld1927jyNxF1WW6LZZm6zNTfl
  37617. MrY=
  37618. -----END CERTIFICATE-----
  37619. DigiCert Global Root G3
  37620. =======================
  37621. -----BEGIN CERTIFICATE-----
  37622. MIICPzCCAcWgAwIBAgIQBVVWvPJepDU1w6QP1atFcjAKBggqhkjOPQQDAzBhMQswCQYDVQQGEwJV
  37623. UzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSAwHgYD
  37624. VQQDExdEaWdpQ2VydCBHbG9iYWwgUm9vdCBHMzAeFw0xMzA4MDExMjAwMDBaFw0zODAxMTUxMjAw
  37625. MDBaMGExCzAJBgNVBAYTAlVTMRUwEwYDVQQKEwxEaWdpQ2VydCBJbmMxGTAXBgNVBAsTEHd3dy5k
  37626. aWdpY2VydC5jb20xIDAeBgNVBAMTF0RpZ2lDZXJ0IEdsb2JhbCBSb290IEczMHYwEAYHKoZIzj0C
  37627. AQYFK4EEACIDYgAE3afZu4q4C/sLfyHS8L6+c/MzXRq8NOrexpu80JX28MzQC7phW1FGfp4tn+6O
  37628. YwwX7Adw9c+ELkCDnOg/QW07rdOkFFk2eJ0DQ+4QE2xy3q6Ip6FrtUPOZ9wj/wMco+I+o0IwQDAP
  37629. BgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjAdBgNVHQ4EFgQUs9tIpPmhxdiuNkHMEWNp
  37630. Yim8S8YwCgYIKoZIzj0EAwMDaAAwZQIxAK288mw/EkrRLTnDCgmXc/SINoyIJ7vmiI1Qhadj+Z4y
  37631. 3maTD/HMsQmP3Wyr+mt/oAIwOWZbwmSNuJ5Q3KjVSaLtx9zRSX8XAbjIho9OjIgrqJqpisXRAL34
  37632. VOKa5Vt8sycX
  37633. -----END CERTIFICATE-----
  37634. DigiCert Trusted Root G4
  37635. ========================
  37636. -----BEGIN CERTIFICATE-----
  37637. MIIFkDCCA3igAwIBAgIQBZsbV56OITLiOQe9p3d1XDANBgkqhkiG9w0BAQwFADBiMQswCQYDVQQG
  37638. EwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3d3cuZGlnaWNlcnQuY29tMSEw
  37639. HwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwHhcNMTMwODAxMTIwMDAwWhcNMzgwMTE1
  37640. MTIwMDAwWjBiMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  37641. d3cuZGlnaWNlcnQuY29tMSEwHwYDVQQDExhEaWdpQ2VydCBUcnVzdGVkIFJvb3QgRzQwggIiMA0G
  37642. CSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC/5pBzaN675F1KPDAiMGkz7MKnJS7JIT3yithZwuEp
  37643. pz1Yq3aaza57G4QNxDAf8xukOBbrVsaXbR2rsnnyyhHS5F/WBTxSD1Ifxp4VpX6+n6lXFllVcq9o
  37644. k3DCsrp1mWpzMpTREEQQLt+C8weE5nQ7bXHiLQwb7iDVySAdYyktzuxeTsiT+CFhmzTrBcZe7Fsa
  37645. vOvJz82sNEBfsXpm7nfISKhmV1efVFiODCu3T6cw2Vbuyntd463JT17lNecxy9qTXtyOj4DatpGY
  37646. QJB5w3jHtrHEtWoYOAMQjdjUN6QuBX2I9YI+EJFwq1WCQTLX2wRzKm6RAXwhTNS8rhsDdV14Ztk6
  37647. MUSaM0C/CNdaSaTC5qmgZ92kJ7yhTzm1EVgX9yRcRo9k98FpiHaYdj1ZXUJ2h4mXaXpI8OCiEhtm
  37648. mnTK3kse5w5jrubU75KSOp493ADkRSWJtppEGSt+wJS00mFt6zPZxd9LBADMfRyVw4/3IbKyEbe7
  37649. f/LVjHAsQWCqsWMYRJUadmJ+9oCw++hkpjPRiQfhvbfmQ6QYuKZ3AeEPlAwhHbJUKSWJbOUOUlFH
  37650. dL4mrLZBdd56rF+NP8m800ERElvlEFDrMcXKchYiCd98THU/Y+whX8QgUWtvsauGi0/C1kVfnSD8
  37651. oR7FwI+isX4KJpn15GkvmB0t9dmpsh3lGwIDAQABo0IwQDAPBgNVHRMBAf8EBTADAQH/MA4GA1Ud
  37652. DwEB/wQEAwIBhjAdBgNVHQ4EFgQU7NfjgtJxXWRM3y5nP+e6mK4cD08wDQYJKoZIhvcNAQEMBQAD
  37653. ggIBALth2X2pbL4XxJEbw6GiAI3jZGgPVs93rnD5/ZpKmbnJeFwMDF/k5hQpVgs2SV1EY+CtnJYY
  37654. ZhsjDT156W1r1lT40jzBQ0CuHVD1UvyQO7uYmWlrx8GnqGikJ9yd+SeuMIW59mdNOj6PWTkiU0Tr
  37655. yF0Dyu1Qen1iIQqAyHNm0aAFYF/opbSnr6j3bTWcfFqK1qI4mfN4i/RN0iAL3gTujJtHgXINwBQy
  37656. 7zBZLq7gcfJW5GqXb5JQbZaNaHqasjYUegbyJLkJEVDXCLG4iXqEI2FCKeWjzaIgQdfRnGTZ6iah
  37657. ixTXTBmyUEFxPT9NcCOGDErcgdLMMpSEDQgJlxxPwO5rIHQw0uA5NBCFIRUBCOhVMt5xSdkoF1BN
  37658. 5r5N0XWs0Mr7QbhDparTwwVETyw2m+L64kW4I1NsBm9nVX9GtUw/bihaeSbSpKhil9Ie4u1Ki7wb
  37659. /UdKDd9nZn6yW0HQO+T0O/QEY+nvwlQAUaCKKsnOeMzV6ocEGLPOr0mIr/OSmbaz5mEP0oUA51Aa
  37660. 5BuVnRmhuZyxm7EAHu/QD09CbMkKvO5D+jpxpchNJqU1/YldvIViHTLSoCtU7ZpXwdv6EM8Zt4tK
  37661. G48BtieVU+i2iW1bvGjUI+iLUaJW+fCmgKDWHrO8Dw9TdSmq6hN35N6MgSGtBxBHEa2HPQfRdbzP
  37662. 82Z+
  37663. -----END CERTIFICATE-----
  37664. COMODO RSA Certification Authority
  37665. ==================================
  37666. -----BEGIN CERTIFICATE-----
  37667. MIIF2DCCA8CgAwIBAgIQTKr5yttjb+Af907YWwOGnTANBgkqhkiG9w0BAQwFADCBhTELMAkGA1UE
  37668. BhMCR0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgG
  37669. A1UEChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlv
  37670. biBBdXRob3JpdHkwHhcNMTAwMTE5MDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBhTELMAkGA1UEBhMC
  37671. R0IxGzAZBgNVBAgTEkdyZWF0ZXIgTWFuY2hlc3RlcjEQMA4GA1UEBxMHU2FsZm9yZDEaMBgGA1UE
  37672. ChMRQ09NT0RPIENBIExpbWl0ZWQxKzApBgNVBAMTIkNPTU9ETyBSU0EgQ2VydGlmaWNhdGlvbiBB
  37673. dXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCR6FSS0gpWsawNJN3Fz0Rn
  37674. dJkrN6N9I3AAcbxT38T6KhKPS38QVr2fcHK3YX/JSw8Xpz3jsARh7v8Rl8f0hj4K+j5c+ZPmNHrZ
  37675. FGvnnLOFoIJ6dq9xkNfs/Q36nGz637CC9BR++b7Epi9Pf5l/tfxnQ3K9DADWietrLNPtj5gcFKt+
  37676. 5eNu/Nio5JIk2kNrYrhV/erBvGy2i/MOjZrkm2xpmfh4SDBF1a3hDTxFYPwyllEnvGfDyi62a+pG
  37677. x8cgoLEfZd5ICLqkTqnyg0Y3hOvozIFIQ2dOciqbXL1MGyiKXCJ7tKuY2e7gUYPDCUZObT6Z+pUX
  37678. 2nwzV0E8jVHtC7ZcryxjGt9XyD+86V3Em69FmeKjWiS0uqlWPc9vqv9JWL7wqP/0uK3pN/u6uPQL
  37679. OvnoQ0IeidiEyxPx2bvhiWC4jChWrBQdnArncevPDt09qZahSL0896+1DSJMwBGB7FY79tOi4lu3
  37680. sgQiUpWAk2nojkxl8ZEDLXB0AuqLZxUpaVICu9ffUGpVRr+goyhhf3DQw6KqLCGqR84onAZFdr+C
  37681. GCe01a60y1Dma/RMhnEw6abfFobg2P9A3fvQQoh/ozM6LlweQRGBY84YcWsr7KaKtzFcOmpH4MN5
  37682. WdYgGq/yapiqcrxXStJLnbsQ/LBMQeXtHT1eKJ2czL+zUdqnR+WEUwIDAQABo0IwQDAdBgNVHQ4E
  37683. FgQUu69+Aj36pvE8hI6t7jiY7NkyMtQwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8w
  37684. DQYJKoZIhvcNAQEMBQADggIBAArx1UaEt65Ru2yyTUEUAJNMnMvlwFTPoCWOAvn9sKIN9SCYPBMt
  37685. rFaisNZ+EZLpLrqeLppysb0ZRGxhNaKatBYSaVqM4dc+pBroLwP0rmEdEBsqpIt6xf4FpuHA1sj+
  37686. nq6PK7o9mfjYcwlYRm6mnPTXJ9OV2jeDchzTc+CiR5kDOF3VSXkAKRzH7JsgHAckaVd4sjn8OoSg
  37687. tZx8jb8uk2IntznaFxiuvTwJaP+EmzzV1gsD41eeFPfR60/IvYcjt7ZJQ3mFXLrrkguhxuhoqEwW
  37688. sRqZCuhTLJK7oQkYdQxlqHvLI7cawiiFwxv/0Cti76R7CZGYZ4wUAc1oBmpjIXUDgIiKboHGhfKp
  37689. pC3n9KUkEEeDys30jXlYsQab5xoq2Z0B15R97QNKyvDb6KkBPvVWmckejkk9u+UJueBPSZI9FoJA
  37690. zMxZxuY67RIuaTxslbH9qh17f4a+Hg4yRvv7E491f0yLS0Zj/gA0QHDBw7mh3aZw4gSzQbzpgJHq
  37691. ZJx64SIDqZxubw5lT2yHh17zbqD5daWbQOhTsiedSrnAdyGN/4fy3ryM7xfft0kL0fJuMAsaDk52
  37692. 7RH89elWsn2/x20Kk4yl0MC2Hb46TpSi125sC8KKfPog88Tk5c0NqMuRkrF8hey1FGlmDoLnzc7I
  37693. LaZRfyHBNVOFBkpdn627G190
  37694. -----END CERTIFICATE-----
  37695. USERTrust RSA Certification Authority
  37696. =====================================
  37697. -----BEGIN CERTIFICATE-----
  37698. MIIF3jCCA8agAwIBAgIQAf1tMPyjylGoG7xkDjUDLTANBgkqhkiG9w0BAQwFADCBiDELMAkGA1UE
  37699. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  37700. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  37701. dGlvbiBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UE
  37702. BhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQK
  37703. ExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNh
  37704. dGlvbiBBdXRob3JpdHkwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCAEmUXNg7D2wiz
  37705. 0KxXDXbtzSfTTK1Qg2HiqiBNCS1kCdzOiZ/MPans9s/B3PHTsdZ7NygRK0faOca8Ohm0X6a9fZ2j
  37706. Y0K2dvKpOyuR+OJv0OwWIJAJPuLodMkYtJHUYmTbf6MG8YgYapAiPLz+E/CHFHv25B+O1ORRxhFn
  37707. RghRy4YUVD+8M/5+bJz/Fp0YvVGONaanZshyZ9shZrHUm3gDwFA66Mzw3LyeTP6vBZY1H1dat//O
  37708. +T23LLb2VN3I5xI6Ta5MirdcmrS3ID3KfyI0rn47aGYBROcBTkZTmzNg95S+UzeQc0PzMsNT79uq
  37709. /nROacdrjGCT3sTHDN/hMq7MkztReJVni+49Vv4M0GkPGw/zJSZrM233bkf6c0Plfg6lZrEpfDKE
  37710. Y1WJxA3Bk1QwGROs0303p+tdOmw1XNtB1xLaqUkL39iAigmTYo61Zs8liM2EuLE/pDkP2QKe6xJM
  37711. lXzzawWpXhaDzLhn4ugTncxbgtNMs+1b/97lc6wjOy0AvzVVdAlJ2ElYGn+SNuZRkg7zJn0cTRe8
  37712. yexDJtC/QV9AqURE9JnnV4eeUB9XVKg+/XRjL7FQZQnmWEIuQxpMtPAlR1n6BB6T1CZGSlCBst6+
  37713. eLf8ZxXhyVeEHg9j1uliutZfVS7qXMYoCAQlObgOK6nyTJccBz8NUvXt7y+CDwIDAQABo0IwQDAd
  37714. BgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rIDZsswDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQF
  37715. MAMBAf8wDQYJKoZIhvcNAQEMBQADggIBAFzUfA3P9wF9QZllDHPFUp/L+M+ZBn8b2kMVn54CVVeW
  37716. FPFSPCeHlCjtHzoBN6J2/FNQwISbxmtOuowhT6KOVWKR82kV2LyI48SqC/3vqOlLVSoGIG1VeCkZ
  37717. 7l8wXEskEVX/JJpuXior7gtNn3/3ATiUFJVDBwn7YKnuHKsSjKCaXqeYalltiz8I+8jRRa8YFWSQ
  37718. Eg9zKC7F4iRO/Fjs8PRF/iKz6y+O0tlFYQXBl2+odnKPi4w2r78NBc5xjeambx9spnFixdjQg3IM
  37719. 8WcRiQycE0xyNN+81XHfqnHd4blsjDwSXWXavVcStkNr/+XeTWYRUc+ZruwXtuhxkYzeSf7dNXGi
  37720. FSeUHM9h4ya7b6NnJSFd5t0dCy5oGzuCr+yDZ4XUmFF0sbmZgIn/f3gZXHlKYC6SQK5MNyosycdi
  37721. yA5d9zZbyuAlJQG03RoHnHcAP9Dc1ew91Pq7P8yF1m9/qS3fuQL39ZeatTXaw2ewh0qpKJ4jjv9c
  37722. J2vhsE/zB+4ALtRZh8tSQZXq9EfX7mRBVXyNWQKV3WKdwrnuWih0hKWbt5DHDAff9Yk2dDLWKMGw
  37723. sAvgnEzDHNb842m1R0aBL6KCq9NjRHDEjf8tM7qtj3u1cIiuPhnPQCjY/MiQu12ZIvVS5ljFH4gx
  37724. Q+6IHdfGjjxDah2nGN59PRbxYvnKkKj9
  37725. -----END CERTIFICATE-----
  37726. USERTrust ECC Certification Authority
  37727. =====================================
  37728. -----BEGIN CERTIFICATE-----
  37729. MIICjzCCAhWgAwIBAgIQXIuZxVqUxdJxVt7NiYDMJjAKBggqhkjOPQQDAzCBiDELMAkGA1UEBhMC
  37730. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  37731. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  37732. biBBdXRob3JpdHkwHhcNMTAwMjAxMDAwMDAwWhcNMzgwMTE4MjM1OTU5WjCBiDELMAkGA1UEBhMC
  37733. VVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0plcnNleSBDaXR5MR4wHAYDVQQKExVU
  37734. aGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNVBAMTJVVTRVJUcnVzdCBFQ0MgQ2VydGlmaWNhdGlv
  37735. biBBdXRob3JpdHkwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQarFRaqfloI+d61SRvU8Za2EurxtW2
  37736. 0eZzca7dnNYMYf3boIkDuAUU7FfO7l0/4iGzzvfUinngo4N+LZfQYcTxmdwlkWOrfzCjtHDix6Ez
  37737. nPO/LlxTsV+zfTJ/ijTjeXmjQjBAMB0GA1UdDgQWBBQ64QmG1M8ZwpZ2dEl23OA1xmNjmjAOBgNV
  37738. HQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNoADBlAjA2Z6EWCNzklwBB
  37739. HU6+4WMBzzuqQhFkoJ2UOQIReVx7Hfpkue4WQrO/isIJxOzksU0CMQDpKmFHjFJKS04YcPbWRNZu
  37740. 9YO6bVi9JNlWSOrvxKJGgYhqOkbRqZtNyWHa0V1Xahg=
  37741. -----END CERTIFICATE-----
  37742. GlobalSign ECC Root CA - R4
  37743. ===========================
  37744. -----BEGIN CERTIFICATE-----
  37745. MIIB4TCCAYegAwIBAgIRKjikHJYKBN5CsiilC+g0mAIwCgYIKoZIzj0EAwIwUDEkMCIGA1UECxMb
  37746. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37747. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  37748. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI0MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37749. EwpHbG9iYWxTaWduMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEuMZ5049sJQ6fLjkZHAOkrprl
  37750. OQcJFspjsbmG+IpXwVfOQvpzofdlQv8ewQCybnMO/8ch5RikqtlxP6jUuc6MHaNCMEAwDgYDVR0P
  37751. AQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFFSwe61FuOJAf/sKbvu+M8k8o4TV
  37752. MAoGCCqGSM49BAMCA0gAMEUCIQDckqGgE6bPA7DmxCGXkPoUVy0D7O48027KqGx2vKLeuwIgJ6iF
  37753. JzWbVsaj8kfSt24bAgAXqmemFZHe+pTsewv4n4Q=
  37754. -----END CERTIFICATE-----
  37755. GlobalSign ECC Root CA - R5
  37756. ===========================
  37757. -----BEGIN CERTIFICATE-----
  37758. MIICHjCCAaSgAwIBAgIRYFlJ4CYuu1X5CneKcflK2GwwCgYIKoZIzj0EAwMwUDEkMCIGA1UECxMb
  37759. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37760. EwpHbG9iYWxTaWduMB4XDTEyMTExMzAwMDAwMFoXDTM4MDExOTAzMTQwN1owUDEkMCIGA1UECxMb
  37761. R2xvYmFsU2lnbiBFQ0MgUm9vdCBDQSAtIFI1MRMwEQYDVQQKEwpHbG9iYWxTaWduMRMwEQYDVQQD
  37762. EwpHbG9iYWxTaWduMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAER0UOlvt9Xb/pOdEh+J8LttV7HpI6
  37763. SFkc8GIxLcB6KP4ap1yztsyX50XUWPrRd21DosCHZTQKH3rd6zwzocWdTaRvQZU4f8kehOvRnkmS
  37764. h5SHDDqFSmafnVmTTZdhBoZKo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  37765. BgNVHQ4EFgQUPeYpSJvqB8ohREom3m7e0oPQn1kwCgYIKoZIzj0EAwMDaAAwZQIxAOVpEslu28Yx
  37766. uglB4Zf4+/2a4n0Sye18ZNPLBSWLVtmg515dTguDnFt2KaAJJiFqYgIwcdK1j1zqO+F4CYWodZI7
  37767. yFz9SO8NdCKoCOJuxUnOxwy8p2Fp8fc74SrL+SvzZpA3
  37768. -----END CERTIFICATE-----
  37769. Staat der Nederlanden Root CA - G3
  37770. ==================================
  37771. -----BEGIN CERTIFICATE-----
  37772. MIIFdDCCA1ygAwIBAgIEAJiiOTANBgkqhkiG9w0BAQsFADBaMQswCQYDVQQGEwJOTDEeMBwGA1UE
  37773. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSswKQYDVQQDDCJTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  37774. Um9vdCBDQSAtIEczMB4XDTEzMTExNDExMjg0MloXDTI4MTExMzIzMDAwMFowWjELMAkGA1UEBhMC
  37775. TkwxHjAcBgNVBAoMFVN0YWF0IGRlciBOZWRlcmxhbmRlbjErMCkGA1UEAwwiU3RhYXQgZGVyIE5l
  37776. ZGVybGFuZGVuIFJvb3QgQ0EgLSBHMzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAL4y
  37777. olQPcPssXFnrbMSkUeiFKrPMSjTysF/zDsccPVMeiAho2G89rcKezIJnByeHaHE6n3WWIkYFsO2t
  37778. x1ueKt6c/DrGlaf1F2cY5y9JCAxcz+bMNO14+1Cx3Gsy8KL+tjzk7FqXxz8ecAgwoNzFs21v0IJy
  37779. EavSgWhZghe3eJJg+szeP4TrjTgzkApyI/o1zCZxMdFyKJLZWyNtZrVtB0LrpjPOktvA9mxjeM3K
  37780. Tj215VKb8b475lRgsGYeCasH/lSJEULR9yS6YHgamPfJEf0WwTUaVHXvQ9Plrk7O53vDxk5hUUur
  37781. mkVLoR9BvUhTFXFkC4az5S6+zqQbwSmEorXLCCN2QyIkHxcE1G6cxvx/K2Ya7Irl1s9N9WMJtxU5
  37782. 1nus6+N86U78dULI7ViVDAZCopz35HCz33JvWjdAidiFpNfxC95DGdRKWCyMijmev4SH8RY7Ngzp
  37783. 07TKbBlBUgmhHbBqv4LvcFEhMtwFdozL92TkA1CvjJFnq8Xy7ljY3r735zHPbMk7ccHViLVlvMDo
  37784. FxcHErVc0qsgk7TmgoNwNsXNo42ti+yjwUOH5kPiNL6VizXtBznaqB16nzaeErAMZRKQFWDZJkBE
  37785. 41ZgpRDUajz9QdwOWke275dhdU/Z/seyHdTtXUmzqWrLZoQT1Vyg3N9udwbRcXXIV2+vD3dbAgMB
  37786. AAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBRUrfrHkleu
  37787. yjWcLhL75LpdINyUVzANBgkqhkiG9w0BAQsFAAOCAgEAMJmdBTLIXg47mAE6iqTnB/d6+Oea31BD
  37788. U5cqPco8R5gu4RV78ZLzYdqQJRZlwJ9UXQ4DO1t3ApyEtg2YXzTdO2PCwyiBwpwpLiniyMMB8jPq
  37789. KqrMCQj3ZWfGzd/TtiunvczRDnBfuCPRy5FOCvTIeuXZYzbB1N/8Ipf3YF3qKS9Ysr1YvY2WTxB1
  37790. v0h7PVGHoTx0IsL8B3+A3MSs/mrBcDCw6Y5p4ixpgZQJut3+TcCDjJRYwEYgr5wfAvg1VUkvRtTA
  37791. 8KCWAg8zxXHzniN9lLf9OtMJgwYh/WA9rjLA0u6NpvDntIJ8CsxwyXmA+P5M9zWEGYox+wrZ13+b
  37792. 8KKaa8MFSu1BYBQw0aoRQm7TIwIEC8Zl3d1Sd9qBa7Ko+gE4uZbqKmxnl4mUnrzhVNXkanjvSr0r
  37793. mj1AfsbAddJu+2gw7OyLnflJNZoaLNmzlTnVHpL3prllL+U9bTpITAjc5CgSKL59NVzq4BZ+Extq
  37794. 1z7XnvwtdbLBFNUjA9tbbws+eC8N3jONFrdI54OagQ97wUNNVQQXOEpR1VmiiXTTn74eS9fGbbeI
  37795. JG9gkaSChVtWQbzQRKtqE77RLFi3EjNYsjdj3BP1lB0/QFH1T/U67cjF68IeHRaVesd+QnGTbksV
  37796. tzDfqu1XhUisHWrdOWnk4Xl4vs4Fv6EM94B7IWcnMFk=
  37797. -----END CERTIFICATE-----
  37798. Staat der Nederlanden EV Root CA
  37799. ================================
  37800. -----BEGIN CERTIFICATE-----
  37801. MIIFcDCCA1igAwIBAgIEAJiWjTANBgkqhkiG9w0BAQsFADBYMQswCQYDVQQGEwJOTDEeMBwGA1UE
  37802. CgwVU3RhYXQgZGVyIE5lZGVybGFuZGVuMSkwJwYDVQQDDCBTdGFhdCBkZXIgTmVkZXJsYW5kZW4g
  37803. RVYgUm9vdCBDQTAeFw0xMDEyMDgxMTE5MjlaFw0yMjEyMDgxMTEwMjhaMFgxCzAJBgNVBAYTAk5M
  37804. MR4wHAYDVQQKDBVTdGFhdCBkZXIgTmVkZXJsYW5kZW4xKTAnBgNVBAMMIFN0YWF0IGRlciBOZWRl
  37805. cmxhbmRlbiBFViBSb290IENBMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA48d+ifkk
  37806. SzrSM4M1LGns3Amk41GoJSt5uAg94JG6hIXGhaTK5skuU6TJJB79VWZxXSzFYGgEt9nCUiY4iKTW
  37807. O0Cmws0/zZiTs1QUWJZV1VD+hq2kY39ch/aO5ieSZxeSAgMs3NZmdO3dZ//BYY1jTw+bbRcwJu+r
  37808. 0h8QoPnFfxZpgQNH7R5ojXKhTbImxrpsX23Wr9GxE46prfNeaXUmGD5BKyF/7otdBwadQ8QpCiv8
  37809. Kj6GyzyDOvnJDdrFmeK8eEEzduG/L13lpJhQDBXd4Pqcfzho0LKmeqfRMb1+ilgnQ7O6M5HTp5gV
  37810. XJrm0w912fxBmJc+qiXbj5IusHsMX/FjqTf5m3VpTCgmJdrV8hJwRVXj33NeN/UhbJCONVrJ0yPr
  37811. 08C+eKxCKFhmpUZtcALXEPlLVPxdhkqHz3/KRawRWrUgUY0viEeXOcDPusBCAUCZSCELa6fS/ZbV
  37812. 0b5GnUngC6agIk440ME8MLxwjyx1zNDFjFE7PZQIZCZhfbnDZY8UnCHQqv0XcgOPvZuM5l5Tnrmd
  37813. 74K74bzickFbIZTTRTeU0d8JOV3nI6qaHcptqAqGhYqCvkIH1vI4gnPah1vlPNOePqc7nvQDs/nx
  37814. fRN0Av+7oeX6AHkcpmZBiFxgV6YuCcS6/ZrPpx9Aw7vMWgpVSzs4dlG4Y4uElBbmVvMCAwEAAaNC
  37815. MEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFP6rAJCYniT8qcwa
  37816. ivsnuL8wbqg7MA0GCSqGSIb3DQEBCwUAA4ICAQDPdyxuVr5Os7aEAJSrR8kN0nbHhp8dB9O2tLsI
  37817. eK9p0gtJ3jPFrK3CiAJ9Brc1AsFgyb/E6JTe1NOpEyVa/m6irn0F3H3zbPB+po3u2dfOWBfoqSmu
  37818. c0iH55vKbimhZF8ZE/euBhD/UcabTVUlT5OZEAFTdfETzsemQUHSv4ilf0X8rLiltTMMgsT7B/Zq
  37819. 5SWEXwbKwYY5EdtYzXc7LMJMD16a4/CrPmEbUCTCwPTxGfARKbalGAKb12NMcIxHowNDXLldRqAN
  37820. b/9Zjr7dn3LDWyvfjFvO5QxGbJKyCqNMVEIYFRIYvdr8unRu/8G2oGTYqV9Vrp9canaW2HNnh/tN
  37821. f1zuacpzEPuKqf2evTY4SUmH9A4U8OmHuD+nT3pajnnUk+S7aFKErGzp85hwVXIy+TSrK0m1zSBi
  37822. 5Dp6Z2Orltxtrpfs/J92VoguZs9btsmksNcFuuEnL5O7Jiqik7Ab846+HUCjuTaPPoIaGl6I6lD4
  37823. WeKDRikL40Rc4ZW2aZCaFG+XroHPaO+Zmr615+F/+PoTRxZMzG0IQOeLeG9QgkRQP2YGiqtDhFZK
  37824. DyAthg710tvSeopLzaXoTvFeJiUBWSOgftL2fiFX1ye8FVdMpEbB4IMeDExNH08GGeL5qPQ6gqGy
  37825. eUN51q1veieQA6TqJIc/2b3Z6fJfUEkc7uzXLg==
  37826. -----END CERTIFICATE-----
  37827. IdenTrust Commercial Root CA 1
  37828. ==============================
  37829. -----BEGIN CERTIFICATE-----
  37830. MIIFYDCCA0igAwIBAgIQCgFCgAAAAUUjyES1AAAAAjANBgkqhkiG9w0BAQsFADBKMQswCQYDVQQG
  37831. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBS
  37832. b290IENBIDEwHhcNMTQwMTE2MTgxMjIzWhcNMzQwMTE2MTgxMjIzWjBKMQswCQYDVQQGEwJVUzES
  37833. MBAGA1UEChMJSWRlblRydXN0MScwJQYDVQQDEx5JZGVuVHJ1c3QgQ29tbWVyY2lhbCBSb290IENB
  37834. IDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnUBneP5k91DNG8W9RYYKyqU+PZ4ld
  37835. hNlT3Qwo2dfw/66VQ3KZ+bVdfIrBQuExUHTRgQ18zZshq0PirK1ehm7zCYofWjK9ouuU+ehcCuz/
  37836. mNKvcbO0U59Oh++SvL3sTzIwiEsXXlfEU8L2ApeN2WIrvyQfYo3fw7gpS0l4PJNgiCL8mdo2yMKi
  37837. 1CxUAGc1bnO/AljwpN3lsKImesrgNqUZFvX9t++uP0D1bVoE/c40yiTcdCMbXTMTEl3EASX2MN0C
  37838. XZ/g1Ue9tOsbobtJSdifWwLziuQkkORiT0/Br4sOdBeo0XKIanoBScy0RnnGF7HamB4HWfp1IYVl
  37839. 3ZBWzvurpWCdxJ35UrCLvYf5jysjCiN2O/cz4ckA82n5S6LgTrx+kzmEB/dEcH7+B1rlsazRGMzy
  37840. NeVJSQjKVsk9+w8YfYs7wRPCTY/JTw436R+hDmrfYi7LNQZReSzIJTj0+kuniVyc0uMNOYZKdHzV
  37841. WYfCP04MXFL0PfdSgvHqo6z9STQaKPNBiDoT7uje/5kdX7rL6B7yuVBgwDHTc+XvvqDtMwt0viAg
  37842. xGds8AgDelWAf0ZOlqf0Hj7h9tgJ4TNkK2PXMl6f+cB7D3hvl7yTmvmcEpB4eoCHFddydJxVdHix
  37843. uuFucAS6T6C6aMN7/zHwcz09lCqxC0EOoP5NiGVreTO01wIDAQABo0IwQDAOBgNVHQ8BAf8EBAMC
  37844. AQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU7UQZwNPwBovupHu+QucmVMiONnYwDQYJKoZI
  37845. hvcNAQELBQADggIBAA2ukDL2pkt8RHYZYR4nKM1eVO8lvOMIkPkp165oCOGUAFjvLi5+U1KMtlwH
  37846. 6oi6mYtQlNeCgN9hCQCTrQ0U5s7B8jeUeLBfnLOic7iPBZM4zY0+sLj7wM+x8uwtLRvM7Kqas6pg
  37847. ghstO8OEPVeKlh6cdbjTMM1gCIOQ045U8U1mwF10A0Cj7oV+wh93nAbowacYXVKV7cndJZ5t+qnt
  37848. ozo00Fl72u1Q8zW/7esUTTHHYPTa8Yec4kjixsU3+wYQ+nVZZjFHKdp2mhzpgq7vmrlR94gjmmmV
  37849. YjzlVYA211QC//G5Xc7UI2/YRYRKW2XviQzdFKcgyxilJbQN+QHwotL0AMh0jqEqSI5l2xPE4iUX
  37850. feu+h1sXIFRRk0pTAwvsXcoz7WL9RccvW9xYoIA55vrX/hMUpu09lEpCdNTDd1lzzY9GvlU47/ro
  37851. kTLql1gEIt44w8y8bckzOmoKaT+gyOpyj4xjhiO9bTyWnpXgSUyqorkqG5w2gXjtw+hG4iZZRHUe
  37852. 2XWJUc0QhJ1hYMtd+ZciTY6Y5uN/9lu7rs3KSoFrXgvzUeF0K+l+J6fZmUlO+KWA2yUPHGNiiskz
  37853. Z2s8EIPGrd6ozRaOjfAHN3Gf8qv8QfXBi+wAN10J5U6A7/qxXDgGpRtK4dw4LTzcqx+QGtVKnO7R
  37854. cGzM7vRX+Bi6hG6H
  37855. -----END CERTIFICATE-----
  37856. IdenTrust Public Sector Root CA 1
  37857. =================================
  37858. -----BEGIN CERTIFICATE-----
  37859. MIIFZjCCA06gAwIBAgIQCgFCgAAAAUUjz0Z8AAAAAjANBgkqhkiG9w0BAQsFADBNMQswCQYDVQQG
  37860. EwJVUzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3Rv
  37861. ciBSb290IENBIDEwHhcNMTQwMTE2MTc1MzMyWhcNMzQwMTE2MTc1MzMyWjBNMQswCQYDVQQGEwJV
  37862. UzESMBAGA1UEChMJSWRlblRydXN0MSowKAYDVQQDEyFJZGVuVHJ1c3QgUHVibGljIFNlY3RvciBS
  37863. b290IENBIDEwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2IpT8pEiv6EdrCvsnduTy
  37864. P4o7ekosMSqMjbCpwzFrqHd2hCa2rIFCDQjrVVi7evi8ZX3yoG2LqEfpYnYeEe4IFNGyRBb06tD6
  37865. Hi9e28tzQa68ALBKK0CyrOE7S8ItneShm+waOh7wCLPQ5CQ1B5+ctMlSbdsHyo+1W/CD80/HLaXI
  37866. rcuVIKQxKFdYWuSNG5qrng0M8gozOSI5Cpcu81N3uURF/YTLNiCBWS2ab21ISGHKTN9T0a9SvESf
  37867. qy9rg3LvdYDaBjMbXcjaY8ZNzaxmMc3R3j6HEDbhuaR672BQssvKplbgN6+rNBM5Jeg5ZuSYeqoS
  37868. mJxZZoY+rfGwyj4GD3vwEUs3oERte8uojHH01bWRNszwFcYr3lEXsZdMUD2xlVl8BX0tIdUAvwFn
  37869. ol57plzy9yLxkA2T26pEUWbMfXYD62qoKjgZl3YNa4ph+bz27nb9cCvdKTz4Ch5bQhyLVi9VGxyh
  37870. LrXHFub4qjySjmm2AcG1hp2JDws4lFTo6tyePSW8Uybt1as5qsVATFSrsrTZ2fjXctscvG29ZV/v
  37871. iDUqZi/u9rNl8DONfJhBaUYPQxxp+pu10GFqzcpL2UyQRqsVWaFHVCkugyhfHMKiq3IXAAaOReyL
  37872. 4jM9f9oZRORicsPfIsbyVtTdX5Vy7W1f90gDW/3FKqD2cyOEEBsB5wIDAQABo0IwQDAOBgNVHQ8B
  37873. Af8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU43HgntinQtnbcZFrlJPrw6PRFKMw
  37874. DQYJKoZIhvcNAQELBQADggIBAEf63QqwEZE4rU1d9+UOl1QZgkiHVIyqZJnYWv6IAcVYpZmxI1Qj
  37875. t2odIFflAWJBF9MJ23XLblSQdf4an4EKwt3X9wnQW3IV5B4Jaj0z8yGa5hV+rVHVDRDtfULAj+7A
  37876. mgjVQdZcDiFpboBhDhXAuM/FSRJSzL46zNQuOAXeNf0fb7iAaJg9TaDKQGXSc3z1i9kKlT/YPyNt
  37877. GtEqJBnZhbMX73huqVjRI9PHE+1yJX9dsXNw0H8GlwmEKYBhHfpe/3OsoOOJuBxxFcbeMX8S3OFt
  37878. m6/n6J91eEyrRjuazr8FGF1NFTwWmhlQBJqymm9li1JfPFgEKCXAZmExfrngdbkaqIHWchezxQMx
  37879. NRF4eKLg6TCMf4DfWN88uieW4oA0beOY02QnrEh+KHdcxiVhJfiFDGX6xDIvpZgF5PgLZxYWxoK4
  37880. Mhn5+bl53B/N66+rDt0b20XkeucC4pVd/GnwU2lhlXV5C15V5jgclKlZM57IcXR5f1GJtshquDDI
  37881. ajjDbp7hNxbqBWJMWxJH7ae0s1hWx0nzfxJoCTFx8G34Tkf71oXuxVhAGaQdp/lLQzfcaFpPz+vC
  37882. ZHTetBXZ9FRUGi8c15dxVJCO2SCdUyt/q4/i6jC8UDfv8Ue1fXwsBOxonbRJRBD0ckscZOf85muQ
  37883. 3Wl9af0AVqW3rLatt8o+Ae+c
  37884. -----END CERTIFICATE-----
  37885. Entrust Root Certification Authority - G2
  37886. =========================================
  37887. -----BEGIN CERTIFICATE-----
  37888. MIIEPjCCAyagAwIBAgIESlOMKDANBgkqhkiG9w0BAQsFADCBvjELMAkGA1UEBhMCVVMxFjAUBgNV
  37889. BAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVy
  37890. bXMxOTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ug
  37891. b25seTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIw
  37892. HhcNMDkwNzA3MTcyNTU0WhcNMzAxMjA3MTc1NTU0WjCBvjELMAkGA1UEBhMCVVMxFjAUBgNVBAoT
  37893. DUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVnYWwtdGVybXMx
  37894. OTA3BgNVBAsTMChjKSAyMDA5IEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXplZCB1c2Ugb25s
  37895. eTEyMDAGA1UEAxMpRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IC0gRzIwggEi
  37896. MA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC6hLZy254Ma+KZ6TABp3bqMriVQRrJ2mFOWHLP
  37897. /vaCeb9zYQYKpSfYs1/TRU4cctZOMvJyig/3gxnQaoCAAEUesMfnmr8SVycco2gvCoe9amsOXmXz
  37898. HHfV1IWNcCG0szLni6LVhjkCsbjSR87kyUnEO6fe+1R9V77w6G7CebI6C1XiUJgWMhNcL3hWwcKU
  37899. s/Ja5CeanyTXxuzQmyWC48zCxEXFjJd6BmsqEZ+pCm5IO2/b1BEZQvePB7/1U1+cPvQXLOZprE4y
  37900. TGJ36rfo5bs0vBmLrpxR57d+tVOxMyLlbc9wPBr64ptntoP0jaWvYkxN4FisZDQSA/i2jZRjJKRx
  37901. AgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBRqciZ6
  37902. 0B7vfec7aVHUbI2fkBJmqzANBgkqhkiG9w0BAQsFAAOCAQEAeZ8dlsa2eT8ijYfThwMEYGprmi5Z
  37903. iXMRrEPR9RP/jTkrwPK9T3CMqS/qF8QLVJ7UG5aYMzyorWKiAHarWWluBh1+xLlEjZivEtRh2woZ
  37904. Rkfz6/djwUAFQKXSt/S1mja/qYh2iARVBCuch38aNzx+LaUa2NSJXsq9rD1s2G2v1fN2D807iDgi
  37905. nWyTmsQ9v4IbZT+mD12q/OWyFcq1rca8PdCE6OoGcrBNOTJ4vz4RnAuknZoh8/CbCzB428Hch0P+
  37906. vGOaysXCHMnHjf87ElgI5rY97HosTvuDls4MPGmHVHOkc8KT/1EQrBVUAdj8BbGJoX90g5pJ19xO
  37907. e4pIb4tF9g==
  37908. -----END CERTIFICATE-----
  37909. Entrust Root Certification Authority - EC1
  37910. ==========================================
  37911. -----BEGIN CERTIFICATE-----
  37912. MIIC+TCCAoCgAwIBAgINAKaLeSkAAAAAUNCR+TAKBggqhkjOPQQDAzCBvzELMAkGA1UEBhMCVVMx
  37913. FjAUBgNVBAoTDUVudHJ1c3QsIEluYy4xKDAmBgNVBAsTH1NlZSB3d3cuZW50cnVzdC5uZXQvbGVn
  37914. YWwtdGVybXMxOTA3BgNVBAsTMChjKSAyMDEyIEVudHJ1c3QsIEluYy4gLSBmb3IgYXV0aG9yaXpl
  37915. ZCB1c2Ugb25seTEzMDEGA1UEAxMqRW50cnVzdCBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5
  37916. IC0gRUMxMB4XDTEyMTIxODE1MjUzNloXDTM3MTIxODE1NTUzNlowgb8xCzAJBgNVBAYTAlVTMRYw
  37917. FAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0L2xlZ2Fs
  37918. LXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxMiBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhvcml6ZWQg
  37919. dXNlIG9ubHkxMzAxBgNVBAMTKkVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAt
  37920. IEVDMTB2MBAGByqGSM49AgEGBSuBBAAiA2IABIQTydC6bUF74mzQ61VfZgIaJPRbiWlH47jCffHy
  37921. AsWfoPZb1YsGGYZPUxBtByQnoaD41UcZYUx9ypMn6nQM72+WCf5j7HBdNq1nd67JnXxVRDqiY1Ef
  37922. 9eNi1KlHBz7MIKNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYE
  37923. FLdj5xrdjekIplWDpOBqUEFlEUJJMAoGCCqGSM49BAMDA2cAMGQCMGF52OVCR98crlOZF7ZvHH3h
  37924. vxGU0QOIdeSNiaSKd0bebWHvAvX7td/M/k7//qnmpwIwW5nXhTcGtXsI/esni0qU+eH6p44mCOh8
  37925. kmhtc9hvJqwhAriZtyZBWyVgrtBIGu4G
  37926. -----END CERTIFICATE-----
  37927. CFCA EV ROOT
  37928. ============
  37929. -----BEGIN CERTIFICATE-----
  37930. MIIFjTCCA3WgAwIBAgIEGErM1jANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJDTjEwMC4GA1UE
  37931. CgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQDDAxDRkNB
  37932. IEVWIFJPT1QwHhcNMTIwODA4MDMwNzAxWhcNMjkxMjMxMDMwNzAxWjBWMQswCQYDVQQGEwJDTjEw
  37933. MC4GA1UECgwnQ2hpbmEgRmluYW5jaWFsIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRUwEwYDVQQD
  37934. DAxDRkNBIEVWIFJPT1QwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDXXWvNED8fBVnV
  37935. BU03sQ7smCuOFR36k0sXgiFxEFLXUWRwFsJVaU2OFW2fvwwbwuCjZ9YMrM8irq93VCpLTIpTUnrD
  37936. 7i7es3ElweldPe6hL6P3KjzJIx1qqx2hp/Hz7KDVRM8Vz3IvHWOX6Jn5/ZOkVIBMUtRSqy5J35DN
  37937. uF++P96hyk0g1CXohClTt7GIH//62pCfCqktQT+x8Rgp7hZZLDRJGqgG16iI0gNyejLi6mhNbiyW
  37938. ZXvKWfry4t3uMCz7zEasxGPrb382KzRzEpR/38wmnvFyXVBlWY9ps4deMm/DGIq1lY+wejfeWkU7
  37939. xzbh72fROdOXW3NiGUgthxwG+3SYIElz8AXSG7Ggo7cbcNOIabla1jj0Ytwli3i/+Oh+uFzJlU9f
  37940. py25IGvPa931DfSCt/SyZi4QKPaXWnuWFo8BGS1sbn85WAZkgwGDg8NNkt0yxoekN+kWzqotaK8K
  37941. gWU6cMGbrU1tVMoqLUuFG7OA5nBFDWteNfB/O7ic5ARwiRIlk9oKmSJgamNgTnYGmE69g60dWIol
  37942. hdLHZR4tjsbftsbhf4oEIRUpdPA+nJCdDC7xij5aqgwJHsfVPKPtl8MeNPo4+QgO48BdK4PRVmrJ
  37943. tqhUUy54Mmc9gn900PvhtgVguXDbjgv5E1hvcWAQUhC5wUEJ73IfZzF4/5YFjQIDAQABo2MwYTAf
  37944. BgNVHSMEGDAWgBTj/i39KNALtbq2osS/BqoFjJP7LzAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB
  37945. /wQEAwIBBjAdBgNVHQ4EFgQU4/4t/SjQC7W6tqLEvwaqBYyT+y8wDQYJKoZIhvcNAQELBQADggIB
  37946. ACXGumvrh8vegjmWPfBEp2uEcwPenStPuiB/vHiyz5ewG5zz13ku9Ui20vsXiObTej/tUxPQ4i9q
  37947. ecsAIyjmHjdXNYmEwnZPNDatZ8POQQaIxffu2Bq41gt/UP+TqhdLjOztUmCypAbqTuv0axn96/Ua
  37948. 4CUqmtzHQTb3yHQFhDmVOdYLO6Qn+gjYXB74BGBSESgoA//vU2YApUo0FmZ8/Qmkrp5nGm9BC2sG
  37949. E5uPhnEFtC+NiWYzKXZUmhH4J/qyP5Hgzg0b8zAarb8iXRvTvyUFTeGSGn+ZnzxEk8rUQElsgIfX
  37950. BDrDMlI1Dlb4pd19xIsNER9Tyx6yF7Zod1rg1MvIB671Oi6ON7fQAUtDKXeMOZePglr4UeWJoBjn
  37951. aH9dCi77o0cOPaYjesYBx4/IXr9tgFa+iiS6M+qf4TIRnvHST4D2G0CvOJ4RUHlzEhLN5mydLIhy
  37952. PDCBBpEi6lmt2hkuIsKNuYyH4Ga8cyNfIWRjgEj1oDwYPZTISEEdQLpe/v5WOaHIz16eGWRGENoX
  37953. kbcFgKyLmZJ956LYBws2J+dIeWCKw9cTXPhyQN9Ky8+ZAAoACxGV2lZFA4gKn2fQ1XmxqI1AbQ3C
  37954. ekD6819kR5LLU7m7Wc5P/dAVUwHY3+vZ5nbv0CO7O6l5s9UCKc2Jo5YPSjXnTkLAdc0Hz+Ys63su
  37955. -----END CERTIFICATE-----
  37956. OISTE WISeKey Global Root GB CA
  37957. ===============================
  37958. -----BEGIN CERTIFICATE-----
  37959. MIIDtTCCAp2gAwIBAgIQdrEgUnTwhYdGs/gjGvbCwDANBgkqhkiG9w0BAQsFADBtMQswCQYDVQQG
  37960. EwJDSDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNl
  37961. ZDEoMCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQiBDQTAeFw0xNDEyMDExNTAw
  37962. MzJaFw0zOTEyMDExNTEwMzFaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYD
  37963. VQQLExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEds
  37964. b2JhbCBSb290IEdCIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2Be3HEokKtaX
  37965. scriHvt9OO+Y9bI5mE4nuBFde9IllIiCFSZqGzG7qFshISvYD06fWvGxWuR51jIjK+FTzJlFXHtP
  37966. rby/h0oLS5daqPZI7H17Dc0hBt+eFf1Biki3IPShehtX1F1Q/7pn2COZH8g/497/b1t3sWtuuMlk
  37967. 9+HKQUYOKXHQuSP8yYFfTvdv37+ErXNku7dCjmn21HYdfp2nuFeKUWdy19SouJVUQHMD9ur06/4o
  37968. Qnc/nSMbsrY9gBQHTC5P99UKFg29ZkM3fiNDecNAhvVMKdqOmq0NpQSHiB6F4+lT1ZvIiwNjeOvg
  37969. GUpuuy9rM2RYk61pv48b74JIxwIDAQABo1EwTzALBgNVHQ8EBAMCAYYwDwYDVR0TAQH/BAUwAwEB
  37970. /zAdBgNVHQ4EFgQUNQ/INmNe4qPs+TtmFc5RUuORmj0wEAYJKwYBBAGCNxUBBAMCAQAwDQYJKoZI
  37971. hvcNAQELBQADggEBAEBM+4eymYGQfp3FsLAmzYh7KzKNbrghcViXfa43FK8+5/ea4n32cZiZBKpD
  37972. dHij40lhPnOMTZTg+XHEthYOU3gf1qKHLwI5gSk8rxWYITD+KJAAjNHhy/peyP34EEY7onhCkRd0
  37973. VQreUGdNZtGn//3ZwLWoo4rOZvUPQ82nK1d7Y0Zqqi5S2PTt4W2tKZB4SLrhI6qjiey1q5bAtEui
  37974. HZeeevJuQHHfaPFlTc58Bd9TZaml8LGXBHAVRgOY1NK/VLSgWH1Sb9pWJmLU2NuJMW8c8CLC02Ic
  37975. Nc1MaRVUGpCY3useX8p3x8uOPUNpnJpY0CQ73xtAln41rYHHTnG6iBM=
  37976. -----END CERTIFICATE-----
  37977. SZAFIR ROOT CA2
  37978. ===============
  37979. -----BEGIN CERTIFICATE-----
  37980. MIIDcjCCAlqgAwIBAgIUPopdB+xV0jLVt+O2XwHrLdzk1uQwDQYJKoZIhvcNAQELBQAwUTELMAkG
  37981. A1UEBhMCUEwxKDAmBgNVBAoMH0tyYWpvd2EgSXpiYSBSb3psaWN6ZW5pb3dhIFMuQS4xGDAWBgNV
  37982. BAMMD1NaQUZJUiBST09UIENBMjAeFw0xNTEwMTkwNzQzMzBaFw0zNTEwMTkwNzQzMzBaMFExCzAJ
  37983. BgNVBAYTAlBMMSgwJgYDVQQKDB9LcmFqb3dhIEl6YmEgUm96bGljemVuaW93YSBTLkEuMRgwFgYD
  37984. VQQDDA9TWkFGSVIgUk9PVCBDQTIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC3vD5Q
  37985. qEvNQLXOYeeWyrSh2gwisPq1e3YAd4wLz32ohswmUeQgPYUM1ljj5/QqGJ3a0a4m7utT3PSQ1hNK
  37986. DJA8w/Ta0o4NkjrcsbH/ON7Dui1fgLkCvUqdGw+0w8LBZwPd3BucPbOw3gAeqDRHu5rr/gsUvTaE
  37987. 2g0gv/pby6kWIK05YO4vdbbnl5z5Pv1+TW9NL++IDWr63fE9biCloBK0TXC5ztdyO4mTp4CEHCdJ
  37988. ckm1/zuVnsHMyAHs6A6KCpbns6aH5db5BSsNl0BwPLqsdVqc1U2dAgrSS5tmS0YHF2Wtn2yIANwi
  37989. ieDhZNRnvDF5YTy7ykHNXGoAyDw4jlivAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0P
  37990. AQH/BAQDAgEGMB0GA1UdDgQWBBQuFqlKGLXLzPVvUPMjX/hd56zwyDANBgkqhkiG9w0BAQsFAAOC
  37991. AQEAtXP4A9xZWx126aMqe5Aosk3AM0+qmrHUuOQn/6mWmc5G4G18TKI4pAZw8PRBEew/R40/cof5
  37992. O/2kbytTAOD/OblqBw7rHRz2onKQy4I9EYKL0rufKq8h5mOGnXkZ7/e7DDWQw4rtTw/1zBLZpD67
  37993. oPwglV9PJi8RI4NOdQcPv5vRtB3pEAT+ymCPoky4rc/hkA/NrgrHXXu3UNLUYfrVFdvXn4dRVOul
  37994. 4+vJhaAlIDf7js4MNIThPIGyd05DpYhfhmehPea0XGG2Ptv+tyjFogeutcrKjSoS75ftwjCkySp6
  37995. +/NNIxuZMzSgLvWpCz/UXeHPhJ/iGcJfitYgHuNztw==
  37996. -----END CERTIFICATE-----
  37997. Certum Trusted Network CA 2
  37998. ===========================
  37999. -----BEGIN CERTIFICATE-----
  38000. MIIF0jCCA7qgAwIBAgIQIdbQSk8lD8kyN/yqXhKN6TANBgkqhkiG9w0BAQ0FADCBgDELMAkGA1UE
  38001. BhMCUEwxIjAgBgNVBAoTGVVuaXpldG8gVGVjaG5vbG9naWVzIFMuQS4xJzAlBgNVBAsTHkNlcnR1
  38002. bSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTEkMCIGA1UEAxMbQ2VydHVtIFRydXN0ZWQgTmV0d29y
  38003. ayBDQSAyMCIYDzIwMTExMDA2MDgzOTU2WhgPMjA0NjEwMDYwODM5NTZaMIGAMQswCQYDVQQGEwJQ
  38004. TDEiMCAGA1UEChMZVW5pemV0byBUZWNobm9sb2dpZXMgUy5BLjEnMCUGA1UECxMeQ2VydHVtIENl
  38005. cnRpZmljYXRpb24gQXV0aG9yaXR5MSQwIgYDVQQDExtDZXJ0dW0gVHJ1c3RlZCBOZXR3b3JrIENB
  38006. IDIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC9+Xj45tWADGSdhhuWZGc/IjoedQF9
  38007. 7/tcZ4zJzFxrqZHmuULlIEub2pt7uZld2ZuAS9eEQCsn0+i6MLs+CRqnSZXvK0AkwpfHp+6bJe+o
  38008. CgCXhVqqndwpyeI1B+twTUrWwbNWuKFBOJvR+zF/j+Bf4bE/D44WSWDXBo0Y+aomEKsq09DRZ40b
  38009. Rr5HMNUuctHFY9rnY3lEfktjJImGLjQ/KUxSiyqnwOKRKIm5wFv5HdnnJ63/mgKXwcZQkpsCLL2p
  38010. uTRZCr+ESv/f/rOf69me4Jgj7KZrdxYq28ytOxykh9xGc14ZYmhFV+SQgkK7QtbwYeDBoz1mo130
  38011. GO6IyY0XRSmZMnUCMe4pJshrAua1YkV/NxVaI2iJ1D7eTiew8EAMvE0Xy02isx7QBlrd9pPPV3WZ
  38012. 9fqGGmd4s7+W/jTcvedSVuWz5XV710GRBdxdaeOVDUO5/IOWOZV7bIBaTxNyxtd9KXpEulKkKtVB
  38013. Rgkg/iKgtlswjbyJDNXXcPiHUv3a76xRLgezTv7QCdpw75j6VuZt27VXS9zlLCUVyJ4ueE742pye
  38014. hizKV/Ma5ciSixqClnrDvFASadgOWkaLOusm+iPJtrCBvkIApPjW/jAux9JG9uWOdf3yzLnQh1vM
  38015. BhBgu4M1t15n3kfsmUjxpKEV/q2MYo45VU85FrmxY53/twIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  38016. AQH/MB0GA1UdDgQWBBS2oVQ5AsOgP46KvPrU+Bym0ToO/TAOBgNVHQ8BAf8EBAMCAQYwDQYJKoZI
  38017. hvcNAQENBQADggIBAHGlDs7k6b8/ONWJWsQCYftMxRQXLYtPU2sQF/xlhMcQSZDe28cmk4gmb3DW
  38018. Al45oPePq5a1pRNcgRRtDoGCERuKTsZPpd1iHkTfCVn0W3cLN+mLIMb4Ck4uWBzrM9DPhmDJ2vuA
  38019. L55MYIR4PSFk1vtBHxgP58l1cb29XN40hz5BsA72udY/CROWFC/emh1auVbONTqwX3BNXuMp8SMo
  38020. clm2q8KMZiYcdywmdjWLKKdpoPk79SPdhRB0yZADVpHnr7pH1BKXESLjokmUbOe3lEu6LaTaM4tM
  38021. pkT/WjzGHWTYtTHkpjx6qFcL2+1hGsvxznN3Y6SHb0xRONbkX8eftoEq5IVIeVheO/jbAoJnwTnb
  38022. w3RLPTYe+SmTiGhbqEQZIfCn6IENLOiTNrQ3ssqwGyZ6miUfmpqAnksqP/ujmv5zMnHCnsZy4Ypo
  38023. J/HkD7TETKVhk/iXEAcqMCWpuchxuO9ozC1+9eB+D4Kob7a6bINDd82Kkhehnlt4Fj1F4jNy3eFm
  38024. ypnTycUm/Q1oBEauttmbjL4ZvrHG8hnjXALKLNhvSgfZyTXaQHXyxKcZb55CEJh15pWLYLztxRLX
  38025. is7VmFxWlgPF7ncGNf/P5O4/E2Hu29othfDNrp2yGAlFw5Khchf8R7agCyzxxN5DaAhqXzvwdmP7
  38026. zAYspsbiDrW5viSP
  38027. -----END CERTIFICATE-----
  38028. Hellenic Academic and Research Institutions RootCA 2015
  38029. =======================================================
  38030. -----BEGIN CERTIFICATE-----
  38031. MIIGCzCCA/OgAwIBAgIBADANBgkqhkiG9w0BAQsFADCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcT
  38032. BkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0
  38033. aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNVBAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNl
  38034. YXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIwMTUwHhcNMTUwNzA3MTAxMTIxWhcNNDAwNjMwMTAx
  38035. MTIxWjCBpjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0aGVuczFEMEIGA1UEChM7SGVsbGVuaWMg
  38036. QWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9ucyBDZXJ0LiBBdXRob3JpdHkxQDA+BgNV
  38037. BAMTN0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgUm9vdENBIDIw
  38038. MTUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDC+Kk/G4n8PDwEXT2QNrCROnk8Zlrv
  38039. bTkBSRq0t89/TSNTt5AA4xMqKKYx8ZEA4yjsriFBzh/a/X0SWwGDD7mwX5nh8hKDgE0GPt+sr+eh
  38040. iGsxr/CL0BgzuNtFajT0AoAkKAoCFZVedioNmToUW/bLy1O8E00BiDeUJRtCvCLYjqOWXjrZMts+
  38041. 6PAQZe104S+nfK8nNLspfZu2zwnI5dMK/IhlZXQK3HMcXM1AsRzUtoSMTFDPaI6oWa7CJ06CojXd
  38042. FPQf/7J31Ycvqm59JCfnxssm5uX+Zwdj2EUN3TpZZTlYepKZcj2chF6IIbjV9Cz82XBST3i4vTwr
  38043. i5WY9bPRaM8gFH5MXF/ni+X1NYEZN9cRCLdmvtNKzoNXADrDgfgXy5I2XdGj2HUb4Ysn6npIQf1F
  38044. GQatJ5lOwXBH3bWfgVMS5bGMSF0xQxfjjMZ6Y5ZLKTBOhE5iGV48zpeQpX8B653g+IuJ3SWYPZK2
  38045. fu/Z8VFRfS0myGlZYeCsargqNhEEelC9MoS+L9xy1dcdFkfkR2YgP/SWxa+OAXqlD3pk9Q0Yh9mu
  38046. iNX6hME6wGkoLfINaFGq46V3xqSQDqE3izEjR8EJCOtu93ib14L8hCCZSRm2Ekax+0VVFqmjZayc
  38047. Bw/qa9wfLgZy7IaIEuQt218FL+TwA9MmM+eAws1CoRc0CwIDAQABo0IwQDAPBgNVHRMBAf8EBTAD
  38048. AQH/MA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUcRVnyMjJvXVdctA4GGqd83EkVAswDQYJKoZI
  38049. hvcNAQELBQADggIBAHW7bVRLqhBYRjTyYtcWNl0IXtVsyIe9tC5G8jH4fOpCtZMWVdyhDBKg2mF+
  38050. D1hYc2Ryx+hFjtyp8iY/xnmMsVMIM4GwVhO+5lFc2JsKT0ucVlMC6U/2DWDqTUJV6HwbISHTGzrM
  38051. d/K4kPFox/la/vot9L/J9UUbzjgQKjeKeaO04wlshYaT/4mWJ3iBj2fjRnRUjtkNaeJK9E10A/+y
  38052. d+2VZ5fkscWrv2oj6NSU4kQoYsRL4vDY4ilrGnB+JGGTe08DMiUNRSQrlrRGar9KC/eaj8GsGsVn
  38053. 82800vpzY4zvFrCopEYq+OsS7HK07/grfoxSwIuEVPkvPuNVqNxmsdnhX9izjFk0WaSrT2y7Hxjb
  38054. davYy5LNlDhhDgcGH0tGEPEVvo2FXDtKK4F5D7Rpn0lQl033DlZdwJVqwjbDG2jJ9SrcR5q+ss7F
  38055. Jej6A7na+RZukYT1HCjI/CbM1xyQVqdfbzoEvM14iQuODy+jqk+iGxI9FghAD/FGTNeqewjBCvVt
  38056. J94Cj8rDtSvK6evIIVM4pcw72Hc3MKJP2W/R8kCtQXoXxdZKNYm3QdV8hn9VTYNKpXMgwDqvkPGa
  38057. JI7ZjnHKe7iG2rKPmT4dEw0SEe7Uq/DpFXYC5ODfqiAeW2GFZECpkJcNrVPSWh2HagCXZWK0vm9q
  38058. p/UsQu0yrbYhnr68
  38059. -----END CERTIFICATE-----
  38060. Hellenic Academic and Research Institutions ECC RootCA 2015
  38061. ===========================================================
  38062. -----BEGIN CERTIFICATE-----
  38063. MIICwzCCAkqgAwIBAgIBADAKBggqhkjOPQQDAjCBqjELMAkGA1UEBhMCR1IxDzANBgNVBAcTBkF0
  38064. aGVuczFEMEIGA1UEChM7SGVsbGVuaWMgQWNhZGVtaWMgYW5kIFJlc2VhcmNoIEluc3RpdHV0aW9u
  38065. cyBDZXJ0LiBBdXRob3JpdHkxRDBCBgNVBAMTO0hlbGxlbmljIEFjYWRlbWljIGFuZCBSZXNlYXJj
  38066. aCBJbnN0aXR1dGlvbnMgRUNDIFJvb3RDQSAyMDE1MB4XDTE1MDcwNzEwMzcxMloXDTQwMDYzMDEw
  38067. MzcxMlowgaoxCzAJBgNVBAYTAkdSMQ8wDQYDVQQHEwZBdGhlbnMxRDBCBgNVBAoTO0hlbGxlbmlj
  38068. IEFjYWRlbWljIGFuZCBSZXNlYXJjaCBJbnN0aXR1dGlvbnMgQ2VydC4gQXV0aG9yaXR5MUQwQgYD
  38069. VQQDEztIZWxsZW5pYyBBY2FkZW1pYyBhbmQgUmVzZWFyY2ggSW5zdGl0dXRpb25zIEVDQyBSb290
  38070. Q0EgMjAxNTB2MBAGByqGSM49AgEGBSuBBAAiA2IABJKgQehLgoRc4vgxEZmGZE4JJS+dQS8KrjVP
  38071. dJWyUWRrjWvmP3CV8AVER6ZyOFB2lQJajq4onvktTpnvLEhvTCUp6NFxW98dwXU3tNf6e3pCnGoK
  38072. Vlp8aQuqgAkkbH7BRqNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0O
  38073. BBYEFLQiC4KZJAEOnLvkDv2/+5cgk5kqMAoGCCqGSM49BAMCA2cAMGQCMGfOFmI4oqxiRaeplSTA
  38074. GiecMjvAwNW6qef4BENThe5SId6d9SWDPp5YSy/XZxMOIQIwBeF1Ad5o7SofTUwJCA3sS61kFyjn
  38075. dc5FZXIhF8siQQ6ME5g4mlRtm8rifOoCWCKR
  38076. -----END CERTIFICATE-----
  38077. ISRG Root X1
  38078. ============
  38079. -----BEGIN CERTIFICATE-----
  38080. MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAwTzELMAkGA1UE
  38081. BhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2VhcmNoIEdyb3VwMRUwEwYDVQQD
  38082. EwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQG
  38083. EwJVUzEpMCcGA1UEChMgSW50ZXJuZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMT
  38084. DElTUkcgUm9vdCBYMTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54r
  38085. Vygch77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+0TM8ukj1
  38086. 3Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6UA5/TR5d8mUgjU+g4rk8K
  38087. b4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sWT8KOEUt+zwvo/7V3LvSye0rgTBIlDHCN
  38088. Aymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyHB5T0Y3HsLuJvW5iB4YlcNHlsdu87kGJ55tukmi8mxdAQ
  38089. 4Q7e2RCOFvu396j3x+UCB5iPNgiV5+I3lg02dZ77DnKxHZu8A/lJBdiB3QW0KtZB6awBdpUKD9jf
  38090. 1b0SHzUvKBds0pjBqAlkd25HN7rOrFleaJ1/ctaJxQZBKT5ZPt0m9STJEadao0xAH0ahmbWnOlFu
  38091. hjuefXKnEgV4We0+UXgVCwOPjdAvBbI+e0ocS3MFEvzG6uBQE3xDk3SzynTnjh8BCNAw1FtxNrQH
  38092. usEwMFxIt4I7mKZ9YIqioymCzLq9gwQbooMDQaHWBfEbwrbwqHyGO0aoSCqI3Haadr8faqU9GY/r
  38093. OPNk3sgrDQoo//fb4hVC1CLQJ13hef4Y53CIrU7m2Ys6xt0nUW7/vGT1M0NPAgMBAAGjQjBAMA4G
  38094. A1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBR5tFnme7bl5AFzgAiIyBpY
  38095. 9umbbjANBgkqhkiG9w0BAQsFAAOCAgEAVR9YqbyyqFDQDLHYGmkgJykIrGF1XIpu+ILlaS/V9lZL
  38096. ubhzEFnTIZd+50xx+7LSYK05qAvqFyFWhfFQDlnrzuBZ6brJFe+GnY+EgPbk6ZGQ3BebYhtF8GaV
  38097. 0nxvwuo77x/Py9auJ/GpsMiu/X1+mvoiBOv/2X/qkSsisRcOj/KKNFtY2PwByVS5uCbMiogziUwt
  38098. hDyC3+6WVwW6LLv3xLfHTjuCvjHIInNzktHCgKQ5ORAzI4JMPJ+GslWYHb4phowim57iaztXOoJw
  38099. TdwJx4nLCgdNbOhdjsnvzqvHu7UrTkXWStAmzOVyyghqpZXjFaH3pO3JLF+l+/+sKAIuvtd7u+Nx
  38100. e5AW0wdeRlN8NwdCjNPElpzVmbUq4JUagEiuTDkHzsxHpFKVK7q4+63SM1N95R1NbdWhscdCb+ZA
  38101. JzVcoyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq4RgqsahD
  38102. YVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPAmRGunUHBcnWEvgJBQl9n
  38103. JEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57demyPxgcYxn/eR44/KJ4EBs+lVDR3veyJ
  38104. m+kXQ99b21/+jh5Xos1AnX5iItreGCc=
  38105. -----END CERTIFICATE-----
  38106. AC RAIZ FNMT-RCM
  38107. ================
  38108. -----BEGIN CERTIFICATE-----
  38109. MIIFgzCCA2ugAwIBAgIPXZONMGc2yAYdGsdUhGkHMA0GCSqGSIb3DQEBCwUAMDsxCzAJBgNVBAYT
  38110. AkVTMREwDwYDVQQKDAhGTk1ULVJDTTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTAeFw0wODEw
  38111. MjkxNTU5NTZaFw0zMDAxMDEwMDAwMDBaMDsxCzAJBgNVBAYTAkVTMREwDwYDVQQKDAhGTk1ULVJD
  38112. TTEZMBcGA1UECwwQQUMgUkFJWiBGTk1ULVJDTTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  38113. ggIBALpxgHpMhm5/yBNtwMZ9HACXjywMI7sQmkCpGreHiPibVmr75nuOi5KOpyVdWRHbNi63URcf
  38114. qQgfBBckWKo3Shjf5TnUV/3XwSyRAZHiItQDwFj8d0fsjz50Q7qsNI1NOHZnjrDIbzAzWHFctPVr
  38115. btQBULgTfmxKo0nRIBnuvMApGGWn3v7v3QqQIecaZ5JCEJhfTzC8PhxFtBDXaEAUwED653cXeuYL
  38116. j2VbPNmaUtu1vZ5Gzz3rkQUCwJaydkxNEJY7kvqcfw+Z374jNUUeAlz+taibmSXaXvMiwzn15Cou
  38117. 08YfxGyqxRxqAQVKL9LFwag0Jl1mpdICIfkYtwb1TplvqKtMUejPUBjFd8g5CSxJkjKZqLsXF3mw
  38118. WsXmo8RZZUc1g16p6DULmbvkzSDGm0oGObVo/CK67lWMK07q87Hj/LaZmtVC+nFNCM+HHmpxffnT
  38119. tOmlcYF7wk5HlqX2doWjKI/pgG6BU6VtX7hI+cL5NqYuSf+4lsKMB7ObiFj86xsc3i1w4peSMKGJ
  38120. 47xVqCfWS+2QrYv6YyVZLag13cqXM7zlzced0ezvXg5KkAYmY6252TUtB7p2ZSysV4999AeU14EC
  38121. ll2jB0nVetBX+RvnU0Z1qrB5QstocQjpYL05ac70r8NWQMetUqIJ5G+GR4of6ygnXYMgrwTJbFaa
  38122. i0b1AgMBAAGjgYMwgYAwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYE
  38123. FPd9xf3E6Jobd2Sn9R2gzL+HYJptMD4GA1UdIAQ3MDUwMwYEVR0gADArMCkGCCsGAQUFBwIBFh1o
  38124. dHRwOi8vd3d3LmNlcnQuZm5tdC5lcy9kcGNzLzANBgkqhkiG9w0BAQsFAAOCAgEAB5BK3/MjTvDD
  38125. nFFlm5wioooMhfNzKWtN/gHiqQxjAb8EZ6WdmF/9ARP67Jpi6Yb+tmLSbkyU+8B1RXxlDPiyN8+s
  38126. D8+Nb/kZ94/sHvJwnvDKuO+3/3Y3dlv2bojzr2IyIpMNOmqOFGYMLVN0V2Ue1bLdI4E7pWYjJ2cJ
  38127. j+F3qkPNZVEI7VFY/uY5+ctHhKQV8Xa7pO6kO8Rf77IzlhEYt8llvhjho6Tc+hj507wTmzl6NLrT
  38128. Qfv6MooqtyuGC2mDOL7Nii4LcK2NJpLuHvUBKwrZ1pebbuCoGRw6IYsMHkCtA+fdZn71uSANA+iW
  38129. +YJF1DngoABd15jmfZ5nc8OaKveri6E6FO80vFIOiZiaBECEHX5FaZNXzuvO+FB8TxxuBEOb+dY7
  38130. Ixjp6o7RTUaN8Tvkasq6+yO3m/qZASlaWFot4/nUbQ4mrcFuNLwy+AwF+mWj2zs3gyLp1txyM/1d
  38131. 8iC9djwj2ij3+RvrWWTV3F9yfiD8zYm1kGdNYno/Tq0dwzn+evQoFt9B9kiABdcPUXmsEKvU7ANm
  38132. 5mqwujGSQkBqvjrTcuFqN1W8rB2Vt2lh8kORdOag0wokRqEIr9baRRmW1FMdW4R58MD3R++Lj8UG
  38133. rp1MYp3/RgT408m2ECVAdf4WqslKYIYvuu8wd+RU4riEmViAqhOLUTpPSPaLtrM=
  38134. -----END CERTIFICATE-----
  38135. Amazon Root CA 1
  38136. ================
  38137. -----BEGIN CERTIFICATE-----
  38138. MIIDQTCCAimgAwIBAgITBmyfz5m/jAo54vB4ikPmljZbyjANBgkqhkiG9w0BAQsFADA5MQswCQYD
  38139. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAxMB4XDTE1
  38140. MDUyNjAwMDAwMFoXDTM4MDExNzAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  38141. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
  38142. ggEBALJ4gHHKeNXjca9HgFB0fW7Y14h29Jlo91ghYPl0hAEvrAIthtOgQ3pOsqTQNroBvo3bSMgH
  38143. FzZM9O6II8c+6zf1tRn4SWiw3te5djgdYZ6k/oI2peVKVuRF4fn9tBb6dNqcmzU5L/qwIFAGbHrQ
  38144. gLKm+a/sRxmPUDgH3KKHOVj4utWp+UhnMJbulHheb4mjUcAwhmahRWa6VOujw5H5SNz/0egwLX0t
  38145. dHA114gk957EWW67c4cX8jJGKLhD+rcdqsq08p8kDi1L93FcXmn/6pUCyziKrlA4b9v7LWIbxcce
  38146. VOF34GfID5yHI9Y/QCB/IIDEgEw+OyQmjgSubJrIqg0CAwEAAaNCMEAwDwYDVR0TAQH/BAUwAwEB
  38147. /zAOBgNVHQ8BAf8EBAMCAYYwHQYDVR0OBBYEFIQYzIU07LwMlJQuCFmcx7IQTgoIMA0GCSqGSIb3
  38148. DQEBCwUAA4IBAQCY8jdaQZChGsV2USggNiMOruYou6r4lK5IpDB/G/wkjUu0yKGX9rbxenDIU5PM
  38149. CCjjmCXPI6T53iHTfIUJrU6adTrCC2qJeHZERxhlbI1Bjjt/msv0tadQ1wUsN+gDS63pYaACbvXy
  38150. 8MWy7Vu33PqUXHeeE6V/Uq2V8viTO96LXFvKWlJbYK8U90vvo/ufQJVtMVT8QtPHRh8jrdkPSHCa
  38151. 2XV4cdFyQzR1bldZwgJcJmApzyMZFo6IQ6XU5MsI+yMRQ+hDKXJioaldXgjUkK642M4UwtBV8ob2
  38152. xJNDd2ZhwLnoQdeXeGADbkpyrqXRfboQnoZsG4q5WTP468SQvvG5
  38153. -----END CERTIFICATE-----
  38154. Amazon Root CA 2
  38155. ================
  38156. -----BEGIN CERTIFICATE-----
  38157. MIIFQTCCAymgAwIBAgITBmyf0pY1hp8KD+WGePhbJruKNzANBgkqhkiG9w0BAQwFADA5MQswCQYD
  38158. VQQGEwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAyMB4XDTE1
  38159. MDUyNjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpv
  38160. bjEZMBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoC
  38161. ggIBAK2Wny2cSkxKgXlRmeyKy2tgURO8TW0G/LAIjd0ZEGrHJgw12MBvIITplLGbhQPDW9tK6Mj4
  38162. kHbZW0/jTOgGNk3Mmqw9DJArktQGGWCsN0R5hYGCrVo34A3MnaZMUnbqQ523BNFQ9lXg1dKmSYXp
  38163. N+nKfq5clU1Imj+uIFptiJXZNLhSGkOQsL9sBbm2eLfq0OQ6PBJTYv9K8nu+NQWpEjTj82R0Yiw9
  38164. AElaKP4yRLuH3WUnAnE72kr3H9rN9yFVkE8P7K6C4Z9r2UXTu/Bfh+08LDmG2j/e7HJV63mjrdvd
  38165. fLC6HM783k81ds8P+HgfajZRRidhW+mez/CiVX18JYpvL7TFz4QuK/0NURBs+18bvBt+xa47mAEx
  38166. kv8LV/SasrlX6avvDXbR8O70zoan4G7ptGmh32n2M8ZpLpcTnqWHsFcQgTfJU7O7f/aS0ZzQGPSS
  38167. btqDT6ZjmUyl+17vIWR6IF9sZIUVyzfpYgwLKhbcAS4y2j5L9Z469hdAlO+ekQiG+r5jqFoz7Mt0
  38168. Q5X5bGlSNscpb/xVA1wf+5+9R+vnSUeVC06JIglJ4PVhHvG/LopyboBZ/1c6+XUyo05f7O0oYtlN
  38169. c/LMgRdg7c3r3NunysV+Ar3yVAhU/bQtCSwXVEqY0VThUWcI0u1ufm8/0i2BWSlmy5A5lREedCf+
  38170. 3euvAgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSw
  38171. DPBMMPQFWAJI/TPlUq9LhONmUjANBgkqhkiG9w0BAQwFAAOCAgEAqqiAjw54o+Ci1M3m9Zh6O+oA
  38172. A7CXDpO8Wqj2LIxyh6mx/H9z/WNxeKWHWc8w4Q0QshNabYL1auaAn6AFC2jkR2vHat+2/XcycuUY
  38173. +gn0oJMsXdKMdYV2ZZAMA3m3MSNjrXiDCYZohMr/+c8mmpJ5581LxedhpxfL86kSk5Nrp+gvU5LE
  38174. YFiwzAJRGFuFjWJZY7attN6a+yb3ACfAXVU3dJnJUH/jWS5E4ywl7uxMMne0nxrpS10gxdr9HIcW
  38175. xkPo1LsmmkVwXqkLN1PiRnsn/eBG8om3zEK2yygmbtmlyTrIQRNg91CMFa6ybRoVGld45pIq2WWQ
  38176. gj9sAq+uEjonljYE1x2igGOpm/HlurR8FLBOybEfdF849lHqm/osohHUqS0nGkWxr7JOcQ3AWEbW
  38177. aQbLU8uz/mtBzUF+fUwPfHJ5elnNXkoOrJupmHN5fLT0zLm4BwyydFy4x2+IoZCn9Kr5v2c69BoV
  38178. Yh63n749sSmvZ6ES8lgQGVMDMBu4Gon2nL2XA46jCfMdiyHxtN/kHNGfZQIG6lzWE7OE76KlXIx3
  38179. KadowGuuQNKotOrN8I1LOJwZmhsoVLiJkO/KdYE+HvJkJMcYr07/R54H9jVlpNMKVv/1F2Rs76gi
  38180. JUmTtt8AF9pYfl3uxRuw0dFfIRDH+fO6AgonB8Xx1sfT4PsJYGw=
  38181. -----END CERTIFICATE-----
  38182. Amazon Root CA 3
  38183. ================
  38184. -----BEGIN CERTIFICATE-----
  38185. MIIBtjCCAVugAwIBAgITBmyf1XSXNmY/Owua2eiedgPySjAKBggqhkjOPQQDAjA5MQswCQYDVQQG
  38186. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSAzMB4XDTE1MDUy
  38187. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  38188. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgMzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABCmXp8ZB
  38189. f8ANm+gBG1bG8lKlui2yEujSLtf6ycXYqm0fc4E7O5hrOXwzpcVOho6AF2hiRVd9RFgdszflZwjr
  38190. Zt6jQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBSrttvXBp43
  38191. rDCGB5Fwx5zEGbF4wDAKBggqhkjOPQQDAgNJADBGAiEA4IWSoxe3jfkrBqWTrBqYaGFy+uGh0Psc
  38192. eGCmQ5nFuMQCIQCcAu/xlJyzlvnrxir4tiz+OpAUFteMYyRIHN8wfdVoOw==
  38193. -----END CERTIFICATE-----
  38194. Amazon Root CA 4
  38195. ================
  38196. -----BEGIN CERTIFICATE-----
  38197. MIIB8jCCAXigAwIBAgITBmyf18G7EEwpQ+Vxe3ssyBrBDjAKBggqhkjOPQQDAzA5MQswCQYDVQQG
  38198. EwJVUzEPMA0GA1UEChMGQW1hem9uMRkwFwYDVQQDExBBbWF6b24gUm9vdCBDQSA0MB4XDTE1MDUy
  38199. NjAwMDAwMFoXDTQwMDUyNjAwMDAwMFowOTELMAkGA1UEBhMCVVMxDzANBgNVBAoTBkFtYXpvbjEZ
  38200. MBcGA1UEAxMQQW1hem9uIFJvb3QgQ0EgNDB2MBAGByqGSM49AgEGBSuBBAAiA2IABNKrijdPo1MN
  38201. /sGKe0uoe0ZLY7Bi9i0b2whxIdIA6GO9mif78DluXeo9pcmBqqNbIJhFXRbb/egQbeOc4OO9X4Ri
  38202. 83BkM6DLJC9wuoihKqB1+IGuYgbEgds5bimwHvouXKNCMEAwDwYDVR0TAQH/BAUwAwEB/zAOBgNV
  38203. HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFNPsxzplbszh2naaVvuc84ZtV+WBMAoGCCqGSM49BAMDA2gA
  38204. MGUCMDqLIfG9fhGt0O9Yli/W651+kI0rz2ZVwyzjKKlwCkcO8DdZEv8tmZQoTipPNU0zWgIxAOp1
  38205. AE47xDqUEpHJWEadIRNyp4iciuRMStuW1KyLa2tJElMzrdfkviT8tQp21KW8EA==
  38206. -----END CERTIFICATE-----
  38207. TUBITAK Kamu SM SSL Kok Sertifikasi - Surum 1
  38208. =============================================
  38209. -----BEGIN CERTIFICATE-----
  38210. MIIEYzCCA0ugAwIBAgIBATANBgkqhkiG9w0BAQsFADCB0jELMAkGA1UEBhMCVFIxGDAWBgNVBAcT
  38211. D0dlYnplIC0gS29jYWVsaTFCMEAGA1UEChM5VHVya2l5ZSBCaWxpbXNlbCB2ZSBUZWtub2xvamlr
  38212. IEFyYXN0aXJtYSBLdXJ1bXUgLSBUVUJJVEFLMS0wKwYDVQQLEyRLYW11IFNlcnRpZmlrYXN5b24g
  38213. TWVya2V6aSAtIEthbXUgU00xNjA0BgNVBAMTLVRVQklUQUsgS2FtdSBTTSBTU0wgS29rIFNlcnRp
  38214. ZmlrYXNpIC0gU3VydW0gMTAeFw0xMzExMjUwODI1NTVaFw00MzEwMjUwODI1NTVaMIHSMQswCQYD
  38215. VQQGEwJUUjEYMBYGA1UEBxMPR2ViemUgLSBLb2NhZWxpMUIwQAYDVQQKEzlUdXJraXllIEJpbGlt
  38216. c2VsIHZlIFRla25vbG9qaWsgQXJhc3Rpcm1hIEt1cnVtdSAtIFRVQklUQUsxLTArBgNVBAsTJEth
  38217. bXUgU2VydGlmaWthc3lvbiBNZXJrZXppIC0gS2FtdSBTTTE2MDQGA1UEAxMtVFVCSVRBSyBLYW11
  38218. IFNNIFNTTCBLb2sgU2VydGlmaWthc2kgLSBTdXJ1bSAxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A
  38219. MIIBCgKCAQEAr3UwM6q7a9OZLBI3hNmNe5eA027n/5tQlT6QlVZC1xl8JoSNkvoBHToP4mQ4t4y8
  38220. 6Ij5iySrLqP1N+RAjhgleYN1Hzv/bKjFxlb4tO2KRKOrbEz8HdDc72i9z+SqzvBV96I01INrN3wc
  38221. wv61A+xXzry0tcXtAA9TNypN9E8Mg/uGz8v+jE69h/mniyFXnHrfA2eJLJ2XYacQuFWQfw4tJzh0
  38222. 3+f92k4S400VIgLI4OD8D62K18lUUMw7D8oWgITQUVbDjlZ/iSIzL+aFCr2lqBs23tPcLG07xxO9
  38223. WSMs5uWk99gL7eqQQESolbuT1dCANLZGeA4fAJNG4e7p+exPFwIDAQABo0IwQDAdBgNVHQ4EFgQU
  38224. ZT/HiobGPN08VFw1+DrtUgxHV8gwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJ
  38225. KoZIhvcNAQELBQADggEBACo/4fEyjq7hmFxLXs9rHmoJ0iKpEsdeV31zVmSAhHqT5Am5EM2fKifh
  38226. AHe+SMg1qIGf5LgsyX8OsNJLN13qudULXjS99HMpw+0mFZx+CFOKWI3QSyjfwbPfIPP54+M638yc
  38227. lNhOT8NrF7f3cuitZjO1JVOr4PhMqZ398g26rrnZqsZr+ZO7rqu4lzwDGrpDxpa5RXI4s6ehlj2R
  38228. e37AIVNMh+3yC1SVUZPVIqUNivGTDj5UDrDYyU7c8jEyVupk+eq1nRZmQnLzf9OxMUP8pI4X8W0j
  38229. q5Rm+K37DwhuJi1/FwcJsoz7UMCflo3Ptv0AnVoUmr8CRPXBwp8iXqIPoeM=
  38230. -----END CERTIFICATE-----
  38231. GDCA TrustAUTH R5 ROOT
  38232. ======================
  38233. -----BEGIN CERTIFICATE-----
  38234. MIIFiDCCA3CgAwIBAgIIfQmX/vBH6nowDQYJKoZIhvcNAQELBQAwYjELMAkGA1UEBhMCQ04xMjAw
  38235. BgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZIENPLixMVEQuMR8wHQYDVQQD
  38236. DBZHRENBIFRydXN0QVVUSCBSNSBST09UMB4XDTE0MTEyNjA1MTMxNVoXDTQwMTIzMTE1NTk1OVow
  38237. YjELMAkGA1UEBhMCQ04xMjAwBgNVBAoMKUdVQU5HIERPTkcgQ0VSVElGSUNBVEUgQVVUSE9SSVRZ
  38238. IENPLixMVEQuMR8wHQYDVQQDDBZHRENBIFRydXN0QVVUSCBSNSBST09UMIICIjANBgkqhkiG9w0B
  38239. AQEFAAOCAg8AMIICCgKCAgEA2aMW8Mh0dHeb7zMNOwZ+Vfy1YI92hhJCfVZmPoiC7XJjDp6L3TQs
  38240. AlFRwxn9WVSEyfFrs0yw6ehGXTjGoqcuEVe6ghWinI9tsJlKCvLriXBjTnnEt1u9ol2x8kECK62p
  38241. OqPseQrsXzrj/e+APK00mxqriCZ7VqKChh/rNYmDf1+uKU49tm7srsHwJ5uu4/Ts765/94Y9cnrr
  38242. pftZTqfrlYwiOXnhLQiPzLyRuEH3FMEjqcOtmkVEs7LXLM3GKeJQEK5cy4KOFxg2fZfmiJqwTTQJ
  38243. 9Cy5WmYqsBebnh52nUpmMUHfP/vFBu8btn4aRjb3ZGM74zkYI+dndRTVdVeSN72+ahsmUPI2JgaQ
  38244. xXABZG12ZuGR224HwGGALrIuL4xwp9E7PLOR5G62xDtw8mySlwnNR30YwPO7ng/Wi64HtloPzgsM
  38245. R6flPri9fcebNaBhlzpBdRfMK5Z3KpIhHtmVdiBnaM8Nvd/WHwlqmuLMc3GkL30SgLdTMEZeS1SZ
  38246. D2fJpcjyIMGC7J0R38IC+xo70e0gmu9lZJIQDSri3nDxGGeCjGHeuLzRL5z7D9Ar7Rt2ueQ5Vfj4
  38247. oR24qoAATILnsn8JuLwwoC8N9VKejveSswoAHQBUlwbgsQfZxw9cZX08bVlX5O2ljelAU58VS6Bx
  38248. 9hoh49pwBiFYFIeFd3mqgnkCAwEAAaNCMEAwHQYDVR0OBBYEFOLJQJ9NzuiaoXzPDj9lxSmIahlR
  38249. MA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQDRSVfg
  38250. p8xoWLoBDysZzY2wYUWsEe1jUGn4H3++Fo/9nesLqjJHdtJnJO29fDMylyrHBYZmDRd9FBUb1Ov9
  38251. H5r2XpdptxolpAqzkT9fNqyL7FeoPueBihhXOYV0GkLH6VsTX4/5COmSdI31R9KrO9b7eGZONn35
  38252. 6ZLpBN79SWP8bfsUcZNnL0dKt7n/HipzcEYwv1ryL3ml4Y0M2fmyYzeMN2WFcGpcWwlyua1jPLHd
  38253. +PwyvzeG5LuOmCd+uh8W4XAR8gPfJWIyJyYYMoSf/wA6E7qaTfRPuBRwIrHKK5DOKcFw9C+df/KQ
  38254. HtZa37dG/OaG+svgIHZ6uqbL9XzeYqWxi+7egmaKTjowHz+Ay60nugxe19CxVsp3cbK1daFQqUBD
  38255. F8Io2c9Si1vIY9RCPqAzekYu9wogRlR+ak8x8YF+QnQ4ZXMn7sZ8uI7XpTrXmKGcjBBV09tL7ECQ
  38256. 8s1uV9JiDnxXk7Gnbc2dg7sq5+W2O3FYrf3RRbxake5TFW/TRQl1brqQXR4EzzffHqhmsYzmIGrv
  38257. /EhOdJhCrylvLmrH+33RZjEizIYAfmaDDEL0vTSSwxrqT8p+ck0LcIymSLumoRT2+1hEmRSuqguT
  38258. aaApJUqlyyvdimYHFngVV3Eb7PVHhPOeMTd61X8kreS8/f3MboPoDKi3QWwH3b08hpcv0g==
  38259. -----END CERTIFICATE-----
  38260. TrustCor RootCert CA-1
  38261. ======================
  38262. -----BEGIN CERTIFICATE-----
  38263. MIIEMDCCAxigAwIBAgIJANqb7HHzA7AZMA0GCSqGSIb3DQEBCwUAMIGkMQswCQYDVQQGEwJQQTEP
  38264. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  38265. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  38266. dHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0IENBLTEwHhcNMTYwMjA0MTIzMjE2WhcNMjkx
  38267. MjMxMTcyMzE2WjCBpDELMAkGA1UEBhMCUEExDzANBgNVBAgMBlBhbmFtYTEUMBIGA1UEBwwLUGFu
  38268. YW1hIENpdHkxJDAiBgNVBAoMG1RydXN0Q29yIFN5c3RlbXMgUy4gZGUgUi5MLjEnMCUGA1UECwwe
  38269. VHJ1c3RDb3IgQ2VydGlmaWNhdGUgQXV0aG9yaXR5MR8wHQYDVQQDDBZUcnVzdENvciBSb290Q2Vy
  38270. dCBDQS0xMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv463leLCJhJrMxnHQFgKq1mq
  38271. jQCj/IDHUHuO1CAmujIS2CNUSSUQIpidRtLByZ5OGy4sDjjzGiVoHKZaBeYei0i/mJZ0PmnK6bV4
  38272. pQa81QBeCQryJ3pS/C3Vseq0iWEk8xoT26nPUu0MJLq5nux+AHT6k61sKZKuUbS701e/s/OojZz0
  38273. JEsq1pme9J7+wH5COucLlVPat2gOkEz7cD+PSiyU8ybdY2mplNgQTsVHCJCZGxdNuWxu72CVEY4h
  38274. gLW9oHPY0LJ3xEXqWib7ZnZ2+AYfYW0PVcWDtxBWcgYHpfOxGgMFZA6dWorWhnAbJN7+KIor0Gqw
  38275. /Hqi3LJ5DotlDwIDAQABo2MwYTAdBgNVHQ4EFgQU7mtJPHo/DeOxCbeKyKsZn3MzUOcwHwYDVR0j
  38276. BBgwFoAU7mtJPHo/DeOxCbeKyKsZn3MzUOcwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMC
  38277. AYYwDQYJKoZIhvcNAQELBQADggEBACUY1JGPE+6PHh0RU9otRCkZoB5rMZ5NDp6tPVxBb5UrJKF5
  38278. mDo4Nvu7Zp5I/5CQ7z3UuJu0h3U/IJvOcs+hVcFNZKIZBqEHMwwLKeXx6quj7LUKdJDHfXLy11yf
  38279. ke+Ri7fc7Waiz45mO7yfOgLgJ90WmMCV1Aqk5IGadZQ1nJBfiDcGrVmVCrDRZ9MZyonnMlo2HD6C
  38280. qFqTvsbQZJG2z9m2GM/bftJlo6bEjhcxwft+dtvTheNYsnd6djtsL1Ac59v2Z3kf9YKVmgenFK+P
  38281. 3CghZwnS1k1aHBkcjndcw5QkPTJrS37UeJSDvjdNzl/HHk484IkzlQsPpTLWPFp5LBk=
  38282. -----END CERTIFICATE-----
  38283. TrustCor RootCert CA-2
  38284. ======================
  38285. -----BEGIN CERTIFICATE-----
  38286. MIIGLzCCBBegAwIBAgIIJaHfyjPLWQIwDQYJKoZIhvcNAQELBQAwgaQxCzAJBgNVBAYTAlBBMQ8w
  38287. DQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5MSQwIgYDVQQKDBtUcnVzdENvciBT
  38288. eXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29yIENlcnRpZmljYXRlIEF1dGhvcml0
  38289. eTEfMB0GA1UEAwwWVHJ1c3RDb3IgUm9vdENlcnQgQ0EtMjAeFw0xNjAyMDQxMjMyMjNaFw0zNDEy
  38290. MzExNzI2MzlaMIGkMQswCQYDVQQGEwJQQTEPMA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5h
  38291. bWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3IgU3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5U
  38292. cnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkxHzAdBgNVBAMMFlRydXN0Q29yIFJvb3RDZXJ0
  38293. IENBLTIwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCnIG7CKqJiJJWQdsg4foDSq8Gb
  38294. ZQWU9MEKENUCrO2fk8eHyLAnK0IMPQo+QVqedd2NyuCb7GgypGmSaIwLgQ5WoD4a3SwlFIIvl9Nk
  38295. RvRUqdw6VC0xK5mC8tkq1+9xALgxpL56JAfDQiDyitSSBBtlVkxs1Pu2YVpHI7TYabS3OtB0PAx1
  38296. oYxOdqHp2yqlO/rOsP9+aij9JxzIsekp8VduZLTQwRVtDr4uDkbIXvRR/u8OYzo7cbrPb1nKDOOb
  38297. XUm4TOJXsZiKQlecdu/vvdFoqNL0Cbt3Nb4lggjEFixEIFapRBF37120Hapeaz6LMvYHL1cEksr1
  38298. /p3C6eizjkxLAjHZ5DxIgif3GIJ2SDpxsROhOdUuxTTCHWKF3wP+TfSvPd9cW436cOGlfifHhi5q
  38299. jxLGhF5DUVCcGZt45vz27Ud+ez1m7xMTiF88oWP7+ayHNZ/zgp6kPwqcMWmLmaSISo5uZk3vFsQP
  38300. eSghYA2FFn3XVDjxklb9tTNMg9zXEJ9L/cb4Qr26fHMC4P99zVvh1Kxhe1fVSntb1IVYJ12/+Ctg
  38301. rKAmrhQhJ8Z3mjOAPF5GP/fDsaOGM8boXg25NSyqRsGFAnWAoOsk+xWq5Gd/bnc/9ASKL3x74xdh
  38302. 8N0JqSDIvgmk0H5Ew7IwSjiqqewYmgeCK9u4nBit2uBGF6zPXQIDAQABo2MwYTAdBgNVHQ4EFgQU
  38303. 2f4hQG6UnrybPZx9mCAZ5YwwYrIwHwYDVR0jBBgwFoAU2f4hQG6UnrybPZx9mCAZ5YwwYrIwDwYD
  38304. VR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQELBQADggIBAJ5Fngw7tu/h
  38305. Osh80QA9z+LqBrWyOrsGS2h60COXdKcs8AjYeVrXWoSK2BKaG9l9XE1wxaX5q+WjiYndAfrs3fnp
  38306. kpfbsEZC89NiqpX+MWcUaViQCqoL7jcjx1BRtPV+nuN79+TMQjItSQzL/0kMmx40/W5ulop5A7Zv
  38307. 2wnL/V9lFDfhOPXzYRZY5LVtDQsEGz9QLX+zx3oaFoBg+Iof6Rsqxvm6ARppv9JYx1RXCI/hOWB3
  38308. S6xZhBqI8d3LT3jX5+EzLfzuQfogsL7L9ziUwOHQhQ+77Sxzq+3+knYaZH9bDTMJBzN7Bj8RpFxw
  38309. PIXAz+OQqIN3+tvmxYxoZxBnpVIt8MSZj3+/0WvitUfW2dCFmU2Umw9Lje4AWkcdEQOsQRivh7dv
  38310. DDqPys/cA8GiCcjl/YBeyGBCARsaU1q7N6a3vLqE6R5sGtRk2tRD/pOLS/IseRYQ1JMLiI+h2IYU
  38311. RpFHmygk71dSTlxCnKr3Sewn6EAes6aJInKc9Q0ztFijMDvd1GpUk74aTfOTlPf8hAs/hCBcNANE
  38312. xdqtvArBAs8e5ZTZ845b2EzwnexhF7sUMlQMAimTHpKG9n/v55IFDlndmQguLvqcAFLTxWYp5KeX
  38313. RKQOKIETNcX2b2TmQcTVL8w0RSXPQQCWPUouwpaYT05KnJe32x+SMsj/D1Fu1uwJ
  38314. -----END CERTIFICATE-----
  38315. TrustCor ECA-1
  38316. ==============
  38317. -----BEGIN CERTIFICATE-----
  38318. MIIEIDCCAwigAwIBAgIJAISCLF8cYtBAMA0GCSqGSIb3DQEBCwUAMIGcMQswCQYDVQQGEwJQQTEP
  38319. MA0GA1UECAwGUGFuYW1hMRQwEgYDVQQHDAtQYW5hbWEgQ2l0eTEkMCIGA1UECgwbVHJ1c3RDb3Ig
  38320. U3lzdGVtcyBTLiBkZSBSLkwuMScwJQYDVQQLDB5UcnVzdENvciBDZXJ0aWZpY2F0ZSBBdXRob3Jp
  38321. dHkxFzAVBgNVBAMMDlRydXN0Q29yIEVDQS0xMB4XDTE2MDIwNDEyMzIzM1oXDTI5MTIzMTE3Mjgw
  38322. N1owgZwxCzAJBgNVBAYTAlBBMQ8wDQYDVQQIDAZQYW5hbWExFDASBgNVBAcMC1BhbmFtYSBDaXR5
  38323. MSQwIgYDVQQKDBtUcnVzdENvciBTeXN0ZW1zIFMuIGRlIFIuTC4xJzAlBgNVBAsMHlRydXN0Q29y
  38324. IENlcnRpZmljYXRlIEF1dGhvcml0eTEXMBUGA1UEAwwOVHJ1c3RDb3IgRUNBLTEwggEiMA0GCSqG
  38325. SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDPj+ARtZ+odnbb3w9U73NjKYKtR8aja+3+XzP4Q1HpGjOR
  38326. MRegdMTUpwHmspI+ap3tDvl0mEDTPwOABoJA6LHip1GnHYMma6ve+heRK9jGrB6xnhkB1Zem6g23
  38327. xFUfJ3zSCNV2HykVh0A53ThFEXXQmqc04L/NyFIduUd+Dbi7xgz2c1cWWn5DkR9VOsZtRASqnKmc
  38328. p0yJF4OuowReUoCLHhIlERnXDH19MURB6tuvsBzvgdAsxZohmz3tQjtQJvLsznFhBmIhVE5/wZ0+
  38329. fyCMgMsq2JdiyIMzkX2woloPV+g7zPIlstR8L+xNxqE6FXrntl019fZISjZFZtS6mFjBAgMBAAGj
  38330. YzBhMB0GA1UdDgQWBBREnkj1zG1I1KBLf/5ZJC+Dl5mahjAfBgNVHSMEGDAWgBREnkj1zG1I1KBL
  38331. f/5ZJC+Dl5mahjAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBhjANBgkqhkiG9w0BAQsF
  38332. AAOCAQEABT41XBVwm8nHc2FvcivUwo/yQ10CzsSUuZQRg2dd4mdsdXa/uwyqNsatR5Nj3B5+1t4u
  38333. /ukZMjgDfxT2AHMsWbEhBuH7rBiVDKP/mZb3Kyeb1STMHd3BOuCYRLDE5D53sXOpZCz2HAF8P11F
  38334. hcCF5yWPldwX8zyfGm6wyuMdKulMY/okYWLW2n62HGz1Ah3UKt1VkOsqEUc8Ll50soIipX1TH0Xs
  38335. J5F95yIW6MBoNtjG8U+ARDL54dHRHareqKucBK+tIA5kmE2la8BIWJZpTdwHjFGTot+fDz2LYLSC
  38336. jaoITmJF4PkL0uDgPFveXHEnJcLmA4GLEFPjx1WitJ/X5g==
  38337. -----END CERTIFICATE-----
  38338. SSL.com Root Certification Authority RSA
  38339. ========================================
  38340. -----BEGIN CERTIFICATE-----
  38341. MIIF3TCCA8WgAwIBAgIIeyyb0xaAMpkwDQYJKoZIhvcNAQELBQAwfDELMAkGA1UEBhMCVVMxDjAM
  38342. BgNVBAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24x
  38343. MTAvBgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBSU0EwHhcNMTYw
  38344. MjEyMTczOTM5WhcNNDEwMjEyMTczOTM5WjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  38345. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NM
  38346. LmNvbSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IFJTQTCCAiIwDQYJKoZIhvcNAQEBBQAD
  38347. ggIPADCCAgoCggIBAPkP3aMrfcvQKv7sZ4Wm5y4bunfh4/WvpOz6Sl2RxFdHaxh3a3by/ZPkPQ/C
  38348. Fp4LZsNWlJ4Xg4XOVu/yFv0AYvUiCVToZRdOQbngT0aXqhvIuG5iXmmxX9sqAn78bMrzQdjt0Oj8
  38349. P2FI7bADFB0QDksZ4LtO7IZl/zbzXmcCC52GVWH9ejjt/uIZALdvoVBidXQ8oPrIJZK0bnoix/ge
  38350. oeOy3ZExqysdBP+lSgQ36YWkMyv94tZVNHwZpEpox7Ko07fKoZOI68GXvIz5HdkihCR0xwQ9aqkp
  38351. k8zruFvh/l8lqjRYyMEjVJ0bmBHDOJx+PYZspQ9AhnwC9FwCTyjLrnGfDzrIM/4RJTXq/LrFYD3Z
  38352. fBjVsqnTdXgDciLKOsMf7yzlLqn6niy2UUb9rwPW6mBo6oUWNmuF6R7As93EJNyAKoFBbZQ+yODJ
  38353. gUEAnl6/f8UImKIYLEJAs/lvOCdLToD0PYFH4Ih86hzOtXVcUS4cK38acijnALXRdMbX5J+tB5O2
  38354. UzU1/Dfkw/ZdFr4hc96SCvigY2q8lpJqPvi8ZVWb3vUNiSYE/CUapiVpy8JtynziWV+XrOvvLsi8
  38355. 1xtZPCvM8hnIk2snYxnP/Okm+Mpxm3+T/jRnhE6Z6/yzeAkzcLpmpnbtG3PrGqUNxCITIJRWCk4s
  38356. bE6x/c+cCbqiM+2HAgMBAAGjYzBhMB0GA1UdDgQWBBTdBAkHovV6fVJTEpKV7jiAJQ2mWTAPBgNV
  38357. HRMBAf8EBTADAQH/MB8GA1UdIwQYMBaAFN0ECQei9Xp9UlMSkpXuOIAlDaZZMA4GA1UdDwEB/wQE
  38358. AwIBhjANBgkqhkiG9w0BAQsFAAOCAgEAIBgRlCn7Jp0cHh5wYfGVcpNxJK1ok1iOMq8bs3AD/CUr
  38359. dIWQPXhq9LmLpZc7tRiRux6n+UBbkflVma8eEdBcHadm47GUBwwyOabqG7B52B2ccETjit3E+ZUf
  38360. ijhDPwGFpUenPUayvOUiaPd7nNgsPgohyC0zrL/FgZkxdMF1ccW+sfAjRfSda/wZY52jvATGGAsl
  38361. u1OJD7OAUN5F7kR/q5R4ZJjT9ijdh9hwZXT7DrkT66cPYakylszeu+1jTBi7qUD3oFRuIIhxdRjq
  38362. erQ0cuAjJ3dctpDqhiVAq+8zD8ufgr6iIPv2tS0a5sKFsXQP+8hlAqRSAUfdSSLBv9jra6x+3uxj
  38363. MxW3IwiPxg+NQVrdjsW5j+VFP3jbutIbQLH+cU0/4IGiul607BXgk90IH37hVZkLId6Tngr75qNJ
  38364. vTYw/ud3sqB1l7UtgYgXZSD32pAAn8lSzDLKNXz1PQ/YK9f1JmzJBjSWFupwWRoyeXkLtoh/D1JI
  38365. Pb9s2KJELtFOt3JY04kTlf5Eq/jXixtunLwsoFvVagCvXzfh1foQC5ichucmj87w7G6KVwuA406y
  38366. wKBjYZC6VWg3dGq2ktufoYYitmUnDuy2n0Jg5GfCtdpBC8TTi2EbvPofkSvXRAdeuims2cXp71NI
  38367. WuuA8ShYIc2wBlX7Jz9TkHCpBB5XJ7k=
  38368. -----END CERTIFICATE-----
  38369. SSL.com Root Certification Authority ECC
  38370. ========================================
  38371. -----BEGIN CERTIFICATE-----
  38372. MIICjTCCAhSgAwIBAgIIdebfy8FoW6gwCgYIKoZIzj0EAwIwfDELMAkGA1UEBhMCVVMxDjAMBgNV
  38373. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xMTAv
  38374. BgNVBAMMKFNTTC5jb20gUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYwMjEy
  38375. MTgxNDAzWhcNNDEwMjEyMTgxNDAzWjB8MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMxEDAO
  38376. BgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjExMC8GA1UEAwwoU1NMLmNv
  38377. bSBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuBBAAiA2IA
  38378. BEVuqVDEpiM2nl8ojRfLliJkP9x6jh3MCLOicSS6jkm5BBtHllirLZXI7Z4INcgn64mMU1jrYor+
  38379. 8FsPazFSY0E7ic3s7LaNGdM0B9y7xgZ/wkWV7Mt/qCPgCemB+vNH06NjMGEwHQYDVR0OBBYEFILR
  38380. hXMw5zUE044CkvvlpNHEIejNMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUgtGFczDnNQTT
  38381. jgKS++Wk0cQh6M0wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2cAMGQCMG/n61kRpGDPYbCW
  38382. e+0F+S8Tkdzt5fxQaxFGRrMcIQBiu77D5+jNB5n5DQtdcj7EqgIwH7y6C+IwJPt8bYBVCpk+gA0z
  38383. 5Wajs6O7pdWLjwkspl1+4vAHCGht0nxpbl/f5Wpl
  38384. -----END CERTIFICATE-----
  38385. SSL.com EV Root Certification Authority RSA R2
  38386. ==============================================
  38387. -----BEGIN CERTIFICATE-----
  38388. MIIF6zCCA9OgAwIBAgIIVrYpzTS8ePYwDQYJKoZIhvcNAQELBQAwgYIxCzAJBgNVBAYTAlVTMQ4w
  38389. DAYDVQQIDAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9u
  38390. MTcwNQYDVQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIy
  38391. MB4XDTE3MDUzMTE4MTQzN1oXDTQyMDUzMDE4MTQzN1owgYIxCzAJBgNVBAYTAlVTMQ4wDAYDVQQI
  38392. DAVUZXhhczEQMA4GA1UEBwwHSG91c3RvbjEYMBYGA1UECgwPU1NMIENvcnBvcmF0aW9uMTcwNQYD
  38393. VQQDDC5TU0wuY29tIEVWIFJvb3QgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgUlNBIFIyMIICIjAN
  38394. BgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjzZlQOHWTcDXtOlG2mvqM0fNTPl9fb69LT3w23jh
  38395. hqXZuglXaO1XPqDQCEGD5yhBJB/jchXQARr7XnAjssufOePPxU7Gkm0mxnu7s9onnQqG6YE3Bf7w
  38396. cXHswxzpY6IXFJ3vG2fThVUCAtZJycxa4bH3bzKfydQ7iEGonL3Lq9ttewkfokxykNorCPzPPFTO
  38397. Zw+oz12WGQvE43LrrdF9HSfvkusQv1vrO6/PgN3B0pYEW3p+pKk8OHakYo6gOV7qd89dAFmPZiw+
  38398. B6KjBSYRaZfqhbcPlgtLyEDhULouisv3D5oi53+aNxPN8k0TayHRwMwi8qFG9kRpnMphNQcAb9Zh
  38399. CBHqurj26bNg5U257J8UZslXWNvNh2n4ioYSA0e/ZhN2rHd9NCSFg83XqpyQGp8hLH94t2S42Oim
  38400. 9HizVcuE0jLEeK6jj2HdzghTreyI/BXkmg3mnxp3zkyPuBQVPWKchjgGAGYS5Fl2WlPAApiiECto
  38401. RHuOec4zSnaqW4EWG7WK2NAAe15itAnWhmMOpgWVSbooi4iTsjQc2KRVbrcc0N6ZVTsj9CLg+Slm
  38402. JuwgUHfbSguPvuUCYHBBXtSuUDkiFCbLsjtzdFVHB3mBOagwE0TlBIqulhMlQg+5U8Sb/M3kHN48
  38403. +qvWBkofZ6aYMBzdLNvcGJVXZsb/XItW9XcCAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAfBgNV
  38404. HSMEGDAWgBT5YLvU49U09rj1BoAlp3PbRmmonjAdBgNVHQ4EFgQU+WC71OPVNPa49QaAJadz20Zp
  38405. qJ4wDgYDVR0PAQH/BAQDAgGGMA0GCSqGSIb3DQEBCwUAA4ICAQBWs47LCp1Jjr+kxJG7ZhcFUZh1
  38406. ++VQLHqe8RT6q9OKPv+RKY9ji9i0qVQBDb6Thi/5Sm3HXvVX+cpVHBK+Rw82xd9qt9t1wkclf7nx
  38407. Y/hoLVUE0fKNsKTPvDxeH3jnpaAgcLAExbf3cqfeIg29MyVGjGSSJuM+LmOW2puMPfgYCdcDzH2G
  38408. guDKBAdRUNf/ktUM79qGn5nX67evaOI5JpS6aLe/g9Pqemc9YmeuJeVy6OLk7K4S9ksrPJ/psEDz
  38409. OFSz/bdoyNrGj1E8svuR3Bznm53htw1yj+KkxKl4+esUrMZDBcJlOSgYAsOCsp0FvmXtll9ldDz7
  38410. CTUue5wT/RsPXcdtgTpWD8w74a8CLyKsRspGPKAcTNZEtF4uXBVmCeEmKf7GUmG6sXP/wwyc5Wxq
  38411. lD8UykAWlYTzWamsX0xhk23RO8yilQwipmdnRC652dKKQbNmC1r7fSOl8hqw/96bg5Qu0T/fkreR
  38412. rwU7ZcegbLHNYhLDkBvjJc40vG93drEQw/cFGsDWr3RiSBd3kmmQYRzelYB0VI8YHMPzA9C/pEN1
  38413. hlMYegouCRw2n5H9gooiS9EOUCXdywMMF8mDAAhONU2Ki+3wApRmLER/y5UnlhetCTCstnEXbosX
  38414. 9hwJ1C07mKVx01QT2WDz9UtmT/rx7iASjbSsV7FFY6GsdqnC+w==
  38415. -----END CERTIFICATE-----
  38416. SSL.com EV Root Certification Authority ECC
  38417. ===========================================
  38418. -----BEGIN CERTIFICATE-----
  38419. MIIClDCCAhqgAwIBAgIILCmcWxbtBZUwCgYIKoZIzj0EAwIwfzELMAkGA1UEBhMCVVMxDjAMBgNV
  38420. BAgMBVRleGFzMRAwDgYDVQQHDAdIb3VzdG9uMRgwFgYDVQQKDA9TU0wgQ29ycG9yYXRpb24xNDAy
  38421. BgNVBAMMK1NTTC5jb20gRVYgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSBFQ0MwHhcNMTYw
  38422. MjEyMTgxNTIzWhcNNDEwMjEyMTgxNTIzWjB/MQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVGV4YXMx
  38423. EDAOBgNVBAcMB0hvdXN0b24xGDAWBgNVBAoMD1NTTCBDb3Jwb3JhdGlvbjE0MDIGA1UEAwwrU1NM
  38424. LmNvbSBFViBSb290IENlcnRpZmljYXRpb24gQXV0aG9yaXR5IEVDQzB2MBAGByqGSM49AgEGBSuB
  38425. BAAiA2IABKoSR5CYG/vvw0AHgyBO8TCCogbR8pKGYfL2IWjKAMTH6kMAVIbc/R/fALhBYlzccBYy
  38426. 3h+Z1MzFB8gIH2EWB1E9fVwHU+M1OIzfzZ/ZLg1KthkuWnBaBu2+8KGwytAJKaNjMGEwHQYDVR0O
  38427. BBYEFFvKXuXe0oGqzagtZFG22XKbl+ZPMA8GA1UdEwEB/wQFMAMBAf8wHwYDVR0jBBgwFoAUW8pe
  38428. 5d7SgarNqC1kUbbZcpuX5k8wDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMCA2gAMGUCMQCK5kCJ
  38429. N+vp1RPZytRrJPOwPYdGWBrssd9v+1a6cGvHOMzosYxPD/fxZ3YOg9AeUY8CMD32IygmTMZgh5Mm
  38430. m7I1HrrW9zzRHM76JTymGoEVW/MSD2zuZYrJh6j5B+BimoxcSg==
  38431. -----END CERTIFICATE-----
  38432. GlobalSign Root CA - R6
  38433. =======================
  38434. -----BEGIN CERTIFICATE-----
  38435. MIIFgzCCA2ugAwIBAgIORea7A4Mzw4VlSOb/RVEwDQYJKoZIhvcNAQEMBQAwTDEgMB4GA1UECxMX
  38436. R2xvYmFsU2lnbiBSb290IENBIC0gUjYxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkds
  38437. b2JhbFNpZ24wHhcNMTQxMjEwMDAwMDAwWhcNMzQxMjEwMDAwMDAwWjBMMSAwHgYDVQQLExdHbG9i
  38438. YWxTaWduIFJvb3QgQ0EgLSBSNjETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UEAxMKR2xvYmFs
  38439. U2lnbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAJUH6HPKZvnsFMp7PPcNCPG0RQss
  38440. grRIxutbPK6DuEGSMxSkb3/pKszGsIhrxbaJ0cay/xTOURQh7ErdG1rG1ofuTToVBu1kZguSgMpE
  38441. 3nOUTvOniX9PeGMIyBJQbUJmL025eShNUhqKGoC3GYEOfsSKvGRMIRxDaNc9PIrFsmbVkJq3MQbF
  38442. vuJtMgamHvm566qjuL++gmNQ0PAYid/kD3n16qIfKtJwLnvnvJO7bVPiSHyMEAc4/2ayd2F+4OqM
  38443. PKq0pPbzlUoSB239jLKJz9CgYXfIWHSw1CM69106yqLbnQneXUQtkPGBzVeS+n68UARjNN9rkxi+
  38444. azayOeSsJDa38O+2HBNXk7besvjihbdzorg1qkXy4J02oW9UivFyVm4uiMVRQkQVlO6jxTiWm05O
  38445. WgtH8wY2SXcwvHE35absIQh1/OZhFj931dmRl4QKbNQCTXTAFO39OfuD8l4UoQSwC+n+7o/hbguy
  38446. CLNhZglqsQY6ZZZZwPA1/cnaKI0aEYdwgQqomnUdnjqGBQCe24DWJfncBZ4nWUx2OVvq+aWh2IMP
  38447. 0f/fMBH5hc8zSPXKbWQULHpYT9NLCEnFlWQaYw55PfWzjMpYrZxCRXluDocZXFSxZba/jJvcE+kN
  38448. b7gu3GduyYsRtYQUigAZcIN5kZeR1BonvzceMgfYFGM8KEyvAgMBAAGjYzBhMA4GA1UdDwEB/wQE
  38449. AwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSubAWjkxPioufi1xzWx/B/yGdToDAfBgNV
  38450. HSMEGDAWgBSubAWjkxPioufi1xzWx/B/yGdToDANBgkqhkiG9w0BAQwFAAOCAgEAgyXt6NH9lVLN
  38451. nsAEoJFp5lzQhN7craJP6Ed41mWYqVuoPId8AorRbrcWc+ZfwFSY1XS+wc3iEZGtIxg93eFyRJa0
  38452. lV7Ae46ZeBZDE1ZXs6KzO7V33EByrKPrmzU+sQghoefEQzd5Mr6155wsTLxDKZmOMNOsIeDjHfrY
  38453. BzN2VAAiKrlNIC5waNrlU/yDXNOd8v9EDERm8tLjvUYAGm0CuiVdjaExUd1URhxN25mW7xocBFym
  38454. Fe944Hn+Xds+qkxV/ZoVqW/hpvvfcDDpw+5CRu3CkwWJ+n1jez/QcYF8AOiYrg54NMMl+68KnyBr
  38455. 3TsTjxKM4kEaSHpzoHdpx7Zcf4LIHv5YGygrqGytXm3ABdJ7t+uA/iU3/gKbaKxCXcPu9czc8FB1
  38456. 0jZpnOZ7BN9uBmm23goJSFmH63sUYHpkqmlD75HHTOwY3WzvUy2MmeFe8nI+z1TIvWfspA9MRf/T
  38457. uTAjB0yPEL+GltmZWrSZVxykzLsViVO6LAUP5MSeGbEYNNVMnbrt9x+vJJUEeKgDu+6B5dpffItK
  38458. oZB0JaezPkvILFa9x8jvOOJckvB595yEunQtYQEgfn7R8k8HWV+LLUNS60YMlOH1Zkd5d9VUWx+t
  38459. JDfLRVpOoERIyNiwmcUVhAn21klJwGW45hpxbqCo8YLoRT5s1gLXCmeDBVrJpBA=
  38460. -----END CERTIFICATE-----
  38461. OISTE WISeKey Global Root GC CA
  38462. ===============================
  38463. -----BEGIN CERTIFICATE-----
  38464. MIICaTCCAe+gAwIBAgIQISpWDK7aDKtARb8roi066jAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJD
  38465. SDEQMA4GA1UEChMHV0lTZUtleTEiMCAGA1UECxMZT0lTVEUgRm91bmRhdGlvbiBFbmRvcnNlZDEo
  38466. MCYGA1UEAxMfT0lTVEUgV0lTZUtleSBHbG9iYWwgUm9vdCBHQyBDQTAeFw0xNzA1MDkwOTQ4MzRa
  38467. Fw00MjA1MDkwOTU4MzNaMG0xCzAJBgNVBAYTAkNIMRAwDgYDVQQKEwdXSVNlS2V5MSIwIAYDVQQL
  38468. ExlPSVNURSBGb3VuZGF0aW9uIEVuZG9yc2VkMSgwJgYDVQQDEx9PSVNURSBXSVNlS2V5IEdsb2Jh
  38469. bCBSb290IEdDIENBMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAETOlQwMYPchi82PG6s4nieUqjFqdr
  38470. VCTbUf/q9Akkwwsin8tqJ4KBDdLArzHkdIJuyiXZjHWd8dvQmqJLIX4Wp2OQ0jnUsYd4XxiWD1Ab
  38471. NTcPasbc2RNNpI6QN+a9WzGRo1QwUjAOBgNVHQ8BAf8EBAMCAQYwDwYDVR0TAQH/BAUwAwEB/zAd
  38472. BgNVHQ4EFgQUSIcUrOPDnpBgOtfKie7TrYy0UGYwEAYJKwYBBAGCNxUBBAMCAQAwCgYIKoZIzj0E
  38473. AwMDaAAwZQIwJsdpW9zV57LnyAyMjMPdeYwbY9XJUpROTYJKcx6ygISpJcBMWm1JKWB4E+J+SOtk
  38474. AjEA2zQgMgj/mkkCtojeFK9dbJlxjRo/i9fgojaGHAeCOnZT/cKi7e97sIBPWA9LUzm9
  38475. -----END CERTIFICATE-----
  38476. GTS Root R1
  38477. ===========
  38478. -----BEGIN CERTIFICATE-----
  38479. MIIFWjCCA0KgAwIBAgIQbkepxUtHDA3sM9CJuRz04TANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  38480. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  38481. b3QgUjEwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  38482. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjEwggIi
  38483. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQC2EQKLHuOhd5s73L+UPreVp0A8of2C+X0yBoJx
  38484. 9vaMf/vo27xqLpeXo4xL+Sv2sfnOhB2x+cWX3u+58qPpvBKJXqeqUqv4IyfLpLGcY9vXmX7wCl7r
  38485. aKb0xlpHDU0QM+NOsROjyBhsS+z8CZDfnWQpJSMHobTSPS5g4M/SCYe7zUjwTcLCeoiKu7rPWRnW
  38486. r4+wB7CeMfGCwcDfLqZtbBkOtdh+JhpFAz2weaSUKK0PfyblqAj+lug8aJRT7oM6iCsVlgmy4HqM
  38487. LnXWnOunVmSPlk9orj2XwoSPwLxAwAtcvfaHszVsrBhQf4TgTM2S0yDpM7xSma8ytSmzJSq0SPly
  38488. 4cpk9+aCEI3oncKKiPo4Zor8Y/kB+Xj9e1x3+naH+uzfsQ55lVe0vSbv1gHR6xYKu44LtcXFilWr
  38489. 06zqkUspzBmkMiVOKvFlRNACzqrOSbTqn3yDsEB750Orp2yjj32JgfpMpf/VjsPOS+C12LOORc92
  38490. wO1AK/1TD7Cn1TsNsYqiA94xrcx36m97PtbfkSIS5r762DL8EGMUUXLeXdYWk70paDPvOmbsB4om
  38491. 3xPXV2V4J95eSRQAogB/mqghtqmxlbCluQ0WEdrHbEg8QOB+DVrNVjzRlwW5y0vtOUucxD/SVRNu
  38492. JLDWcfr0wbrM7Rv1/oFB2ACYPTrIrnqYNxgFlQIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  38493. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQU5K8rJnEaK0gnhS9SZizv8IkTcT4wDQYJKoZIhvcNAQEM
  38494. BQADggIBADiWCu49tJYeX++dnAsznyvgyv3SjgofQXSlfKqE1OXyHuY3UjKcC9FhHb8owbZEKTV1
  38495. d5iyfNm9dKyKaOOpMQkpAWBz40d8U6iQSifvS9efk+eCNs6aaAyC58/UEBZvXw6ZXPYfcX3v73sv
  38496. fuo21pdwCxXu11xWajOl40k4DLh9+42FpLFZXvRq4d2h9mREruZRgyFmxhE+885H7pwoHyXa/6xm
  38497. ld01D1zvICxi/ZG6qcz8WpyTgYMpl0p8WnK0OdC3d8t5/Wk6kjftbjhlRn7pYL15iJdfOBL07q9b
  38498. gsiG1eGZbYwE8na6SfZu6W0eX6DvJ4J2QPim01hcDyxC2kLGe4g0x8HYRZvBPsVhHdljUEn2NIVq
  38499. 4BjFbkerQUIpm/ZgDdIx02OYI5NaAIFItO/Nis3Jz5nu2Z6qNuFoS3FJFDYoOj0dzpqPJeaAcWEr
  38500. tXvM+SUWgeExX6GjfhaknBZqlxi9dnKlC54dNuYvoS++cJEPqOba+MSSQGwlfnuzCdyyF62ARPBo
  38501. pY+Udf90WuioAnwMCeKpSwughQtiue+hMZL77/ZRBIls6Kl0obsXs7X9SQ98POyDGCBDTtWTurQ0
  38502. sR8WNh8M5mQ5Fkzc4P4dyKliPUDqysU0ArSuiYgzNdwsE3PYJ/HQcu51OyLemGhmW/HGY0dVHLql
  38503. CFF1pkgl
  38504. -----END CERTIFICATE-----
  38505. GTS Root R2
  38506. ===========
  38507. -----BEGIN CERTIFICATE-----
  38508. MIIFWjCCA0KgAwIBAgIQbkepxlqz5yDFMJo/aFLybzANBgkqhkiG9w0BAQwFADBHMQswCQYDVQQG
  38509. EwJVUzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJv
  38510. b3QgUjIwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAG
  38511. A1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjIwggIi
  38512. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDO3v2m++zsFDQ8BwZabFn3GTXd98GdVarTzTuk
  38513. k3LvCvptnfbwhYBboUhSnznFt+4orO/LdmgUud+tAWyZH8QiHZ/+cnfgLFuv5AS/T3KgGjSY6Dlo
  38514. 7JUle3ah5mm5hRm9iYz+re026nO8/4Piy33B0s5Ks40FnotJk9/BW9BuXvAuMC6C/Pq8tBcKSOWI
  38515. m8Wba96wyrQD8Nr0kLhlZPdcTK3ofmZemde4wj7I0BOdre7kRXuJVfeKH2JShBKzwkCX44ofR5Gm
  38516. dFrS+LFjKBC4swm4VndAoiaYecb+3yXuPuWgf9RhD1FLPD+M2uFwdNjCaKH5wQzpoeJ/u1U8dgbu
  38517. ak7MkogwTZq9TwtImoS1mKPV+3PBV2HdKFZ1E66HjucMUQkQdYhMvI35ezzUIkgfKtzra7tEscsz
  38518. cTJGr61K8YzodDqs5xoic4DSMPclQsciOzsSrZYuxsN2B6ogtzVJV+mSSeh2FnIxZyuWfoqjx5RW
  38519. Ir9qS34BIbIjMt/kmkRtWVtd9QCgHJvGeJeNkP+byKq0rxFROV7Z+2et1VsRnTKaG73Vululycsl
  38520. aVNVJ1zgyjbLiGH7HrfQy+4W+9OmTN6SpdTi3/UGVN4unUu0kzCqgc7dGtxRcw1PcOnlthYhGXmy
  38521. 5okLdWTK1au8CcEYof/UVKGFPP0UJAOyh9OktwIDAQABo0IwQDAOBgNVHQ8BAf8EBAMCAQYwDwYD
  38522. VR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUu//KjiOfT5nK2+JopqUVJxce2Q4wDQYJKoZIhvcNAQEM
  38523. BQADggIBALZp8KZ3/p7uC4Gt4cCpx/k1HUCCq+YEtN/L9x0Pg/B+E02NjO7jMyLDOfxA325BS0JT
  38524. vhaI8dI4XsRomRyYUpOM52jtG2pzegVATX9lO9ZY8c6DR2Dj/5epnGB3GFW1fgiTz9D2PGcDFWEJ
  38525. +YF59exTpJ/JjwGLc8R3dtyDovUMSRqodt6Sm2T4syzFJ9MHwAiApJiS4wGWAqoC7o87xdFtCjMw
  38526. c3i5T1QWvwsHoaRc5svJXISPD+AVdyx+Jn7axEvbpxZ3B7DNdehyQtaVhJ2Gg/LkkM0JR9SLA3Da
  38527. WsYDQvTtN6LwG1BUSw7YhN4ZKJmBR64JGz9I0cNv4rBgF/XuIwKl2gBbbZCr7qLpGzvpx0QnRY5r
  38528. n/WkhLx3+WuXrD5RRaIRpsyF7gpo8j5QOHokYh4XIDdtak23CZvJ/KRY9bb7nE4Yu5UC56Gtmwfu
  38529. Nmsk0jmGwZODUNKBRqhfYlcsu2xkiAhu7xNUX90txGdj08+JN7+dIPT7eoOboB6BAFDC5AwiWVIQ
  38530. 7UNWhwD4FFKnHYuTjKJNRn8nxnGbJN7k2oaLDX5rIMHAnuFl2GqjpuiFizoHCBy69Y9Vmhh1fuXs
  38531. gWbRIXOhNUQLgD1bnF5vKheW0YMjiGZt5obicDIvUiLnyOd/xCxgXS/Dr55FBcOEArf9LAhST4Ld
  38532. o/DUhgkC
  38533. -----END CERTIFICATE-----
  38534. GTS Root R3
  38535. ===========
  38536. -----BEGIN CERTIFICATE-----
  38537. MIICDDCCAZGgAwIBAgIQbkepx2ypcyRAiQ8DVd2NHTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  38538. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  38539. UjMwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  38540. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjMwdjAQBgcq
  38541. hkjOPQIBBgUrgQQAIgNiAAQfTzOHMymKoYTey8chWEGJ6ladK0uFxh1MJ7x/JlFyb+Kf1qPKzEUU
  38542. Rout736GjOyxfi//qXGdGIRFBEFVbivqJn+7kAHjSxm65FSWRQmx1WyRRK2EE46ajA2ADDL24Cej
  38543. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTB8Sa6oC2uhYHP
  38544. 0/EqEr24Cmf9vDAKBggqhkjOPQQDAwNpADBmAjEAgFukfCPAlaUs3L6JbyO5o91lAFJekazInXJ0
  38545. glMLfalAvWhgxeG4VDvBNhcl2MG9AjEAnjWSdIUlUfUk7GRSJFClH9voy8l27OyCbvWFGFPouOOa
  38546. KaqW04MjyaR7YbPMAuhd
  38547. -----END CERTIFICATE-----
  38548. GTS Root R4
  38549. ===========
  38550. -----BEGIN CERTIFICATE-----
  38551. MIICCjCCAZGgAwIBAgIQbkepyIuUtui7OyrYorLBmTAKBggqhkjOPQQDAzBHMQswCQYDVQQGEwJV
  38552. UzEiMCAGA1UEChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3Qg
  38553. UjQwHhcNMTYwNjIyMDAwMDAwWhcNMzYwNjIyMDAwMDAwWjBHMQswCQYDVQQGEwJVUzEiMCAGA1UE
  38554. ChMZR29vZ2xlIFRydXN0IFNlcnZpY2VzIExMQzEUMBIGA1UEAxMLR1RTIFJvb3QgUjQwdjAQBgcq
  38555. hkjOPQIBBgUrgQQAIgNiAATzdHOnaItgrkO4NcWBMHtLSZ37wWHO5t5GvWvVYRg1rkDdc/eJkTBa
  38556. 6zzuhXyiQHY7qca4R9gq55KRanPpsXI5nymfopjTX15YhmUPoYRlBtHci8nHc8iMai/lxKvRHYqj
  38557. QjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBSATNbrdP9JNqPV
  38558. 2Py1PsVq8JQdjDAKBggqhkjOPQQDAwNnADBkAjBqUFJ0CMRw3J5QdCHojXohw0+WbhXRIjVhLfoI
  38559. N+4Zba3bssx9BzT1YBkstTTZbyACMANxsbqjYAuG7ZoIapVon+Kz4ZNkfF6Tpt95LY2F45TPI11x
  38560. zPKwTdb+mciUqXWi4w==
  38561. -----END CERTIFICATE-----
  38562. UCA Global G2 Root
  38563. ==================
  38564. -----BEGIN CERTIFICATE-----
  38565. MIIFRjCCAy6gAwIBAgIQXd+x2lqj7V2+WmUgZQOQ7zANBgkqhkiG9w0BAQsFADA9MQswCQYDVQQG
  38566. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxGzAZBgNVBAMMElVDQSBHbG9iYWwgRzIgUm9vdDAeFw0x
  38567. NjAzMTEwMDAwMDBaFw00MDEyMzEwMDAwMDBaMD0xCzAJBgNVBAYTAkNOMREwDwYDVQQKDAhVbmlU
  38568. cnVzdDEbMBkGA1UEAwwSVUNBIEdsb2JhbCBHMiBSb290MIICIjANBgkqhkiG9w0BAQEFAAOCAg8A
  38569. MIICCgKCAgEAxeYrb3zvJgUno4Ek2m/LAfmZmqkywiKHYUGRO8vDaBsGxUypK8FnFyIdK+35KYmT
  38570. oni9kmugow2ifsqTs6bRjDXVdfkX9s9FxeV67HeToI8jrg4aA3++1NDtLnurRiNb/yzmVHqUwCoV
  38571. 8MmNsHo7JOHXaOIxPAYzRrZUEaalLyJUKlgNAQLx+hVRZ2zA+te2G3/RVogvGjqNO7uCEeBHANBS
  38572. h6v7hn4PJGtAnTRnvI3HLYZveT6OqTwXS3+wmeOwcWDcC/Vkw85DvG1xudLeJ1uK6NjGruFZfc8o
  38573. LTW4lVYa8bJYS7cSN8h8s+1LgOGN+jIjtm+3SJUIsUROhYw6AlQgL9+/V087OpAh18EmNVQg7Mc/
  38574. R+zvWr9LesGtOxdQXGLYD0tK3Cv6brxzks3sx1DoQZbXqX5t2Okdj4q1uViSukqSKwxW/YDrCPBe
  38575. KW4bHAyvj5OJrdu9o54hyokZ7N+1wxrrFv54NkzWbtA+FxyQF2smuvt6L78RHBgOLXMDj6DlNaBa
  38576. 4kx1HXHhOThTeEDMg5PXCp6dW4+K5OXgSORIskfNTip1KnvyIvbJvgmRlld6iIis7nCs+dwp4wwc
  38577. OxJORNanTrAmyPPZGpeRaOrvjUYG0lZFWJo8DA+DuAUlwznPO6Q0ibd5Ei9Hxeepl2n8pndntd97
  38578. 8XplFeRhVmUCAwEAAaNCMEAwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0O
  38579. BBYEFIHEjMz15DD/pQwIX4wVZyF0Ad/fMA0GCSqGSIb3DQEBCwUAA4ICAQATZSL1jiutROTL/7lo
  38580. 5sOASD0Ee/ojL3rtNtqyzm325p7lX1iPyzcyochltq44PTUbPrw7tgTQvPlJ9Zv3hcU2tsu8+Mg5
  38581. 1eRfB70VVJd0ysrtT7q6ZHafgbiERUlMjW+i67HM0cOU2kTC5uLqGOiiHycFutfl1qnN3e92mI0A
  38582. Ds0b+gO3joBYDic/UvuUospeZcnWhNq5NXHzJsBPd+aBJ9J3O5oUb3n09tDh05S60FdRvScFDcH9
  38583. yBIw7m+NESsIndTUv4BFFJqIRNow6rSn4+7vW4LVPtateJLbXDzz2K36uGt/xDYotgIVilQsnLAX
  38584. c47QN6MUPJiVAAwpBVueSUmxX8fjy88nZY41F7dXyDDZQVu5FLbowg+UMaeUmMxq67XhJ/UQqAHo
  38585. jhJi6IjMtX9Gl8CbEGY4GjZGXyJoPd/JxhMnq1MGrKI8hgZlb7F+sSlEmqO6SWkoaY/X5V+tBIZk
  38586. bxqgDMUIYs6Ao9Dz7GjevjPHF1t/gMRMTLGmhIrDO7gJzRSBuhjjVFc2/tsvfEehOjPI+Vg7RE+x
  38587. ygKJBJYoaMVLuCaJu9YzL1DV/pqJuhgyklTGW+Cd+V7lDSKb9triyCGyYiGqhkCyLmTTX8jjfhFn
  38588. RR8F/uOi77Oos/N9j/gMHyIfLXC0uAE0djAA5SN4p1bXUB+K+wb1whnw0A==
  38589. -----END CERTIFICATE-----
  38590. UCA Extended Validation Root
  38591. ============================
  38592. -----BEGIN CERTIFICATE-----
  38593. MIIFWjCCA0KgAwIBAgIQT9Irj/VkyDOeTzRYZiNwYDANBgkqhkiG9w0BAQsFADBHMQswCQYDVQQG
  38594. EwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9u
  38595. IFJvb3QwHhcNMTUwMzEzMDAwMDAwWhcNMzgxMjMxMDAwMDAwWjBHMQswCQYDVQQGEwJDTjERMA8G
  38596. A1UECgwIVW5pVHJ1c3QxJTAjBgNVBAMMHFVDQSBFeHRlbmRlZCBWYWxpZGF0aW9uIFJvb3QwggIi
  38597. MA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCpCQcoEwKwmeBkqh5DFnpzsZGgdT6o+uM4AHrs
  38598. iWogD4vFsJszA1qGxliG1cGFu0/GnEBNyr7uaZa4rYEwmnySBesFK5pI0Lh2PpbIILvSsPGP2KxF
  38599. Rv+qZ2C0d35qHzwaUnoEPQc8hQ2E0B92CvdqFN9y4zR8V05WAT558aopO2z6+I9tTcg1367r3CTu
  38600. eUWnhbYFiN6IXSV8l2RnCdm/WhUFhvMJHuxYMjMR83dksHYf5BA1FxvyDrFspCqjc/wJHx4yGVMR
  38601. 59mzLC52LqGj3n5qiAno8geK+LLNEOfic0CTuwjRP+H8C5SzJe98ptfRr5//lpr1kXuYC3fUfugH
  38602. 0mK1lTnj8/FtDw5lhIpjVMWAtuCeS31HJqcBCF3RiJ7XwzJE+oJKCmhUfzhTA8ykADNkUVkLo4KR
  38603. el7sFsLzKuZi2irbWWIQJUoqgQtHB0MGcIfS+pMRKXpITeuUx3BNr2fVUbGAIAEBtHoIppB/TuDv
  38604. B0GHr2qlXov7z1CymlSvw4m6WC31MJixNnI5fkkE/SmnTHnkBVfblLkWU41Gsx2VYVdWf6/wFlth
  38605. WG82UBEL2KwrlRYaDh8IzTY0ZRBiZtWAXxQgXy0MoHgKaNYs1+lvK9JKBZP8nm9rZ/+I8U6laUpS
  38606. NwXqxhaN0sSZ0YIrO7o1dfdRUVjzyAfd5LQDfwIDAQABo0IwQDAdBgNVHQ4EFgQU2XQ65DA9DfcS
  38607. 3H5aBZ8eNJr34RQwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAYYwDQYJKoZIhvcNAQEL
  38608. BQADggIBADaNl8xCFWQpN5smLNb7rhVpLGsaGvdftvkHTFnq88nIua7Mui563MD1sC3AO6+fcAUR
  38609. ap8lTwEpcOPlDOHqWnzcSbvBHiqB9RZLcpHIojG5qtr8nR/zXUACE/xOHAbKsxSQVBcZEhrxH9cM
  38610. aVr2cXj0lH2RC47skFSOvG+hTKv8dGT9cZr4QQehzZHkPJrgmzI5c6sq1WnIeJEmMX3ixzDx/BR4
  38611. dxIOE/TdFpS/S2d7cFOFyrC78zhNLJA5wA3CXWvp4uXViI3WLL+rG761KIcSF3Ru/H38j9CHJrAb
  38612. +7lsq+KePRXBOy5nAliRn+/4Qh8st2j1da3Ptfb/EX3C8CSlrdP6oDyp+l3cpaDvRKS+1ujl5BOW
  38613. F3sGPjLtx7dCvHaj2GU4Kzg1USEODm8uNBNA4StnDG1KQTAYI1oyVZnJF+A83vbsea0rWBmirSwi
  38614. GpWOvpaQXUJXxPkUAzUrHC1RVwinOt4/5Mi0A3PCwSaAuwtCH60NryZy2sy+s6ODWA2CxR9GUeOc
  38615. GMyNm43sSet1UNWMKFnKdDTajAshqx7qG+XH/RU+wBeq+yNuJkbL+vmxcmtpzyKEC2IPrNkZAJSi
  38616. djzULZrtBJ4tBmIQN1IchXIbJ+XMxjHsN+xjWZsLHXbMfjKaiJUINlK73nZfdklJrX+9ZSCyycEr
  38617. dhh2n1ax
  38618. -----END CERTIFICATE-----
  38619. Certigna Root CA
  38620. ================
  38621. -----BEGIN CERTIFICATE-----
  38622. MIIGWzCCBEOgAwIBAgIRAMrpG4nxVQMNo+ZBbcTjpuEwDQYJKoZIhvcNAQELBQAwWjELMAkGA1UE
  38623. BhMCRlIxEjAQBgNVBAoMCURoaW15b3RpczEcMBoGA1UECwwTMDAwMiA0ODE0NjMwODEwMDAzNjEZ
  38624. MBcGA1UEAwwQQ2VydGlnbmEgUm9vdCBDQTAeFw0xMzEwMDEwODMyMjdaFw0zMzEwMDEwODMyMjda
  38625. MFoxCzAJBgNVBAYTAkZSMRIwEAYDVQQKDAlEaGlteW90aXMxHDAaBgNVBAsMEzAwMDIgNDgxNDYz
  38626. MDgxMDAwMzYxGTAXBgNVBAMMEENlcnRpZ25hIFJvb3QgQ0EwggIiMA0GCSqGSIb3DQEBAQUAA4IC
  38627. DwAwggIKAoICAQDNGDllGlmx6mQWDoyUJJV8g9PFOSbcDO8WV43X2KyjQn+Cyu3NW9sOty3tRQgX
  38628. stmzy9YXUnIo245Onoq2C/mehJpNdt4iKVzSs9IGPjA5qXSjklYcoW9MCiBtnyN6tMbaLOQdLNyz
  38629. KNAT8kxOAkmhVECe5uUFoC2EyP+YbNDrihqECB63aCPuI9Vwzm1RaRDuoXrC0SIxwoKF0vJVdlB8
  38630. JXrJhFwLrN1CTivngqIkicuQstDuI7pmTLtipPlTWmR7fJj6o0ieD5Wupxj0auwuA0Wv8HT4Ks16
  38631. XdG+RCYyKfHx9WzMfgIhC59vpD++nVPiz32pLHxYGpfhPTc3GGYo0kDFUYqMwy3OU4gkWGQwFsWq
  38632. 4NYKpkDfePb1BHxpE4S80dGnBs8B92jAqFe7OmGtBIyT46388NtEbVncSVmurJqZNjBBe3YzIoej
  38633. wpKGbvlw7q6Hh5UbxHq9MfPU0uWZ/75I7HX1eBYdpnDBfzwboZL7z8g81sWTCo/1VTp2lc5ZmIoJ
  38634. lXcymoO6LAQ6l73UL77XbJuiyn1tJslV1c/DeVIICZkHJC1kJWumIWmbat10TWuXekG9qxf5kBdI
  38635. jzb5LdXF2+6qhUVB+s06RbFo5jZMm5BX7CO5hwjCxAnxl4YqKE3idMDaxIzb3+KhF1nOJFl0Mdp/
  38636. /TBt2dzhauH8XwIDAQABo4IBGjCCARYwDwYDVR0TAQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYw
  38637. HQYDVR0OBBYEFBiHVuBud+4kNTxOc5of1uHieX4rMB8GA1UdIwQYMBaAFBiHVuBud+4kNTxOc5of
  38638. 1uHieX4rMEQGA1UdIAQ9MDswOQYEVR0gADAxMC8GCCsGAQUFBwIBFiNodHRwczovL3d3d3cuY2Vy
  38639. dGlnbmEuZnIvYXV0b3JpdGVzLzBtBgNVHR8EZjBkMC+gLaArhilodHRwOi8vY3JsLmNlcnRpZ25h
  38640. LmZyL2NlcnRpZ25hcm9vdGNhLmNybDAxoC+gLYYraHR0cDovL2NybC5kaGlteW90aXMuY29tL2Nl
  38641. cnRpZ25hcm9vdGNhLmNybDANBgkqhkiG9w0BAQsFAAOCAgEAlLieT/DjlQgi581oQfccVdV8AOIt
  38642. OoldaDgvUSILSo3L6btdPrtcPbEo/uRTVRPPoZAbAh1fZkYJMyjhDSSXcNMQH+pkV5a7XdrnxIxP
  38643. TGRGHVyH41neQtGbqH6mid2PHMkwgu07nM3A6RngatgCdTer9zQoKJHyBApPNeNgJgH60BGM+RFq
  38644. 7q89w1DTj18zeTyGqHNFkIwgtnJzFyO+B2XleJINugHA64wcZr+shncBlA2c5uk5jR+mUYyZDDl3
  38645. 4bSb+hxnV29qao6pK0xXeXpXIs/NX2NGjVxZOob4Mkdio2cNGJHc+6Zr9UhhcyNZjgKnvETq9Emd
  38646. 8VRY+WCv2hikLyhF3HqgiIZd8zvn/yk1gPxkQ5Tm4xxvvq0OKmOZK8l+hfZx6AYDlf7ej0gcWtSS
  38647. 6Cvu5zHbugRqh5jnxV/vfaci9wHYTfmJ0A6aBVmknpjZbyvKcL5kwlWj9Omvw5Ip3IgWJJk8jSaY
  38648. tlu3zM63Nwf9JtmYhST/WSMDmu2dnajkXjjO11INb9I/bbEFa0nOipFGc/T2L/Coc3cOZayhjWZS
  38649. aX5LaAzHHjcng6WMxwLkFM1JAbBzs/3GkDpv0mztO+7skb6iQ12LAEpmJURw3kAP+HwV96LOPNde
  38650. E4yBFxgX0b3xdxA61GU5wSesVywlVP+i2k+KYTlerj1KjL0=
  38651. -----END CERTIFICATE-----
  38652. emSign Root CA - G1
  38653. ===================
  38654. -----BEGIN CERTIFICATE-----
  38655. MIIDlDCCAnygAwIBAgIKMfXkYgxsWO3W2DANBgkqhkiG9w0BAQsFADBnMQswCQYDVQQGEwJJTjET
  38656. MBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRl
  38657. ZDEcMBoGA1UEAxMTZW1TaWduIFJvb3QgQ0EgLSBHMTAeFw0xODAyMTgxODMwMDBaFw00MzAyMTgx
  38658. ODMwMDBaMGcxCzAJBgNVBAYTAklOMRMwEQYDVQQLEwplbVNpZ24gUEtJMSUwIwYDVQQKExxlTXVk
  38659. aHJhIFRlY2hub2xvZ2llcyBMaW1pdGVkMRwwGgYDVQQDExNlbVNpZ24gUm9vdCBDQSAtIEcxMIIB
  38660. IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAk0u76WaK7p1b1TST0Bsew+eeuGQzf2N4aLTN
  38661. LnF115sgxk0pvLZoYIr3IZpWNVrzdr3YzZr/k1ZLpVkGoZM0Kd0WNHVO8oG0x5ZOrRkVUkr+PHB1
  38662. cM2vK6sVmjM8qrOLqs1D/fXqcP/tzxE7lM5OMhbTI0Aqd7OvPAEsbO2ZLIvZTmmYsvePQbAyeGHW
  38663. DV/D+qJAkh1cF+ZwPjXnorfCYuKrpDhMtTk1b+oDafo6VGiFbdbyL0NVHpENDtjVaqSW0RM8LHhQ
  38664. 6DqS0hdW5TUaQBw+jSztOd9C4INBdN+jzcKGYEho42kLVACL5HZpIQ15TjQIXhTCzLG3rdd8cIrH
  38665. hQIDAQABo0IwQDAdBgNVHQ4EFgQU++8Nhp6w492pufEhF38+/PB3KxowDgYDVR0PAQH/BAQDAgEG
  38666. MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAFn/8oz1h31xPaOfG1vR2vjTnGs2
  38667. vZupYeveFix0PZ7mddrXuqe8QhfnPZHr5X3dPpzxz5KsbEjMwiI/aTvFthUvozXGaCocV685743Q
  38668. NcMYDHsAVhzNixl03r4PEuDQqqE/AjSxcM6dGNYIAwlG7mDgfrbESQRRfXBgvKqy/3lyeqYdPV8q
  38669. +Mri/Tm3R7nrft8EI6/6nAYH6ftjk4BAtcZsCjEozgyfz7MjNYBBjWzEN3uBL4ChQEKF6dk4jeih
  38670. U80Bv2noWgbyRQuQ+q7hv53yrlc8pa6yVvSLZUDp/TGBLPQ5Cdjua6e0ph0VpZj3AYHYhX3zUVxx
  38671. iN66zB+Afko=
  38672. -----END CERTIFICATE-----
  38673. emSign ECC Root CA - G3
  38674. =======================
  38675. -----BEGIN CERTIFICATE-----
  38676. MIICTjCCAdOgAwIBAgIKPPYHqWhwDtqLhDAKBggqhkjOPQQDAzBrMQswCQYDVQQGEwJJTjETMBEG
  38677. A1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEg
  38678. MB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0gRzMwHhcNMTgwMjE4MTgzMDAwWhcNNDMwMjE4
  38679. MTgzMDAwWjBrMQswCQYDVQQGEwJJTjETMBEGA1UECxMKZW1TaWduIFBLSTElMCMGA1UEChMcZU11
  38680. ZGhyYSBUZWNobm9sb2dpZXMgTGltaXRlZDEgMB4GA1UEAxMXZW1TaWduIEVDQyBSb290IENBIC0g
  38681. RzMwdjAQBgcqhkjOPQIBBgUrgQQAIgNiAAQjpQy4LRL1KPOxst3iAhKAnjlfSU2fySU0WXTsuwYc
  38682. 58Byr+iuL+FBVIcUqEqy6HyC5ltqtdyzdc6LBtCGI79G1Y4PPwT01xySfvalY8L1X44uT6EYGQIr
  38683. MgqCZH0Wk9GjQjBAMB0GA1UdDgQWBBR8XQKEE9TMipuBzhccLikenEhjQjAOBgNVHQ8BAf8EBAMC
  38684. AQYwDwYDVR0TAQH/BAUwAwEB/zAKBggqhkjOPQQDAwNpADBmAjEAvvNhzwIQHWSVB7gYboiFBS+D
  38685. CBeQyh+KTOgNG3qxrdWBCUfvO6wIBHxcmbHtRwfSAjEAnbpV/KlK6O3t5nYBQnvI+GDZjVGLVTv7
  38686. jHvrZQnD+JbNR6iC8hZVdyR+EhCVBCyj
  38687. -----END CERTIFICATE-----
  38688. emSign Root CA - C1
  38689. ===================
  38690. -----BEGIN CERTIFICATE-----
  38691. MIIDczCCAlugAwIBAgILAK7PALrEzzL4Q7IwDQYJKoZIhvcNAQELBQAwVjELMAkGA1UEBhMCVVMx
  38692. EzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQDExNlbVNp
  38693. Z24gUm9vdCBDQSAtIEMxMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowVjELMAkGA1UE
  38694. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMRwwGgYDVQQD
  38695. ExNlbVNpZ24gUm9vdCBDQSAtIEMxMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAz+up
  38696. ufGZBczYKCFK83M0UYRWEPWgTywS4/oTmifQz/l5GnRfHXk5/Fv4cI7gklL35CX5VIPZHdPIWoU/
  38697. Xse2B+4+wM6ar6xWQio5JXDWv7V7Nq2s9nPczdcdioOl+yuQFTdrHCZH3DspVpNqs8FqOp099cGX
  38698. OFgFixwR4+S0uF2FHYP+eF8LRWgYSKVGczQ7/g/IdrvHGPMF0Ybzhe3nudkyrVWIzqa2kbBPrH4V
  38699. I5b2P/AgNBbeCsbEBEV5f6f9vtKppa+cxSMq9zwhbL2vj07FOrLzNBL834AaSaTUqZX3noleooms
  38700. lMuoaJuvimUnzYnu3Yy1aylwQ6BpC+S5DwIDAQABo0IwQDAdBgNVHQ4EFgQU/qHgcB4qAzlSWkK+
  38701. XJGFehiqTbUwDgYDVR0PAQH/BAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQAD
  38702. ggEBAMJKVvoVIXsoounlHfv4LcQ5lkFMOycsxGwYFYDGrK9HWS8mC+M2sO87/kOXSTKZEhVb3xEp
  38703. /6tT+LvBeA+snFOvV71ojD1pM/CjoCNjO2RnIkSt1XHLVip4kqNPEjE2NuLe/gDEo2APJ62gsIq1
  38704. NnpSob0n9CAnYuhNlCQT5AoE6TyrLshDCUrGYQTlSTR+08TI9Q/Aqum6VF7zYytPT1DU/rl7mYw9
  38705. wC68AivTxEDkigcxHpvOJpkT+xHqmiIMERnHXhuBUDDIlhJu58tBf5E7oke3VIAb3ADMmpDqw8NQ
  38706. BmIMMMAVSKeoWXzhriKi4gp6D/piq1JM4fHfyr6DDUI=
  38707. -----END CERTIFICATE-----
  38708. emSign ECC Root CA - C3
  38709. =======================
  38710. -----BEGIN CERTIFICATE-----
  38711. MIICKzCCAbGgAwIBAgIKe3G2gla4EnycqDAKBggqhkjOPQQDAzBaMQswCQYDVQQGEwJVUzETMBEG
  38712. A1UECxMKZW1TaWduIFBLSTEUMBIGA1UEChMLZU11ZGhyYSBJbmMxIDAeBgNVBAMTF2VtU2lnbiBF
  38713. Q0MgUm9vdCBDQSAtIEMzMB4XDTE4MDIxODE4MzAwMFoXDTQzMDIxODE4MzAwMFowWjELMAkGA1UE
  38714. BhMCVVMxEzARBgNVBAsTCmVtU2lnbiBQS0kxFDASBgNVBAoTC2VNdWRocmEgSW5jMSAwHgYDVQQD
  38715. ExdlbVNpZ24gRUNDIFJvb3QgQ0EgLSBDMzB2MBAGByqGSM49AgEGBSuBBAAiA2IABP2lYa57JhAd
  38716. 6bciMK4G9IGzsUJxlTm801Ljr6/58pc1kjZGDoeVjbk5Wum739D+yAdBPLtVb4OjavtisIGJAnB9
  38717. SMVK4+kiVCJNk7tCDK93nCOmfddhEc5lx/h//vXyqaNCMEAwHQYDVR0OBBYEFPtaSNCAIEDyqOkA
  38718. B2kZd6fmw/TPMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8EBTADAQH/MAoGCCqGSM49BAMDA2gA
  38719. MGUCMQC02C8Cif22TGK6Q04ThHK1rt0c3ta13FaPWEBaLd4gTCKDypOofu4SQMfWh0/434UCMBwU
  38720. ZOR8loMRnLDRWmFLpg9J0wD8ofzkpf9/rdcw0Md3f76BB1UwUCAU9Vc4CqgxUQ==
  38721. -----END CERTIFICATE-----
  38722. Hongkong Post Root CA 3
  38723. =======================
  38724. -----BEGIN CERTIFICATE-----
  38725. MIIFzzCCA7egAwIBAgIUCBZfikyl7ADJk0DfxMauI7gcWqQwDQYJKoZIhvcNAQELBQAwbzELMAkG
  38726. A1UEBhMCSEsxEjAQBgNVBAgTCUhvbmcgS29uZzESMBAGA1UEBxMJSG9uZyBLb25nMRYwFAYDVQQK
  38727. Ew1Ib25na29uZyBQb3N0MSAwHgYDVQQDExdIb25na29uZyBQb3N0IFJvb3QgQ0EgMzAeFw0xNzA2
  38728. MDMwMjI5NDZaFw00MjA2MDMwMjI5NDZaMG8xCzAJBgNVBAYTAkhLMRIwEAYDVQQIEwlIb25nIEtv
  38729. bmcxEjAQBgNVBAcTCUhvbmcgS29uZzEWMBQGA1UEChMNSG9uZ2tvbmcgUG9zdDEgMB4GA1UEAxMX
  38730. SG9uZ2tvbmcgUG9zdCBSb290IENBIDMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQCz
  38731. iNfqzg8gTr7m1gNt7ln8wlffKWihgw4+aMdoWJwcYEuJQwy51BWy7sFOdem1p+/l6TWZ5Mwc50tf
  38732. jTMwIDNT2aa71T4Tjukfh0mtUC1Qyhi+AViiE3CWu4mIVoBc+L0sPOFMV4i707mV78vH9toxdCim
  38733. 5lSJ9UExyuUmGs2C4HDaOym71QP1mbpV9WTRYA6ziUm4ii8F0oRFKHyPaFASePwLtVPLwpgchKOe
  38734. sL4jpNrcyCse2m5FHomY2vkALgbpDDtw1VAliJnLzXNg99X/NWfFobxeq81KuEXryGgeDQ0URhLj
  38735. 0mRiikKYvLTGCAj4/ahMZJx2Ab0vqWwzD9g/KLg8aQFChn5pwckGyuV6RmXpwtZQQS4/t+TtbNe/
  38736. JgERohYpSms0BpDsE9K2+2p20jzt8NYt3eEV7KObLyzJPivkaTv/ciWxNoZbx39ri1UbSsUgYT2u
  38737. y1DhCDq+sI9jQVMwCFk8mB13umOResoQUGC/8Ne8lYePl8X+l2oBlKN8W4UdKjk60FSh0Tlxnf0h
  38738. +bV78OLgAo9uliQlLKAeLKjEiafv7ZkGL7YKTE/bosw3Gq9HhS2KX8Q0NEwA/RiTZxPRN+ZItIsG
  38739. xVd7GYYKecsAyVKvQv83j+GjHno9UKtjBucVtT+2RTeUN7F+8kjDf8V1/peNRY8apxpyKBpADwID
  38740. AQABo2MwYTAPBgNVHRMBAf8EBTADAQH/MA4GA1UdDwEB/wQEAwIBBjAfBgNVHSMEGDAWgBQXnc0e
  38741. i9Y5K3DTXNSguB+wAPzFYTAdBgNVHQ4EFgQUF53NHovWOStw01zUoLgfsAD8xWEwDQYJKoZIhvcN
  38742. AQELBQADggIBAFbVe27mIgHSQpsY1Q7XZiNc4/6gx5LS6ZStS6LG7BJ8dNVI0lkUmcDrudHr9Egw
  38743. W62nV3OZqdPlt9EuWSRY3GguLmLYauRwCy0gUCCkMpXRAJi70/33MvJJrsZ64Ee+bs7Lo3I6LWld
  38744. y8joRTnU+kLBEUx3XZL7av9YROXrgZ6voJmtvqkBZss4HTzfQx/0TW60uhdG/H39h4F5ag0zD/ov
  38745. +BS5gLNdTaqX4fnkGMX41TiMJjz98iji7lpJiCzfeT2OnpA8vUFKOt1b9pq0zj8lMH8yfaIDlNDc
  38746. eqFS3m6TjRgm/VWsvY+b0s+v54Ysyx8Jb6NvqYTUc79NoXQbTiNg8swOqn+knEwlqLJmOzj/2ZQw
  38747. 9nKEvmhVEA/GcywWaZMH/rFF7buiVWqw2rVKAiUnhde3t4ZEFolsgCs+l6mc1X5VTMbeRRAc6uk7
  38748. nwNT7u56AQIWeNTowr5GdogTPyK7SBIdUgC0An4hGh6cJfTzPV4e0hz5sy229zdcxsshTrD3mUcY
  38749. hcErulWuBurQB7Lcq9CClnXO0lD+mefPL5/ndtFhKvshuzHQqp9HpLIiyhY6UFfEW0NnxWViA0kB
  38750. 60PZ2Pierc+xYw5F9KBaLJstxabArahH9CdMOA0uG0k7UvToiIMrVCjU8jVStDKDYmlkDJGcn5fq
  38751. dBb9HxEGmpv0
  38752. -----END CERTIFICATE-----
  38753. Entrust Root Certification Authority - G4
  38754. =========================================
  38755. -----BEGIN CERTIFICATE-----
  38756. MIIGSzCCBDOgAwIBAgIRANm1Q3+vqTkPAAAAAFVlrVgwDQYJKoZIhvcNAQELBQAwgb4xCzAJBgNV
  38757. BAYTAlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3Qu
  38758. bmV0L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1
  38759. dGhvcml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1
  38760. dGhvcml0eSAtIEc0MB4XDTE1MDUyNzExMTExNloXDTM3MTIyNzExNDExNlowgb4xCzAJBgNVBAYT
  38761. AlVTMRYwFAYDVQQKEw1FbnRydXN0LCBJbmMuMSgwJgYDVQQLEx9TZWUgd3d3LmVudHJ1c3QubmV0
  38762. L2xlZ2FsLXRlcm1zMTkwNwYDVQQLEzAoYykgMjAxNSBFbnRydXN0LCBJbmMuIC0gZm9yIGF1dGhv
  38763. cml6ZWQgdXNlIG9ubHkxMjAwBgNVBAMTKUVudHJ1c3QgUm9vdCBDZXJ0aWZpY2F0aW9uIEF1dGhv
  38764. cml0eSAtIEc0MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAsewsQu7i0TD/pZJH4i3D
  38765. umSXbcr3DbVZwbPLqGgZ2K+EbTBwXX7zLtJTmeH+H17ZSK9dE43b/2MzTdMAArzE+NEGCJR5WIoV
  38766. 3imz/f3ET+iq4qA7ec2/a0My3dl0ELn39GjUu9CH1apLiipvKgS1sqbHoHrmSKvS0VnM1n4j5pds
  38767. 8ELl3FFLFUHtSUrJ3hCX1nbB76W1NhSXNdh4IjVS70O92yfbYVaCNNzLiGAMC1rlLAHGVK/XqsEQ
  38768. e9IFWrhAnoanw5CGAlZSCXqc0ieCU0plUmr1POeo8pyvi73TDtTUXm6Hnmo9RR3RXRv06QqsYJn7
  38769. ibT/mCzPfB3pAqoEmh643IhuJbNsZvc8kPNXwbMv9W3y+8qh+CmdRouzavbmZwe+LGcKKh9asj5X
  38770. xNMhIWNlUpEbsZmOeX7m640A2Vqq6nPopIICR5b+W45UYaPrL0swsIsjdXJ8ITzI9vF01Bx7owVV
  38771. 7rtNOzK+mndmnqxpkCIHH2E6lr7lmk/MBTwoWdPBDFSoWWG9yHJM6Nyfh3+9nEg2XpWjDrk4JFX8
  38772. dWbrAuMINClKxuMrLzOg2qOGpRKX/YAr2hRC45K9PvJdXmd0LhyIRyk0X+IyqJwlN4y6mACXi0mW
  38773. Hv0liqzc2thddG5msP9E36EYxr5ILzeUePiVSj9/E15dWf10hkNjc0kCAwEAAaNCMEAwDwYDVR0T
  38774. AQH/BAUwAwEB/zAOBgNVHQ8BAf8EBAMCAQYwHQYDVR0OBBYEFJ84xFYjwznooHFs6FRM5Og6sb9n
  38775. MA0GCSqGSIb3DQEBCwUAA4ICAQAS5UKme4sPDORGpbZgQIeMJX6tuGguW8ZAdjwD+MlZ9POrYs4Q
  38776. jbRaZIxowLByQzTSGwv2LFPSypBLhmb8qoMi9IsabyZIrHZ3CL/FmFz0Jomee8O5ZDIBf9PD3Vht
  38777. 7LGrhFV0d4QEJ1JrhkzO3bll/9bGXp+aEJlLdWr+aumXIOTkdnrG0CSqkM0gkLpHZPt/B7NTeLUK
  38778. YvJzQ85BK4FqLoUWlFPUa19yIqtRLULVAJyZv967lDtX/Zr1hstWO1uIAeV8KEsD+UmDfLJ/fOPt
  38779. jqF/YFOOVZ1QNBIPt5d7bIdKROf1beyAN/BYGW5KaHbwH5Lk6rWS02FREAutp9lfx1/cH6NcjKF+
  38780. m7ee01ZvZl4HliDtC3T7Zk6LERXpgUl+b7DUUH8i119lAg2m9IUe2K4GS0qn0jFmwvjO5QimpAKW
  38781. RGhXxNUzzxkvFMSUHHuk2fCfDrGA4tGeEWSpiBE6doLlYsKA2KSD7ZPvfC+QsDJMlhVoSFLUmQjA
  38782. JOgc47OlIQ6SwJAfzyBfyjs4x7dtOvPmRLgOMWuIjnDrnBdSqEGULoe256YSxXXfW8AKbnuk5F6G
  38783. +TaU33fD6Q3AOfF5u0aOq0NZJ7cguyPpVkAh7DE9ZapD8j3fcEThuk0mEDuYn/PIjhs4ViFqUZPT
  38784. kcpG2om3PVODLAgfi49T3f+sHw==
  38785. -----END CERTIFICATE-----
  38786. Microsoft ECC Root Certificate Authority 2017
  38787. =============================================
  38788. -----BEGIN CERTIFICATE-----
  38789. MIICWTCCAd+gAwIBAgIQZvI9r4fei7FK6gxXMQHC7DAKBggqhkjOPQQDAzBlMQswCQYDVQQGEwJV
  38790. UzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQgRUND
  38791. IFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjMwNjQ1WhcNNDIwNzE4
  38792. MjMxNjA0WjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYw
  38793. NAYDVQQDEy1NaWNyb3NvZnQgRUNDIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwdjAQ
  38794. BgcqhkjOPQIBBgUrgQQAIgNiAATUvD0CQnVBEyPNgASGAlEvaqiBYgtlzPbKnR5vSmZRogPZnZH6
  38795. thaxjG7efM3beaYvzrvOcS/lpaso7GMEZpn4+vKTEAXhgShC48Zo9OYbhGBKia/teQ87zvH2RPUB
  38796. eMCjVDBSMA4GA1UdDwEB/wQEAwIBhjAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTIy5lycFIM
  38797. +Oa+sgRXKSrPQhDtNTAQBgkrBgEEAYI3FQEEAwIBADAKBggqhkjOPQQDAwNoADBlAjBY8k3qDPlf
  38798. Xu5gKcs68tvWMoQZP3zVL8KxzJOuULsJMsbG7X7JNpQS5GiFBqIb0C8CMQCZ6Ra0DvpWSNSkMBaR
  38799. eNtUjGUBiudQZsIxtzm6uBoiB078a1QWIP8rtedMDE2mT3M=
  38800. -----END CERTIFICATE-----
  38801. Microsoft RSA Root Certificate Authority 2017
  38802. =============================================
  38803. -----BEGIN CERTIFICATE-----
  38804. MIIFqDCCA5CgAwIBAgIQHtOXCV/YtLNHcB6qvn9FszANBgkqhkiG9w0BAQwFADBlMQswCQYDVQQG
  38805. EwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMTYwNAYDVQQDEy1NaWNyb3NvZnQg
  38806. UlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcwHhcNMTkxMjE4MjI1MTIyWhcNNDIw
  38807. NzE4MjMwMDIzWjBlMQswCQYDVQQGEwJVUzEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9u
  38808. MTYwNAYDVQQDEy1NaWNyb3NvZnQgUlNBIFJvb3QgQ2VydGlmaWNhdGUgQXV0aG9yaXR5IDIwMTcw
  38809. ggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDKW76UM4wplZEWCpW9R2LBifOZNt9GkMml
  38810. 7Xhqb0eRaPgnZ1AzHaGm++DlQ6OEAlcBXZxIQIJTELy/xztokLaCLeX0ZdDMbRnMlfl7rEqUrQ7e
  38811. S0MdhweSE5CAg2Q1OQT85elss7YfUJQ4ZVBcF0a5toW1HLUX6NZFndiyJrDKxHBKrmCk3bPZ7Pw7
  38812. 1VdyvD/IybLeS2v4I2wDwAW9lcfNcztmgGTjGqwu+UcF8ga2m3P1eDNbx6H7JyqhtJqRjJHTOoI+
  38813. dkC0zVJhUXAoP8XFWvLJjEm7FFtNyP9nTUwSlq31/niol4fX/V4ggNyhSyL71Imtus5Hl0dVe49F
  38814. yGcohJUcaDDv70ngNXtk55iwlNpNhTs+VcQor1fznhPbRiefHqJeRIOkpcrVE7NLP8TjwuaGYaRS
  38815. MLl6IE9vDzhTyzMMEyuP1pq9KsgtsRx9S1HKR9FIJ3Jdh+vVReZIZZ2vUpC6W6IYZVcSn2i51BVr
  38816. lMRpIpj0M+Dt+VGOQVDJNE92kKz8OMHY4Xu54+OU4UZpyw4KUGsTuqwPN1q3ErWQgR5WrlcihtnJ
  38817. 0tHXUeOrO8ZV/R4O03QK0dqq6mm4lyiPSMQH+FJDOvTKVTUssKZqwJz58oHhEmrARdlns87/I6KJ
  38818. ClTUFLkqqNfs+avNJVgyeY+QW5g5xAgGwax/Dj0ApQIDAQABo1QwUjAOBgNVHQ8BAf8EBAMCAYYw
  38819. DwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUCctZf4aycI8awznjwNnpv7tNsiMwEAYJKwYBBAGC
  38820. NxUBBAMCAQAwDQYJKoZIhvcNAQEMBQADggIBAKyvPl3CEZaJjqPnktaXFbgToqZCLgLNFgVZJ8og
  38821. 6Lq46BrsTaiXVq5lQ7GPAJtSzVXNUzltYkyLDVt8LkS/gxCP81OCgMNPOsduET/m4xaRhPtthH80
  38822. dK2Jp86519efhGSSvpWhrQlTM93uCupKUY5vVau6tZRGrox/2KJQJWVggEbbMwSubLWYdFQl3JPk
  38823. +ONVFT24bcMKpBLBaYVu32TxU5nhSnUgnZUP5NbcA/FZGOhHibJXWpS2qdgXKxdJ5XbLwVaZOjex
  38824. /2kskZGT4d9Mozd2TaGf+G0eHdP67Pv0RR0Tbc/3WeUiJ3IrhvNXuzDtJE3cfVa7o7P4NHmJweDy
  38825. AmH3pvwPuxwXC65B2Xy9J6P9LjrRk5Sxcx0ki69bIImtt2dmefU6xqaWM/5TkshGsRGRxpl/j8nW
  38826. ZjEgQRCHLQzWwa80mMpkg/sTV9HB8Dx6jKXB/ZUhoHHBk2dxEuqPiAppGWSZI1b7rCoucL5mxAyE
  38827. 7+WL85MB+GqQk2dLsmijtWKP6T+MejteD+eMuMZ87zf9dOLITzNy4ZQ5bb0Sr74MTnB8G2+NszKT
  38828. c0QWbej09+CVgI+WXTik9KveCjCHk9hNAHFiRSdLOkKEW39lt2c0Ui2cFmuqqNh7o0JMcccMyj6D
  38829. 5KbvtwEwXlGjefVwaaZBRA+GsCyRxj3qrg+E
  38830. -----END CERTIFICATE-----
  38831. e-Szigno Root CA 2017
  38832. =====================
  38833. -----BEGIN CERTIFICATE-----
  38834. MIICQDCCAeWgAwIBAgIMAVRI7yH9l1kN9QQKMAoGCCqGSM49BAMCMHExCzAJBgNVBAYTAkhVMREw
  38835. DwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UECgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUt
  38836. MjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3ppZ25vIFJvb3QgQ0EgMjAxNzAeFw0xNzA4MjIxMjA3MDZa
  38837. Fw00MjA4MjIxMjA3MDZaMHExCzAJBgNVBAYTAkhVMREwDwYDVQQHDAhCdWRhcGVzdDEWMBQGA1UE
  38838. CgwNTWljcm9zZWMgTHRkLjEXMBUGA1UEYQwOVkFUSFUtMjM1ODQ0OTcxHjAcBgNVBAMMFWUtU3pp
  38839. Z25vIFJvb3QgQ0EgMjAxNzBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABJbcPYrYsHtvxie+RJCx
  38840. s1YVe45DJH0ahFnuY2iyxl6H0BVIHqiQrb1TotreOpCmYF9oMrWGQd+HWyx7xf58etqjYzBhMA8G
  38841. A1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBSHERUI0arBeAyxr87GyZDv
  38842. vzAEwDAfBgNVHSMEGDAWgBSHERUI0arBeAyxr87GyZDvvzAEwDAKBggqhkjOPQQDAgNJADBGAiEA
  38843. tVfd14pVCzbhhkT61NlojbjcI4qKDdQvfepz7L9NbKgCIQDLpbQS+ue16M9+k/zzNY9vTlp8tLxO
  38844. svxyqltZ+efcMQ==
  38845. -----END CERTIFICATE-----
  38846. certSIGN Root CA G2
  38847. ===================
  38848. -----BEGIN CERTIFICATE-----
  38849. MIIFRzCCAy+gAwIBAgIJEQA0tk7GNi02MA0GCSqGSIb3DQEBCwUAMEExCzAJBgNVBAYTAlJPMRQw
  38850. EgYDVQQKEwtDRVJUU0lHTiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjAeFw0xNzAy
  38851. MDYwOTI3MzVaFw00MjAyMDYwOTI3MzVaMEExCzAJBgNVBAYTAlJPMRQwEgYDVQQKEwtDRVJUU0lH
  38852. TiBTQTEcMBoGA1UECxMTY2VydFNJR04gUk9PVCBDQSBHMjCCAiIwDQYJKoZIhvcNAQEBBQADggIP
  38853. ADCCAgoCggIBAMDFdRmRfUR0dIf+DjuW3NgBFszuY5HnC2/OOwppGnzC46+CjobXXo9X69MhWf05
  38854. N0IwvlDqtg+piNguLWkh59E3GE59kdUWX2tbAMI5Qw02hVK5U2UPHULlj88F0+7cDBrZuIt4Imfk
  38855. abBoxTzkbFpG583H+u/E7Eu9aqSs/cwoUe+StCmrqzWaTOTECMYmzPhpn+Sc8CnTXPnGFiWeI8Mg
  38856. wT0PPzhAsP6CRDiqWhqKa2NYOLQV07YRaXseVO6MGiKscpc/I1mbySKEwQdPzH/iV8oScLumZfNp
  38857. dWO9lfsbl83kqK/20U6o2YpxJM02PbyWxPFsqa7lzw1uKA2wDrXKUXt4FMMgL3/7FFXhEZn91Qqh
  38858. ngLjYl/rNUssuHLoPj1PrCy7Lobio3aP5ZMqz6WryFyNSwb/EkaseMsUBzXgqd+L6a8VTxaJW732
  38859. jcZZroiFDsGJ6x9nxUWO/203Nit4ZoORUSs9/1F3dmKh7Gc+PoGD4FapUB8fepmrY7+EF3fxDTvf
  38860. 95xhszWYijqy7DwaNz9+j5LP2RIUZNoQAhVB/0/E6xyjyfqZ90bp4RjZsbgyLcsUDFDYg2WD7rlc
  38861. z8sFWkz6GZdr1l0T08JcVLwyc6B49fFtHsufpaafItzRUZ6CeWRgKRM+o/1Pcmqr4tTluCRVLERL
  38862. iohEnMqE0yo7AgMBAAGjQjBAMA8GA1UdEwEB/wQFMAMBAf8wDgYDVR0PAQH/BAQDAgEGMB0GA1Ud
  38863. DgQWBBSCIS1mxteg4BXrzkwJd8RgnlRuAzANBgkqhkiG9w0BAQsFAAOCAgEAYN4auOfyYILVAzOB
  38864. ywaK8SJJ6ejqkX/GM15oGQOGO0MBzwdw5AgeZYWR5hEit/UCI46uuR59H35s5r0l1ZUa8gWmr4UC
  38865. b6741jH/JclKyMeKqdmfS0mbEVeZkkMR3rYzpMzXjWR91M08KCy0mpbqTfXERMQlqiCA2ClV9+BB
  38866. /AYm/7k29UMUA2Z44RGx2iBfRgB4ACGlHgAoYXhvqAEBj500mv/0OJD7uNGzcgbJceaBxXntC6Z5
  38867. 8hMLnPddDnskk7RI24Zf3lCGeOdA5jGokHZwYa+cNywRtYK3qq4kNFtyDGkNzVmf9nGvnAvRCjj5
  38868. BiKDUyUM/FHE5r7iOZULJK2v0ZXkltd0ZGtxTgI8qoXzIKNDOXZbbFD+mpwUHmUUihW9o4JFWklW
  38869. atKcsWMy5WHgUyIOpwpJ6st+H6jiYoD2EEVSmAYY3qXNL3+q1Ok+CHLsIwMCPKaq2LxndD0UF/tU
  38870. Sxfj03k9bWtJySgOLnRQvwzZRjoQhsmnP+mg7H/rpXdYaXHmgwo38oZJar55CJD2AhZkPuXaTH4M
  38871. NMn5X7azKFGnpyuqSfqNZSlO42sTp5SjLVFteAxEy9/eCG/Oo2Sr05WE1LlSVHJ7liXMvGnjSG4N
  38872. 0MedJ5qq+BOS3R7fY581qRY27Iy4g/Q9iY/NtBde17MXQRBdJ3NghVdJIgc=
  38873. -----END CERTIFICATE-----
  38874. Trustwave Global Certification Authority
  38875. ========================================
  38876. -----BEGIN CERTIFICATE-----
  38877. MIIF2jCCA8KgAwIBAgIMBfcOhtpJ80Y1LrqyMA0GCSqGSIb3DQEBCwUAMIGIMQswCQYDVQQGEwJV
  38878. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  38879. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  38880. IEF1dGhvcml0eTAeFw0xNzA4MjMxOTM0MTJaFw00MjA4MjMxOTM0MTJaMIGIMQswCQYDVQQGEwJV
  38881. UzERMA8GA1UECAwISWxsaW5vaXMxEDAOBgNVBAcMB0NoaWNhZ28xITAfBgNVBAoMGFRydXN0d2F2
  38882. ZSBIb2xkaW5ncywgSW5jLjExMC8GA1UEAwwoVHJ1c3R3YXZlIEdsb2JhbCBDZXJ0aWZpY2F0aW9u
  38883. IEF1dGhvcml0eTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALldUShLPDeS0YLOvR29
  38884. zd24q88KPuFd5dyqCblXAj7mY2Hf8g+CY66j96xz0XznswuvCAAJWX/NKSqIk4cXGIDtiLK0thAf
  38885. LdZfVaITXdHG6wZWiYj+rDKd/VzDBcdu7oaJuogDnXIhhpCujwOl3J+IKMujkkkP7NAP4m1ET4Bq
  38886. stTnoApTAbqOl5F2brz81Ws25kCI1nsvXwXoLG0R8+eyvpJETNKXpP7ScoFDB5zpET71ixpZfR9o
  38887. WN0EACyW80OzfpgZdNmcc9kYvkHHNHnZ9GLCQ7mzJ7Aiy/k9UscwR7PJPrhq4ufogXBeQotPJqX+
  38888. OsIgbrv4Fo7NDKm0G2x2EOFYeUY+VM6AqFcJNykbmROPDMjWLBz7BegIlT1lRtzuzWniTY+HKE40
  38889. Cz7PFNm73bZQmq131BnW2hqIyE4bJ3XYsgjxroMwuREOzYfwhI0Vcnyh78zyiGG69Gm7DIwLdVcE
  38890. uE4qFC49DxweMqZiNu5m4iK4BUBjECLzMx10coos9TkpoNPnG4CELcU9402x/RpvumUHO1jsQkUm
  38891. +9jaJXLE9gCxInm943xZYkqcBW89zubWR2OZxiRvchLIrH+QtAuRcOi35hYQcRfO3gZPSEF9NUqj
  38892. ifLJS3tBEW1ntwiYTOURGa5CgNz7kAXU+FDKvuStx8KU1xad5hePrzb7AgMBAAGjQjBAMA8GA1Ud
  38893. EwEB/wQFMAMBAf8wHQYDVR0OBBYEFJngGWcNYtt2s9o9uFvo/ULSMQ6HMA4GA1UdDwEB/wQEAwIB
  38894. BjANBgkqhkiG9w0BAQsFAAOCAgEAmHNw4rDT7TnsTGDZqRKGFx6W0OhUKDtkLSGm+J1WE2pIPU/H
  38895. PinbbViDVD2HfSMF1OQc3Og4ZYbFdada2zUFvXfeuyk3QAUHw5RSn8pk3fEbK9xGChACMf1KaA0H
  38896. ZJDmHvUqoai7PF35owgLEQzxPy0QlG/+4jSHg9bP5Rs1bdID4bANqKCqRieCNqcVtgimQlRXtpla
  38897. 4gt5kNdXElE1GYhBaCXUNxeEFfsBctyV3lImIJgm4nb1J2/6ADtKYdkNy1GTKv0WBpanI5ojSP5R
  38898. vbbEsLFUzt5sQa0WZ37b/TjNuThOssFgy50X31ieemKyJo90lZvkWx3SD92YHJtZuSPTMaCm/zjd
  38899. zyBP6VhWOmfD0faZmZ26NraAL4hHT4a/RDqA5Dccprrql5gR0IRiR2Qequ5AvzSxnI9O4fKSTx+O
  38900. 856X3vOmeWqJcU9LJxdI/uz0UA9PSX3MReO9ekDFQdxhVicGaeVyQYHTtgGJoC86cnn+OjC/QezH
  38901. Yj6RS8fZMXZC+fc8Y+wmjHMMfRod6qh8h6jCJ3zhM0EPz8/8AKAigJ5Kp28AsEFFtyLKaEjFQqKu
  38902. 3R3y4G5OBVixwJAWKqQ9EEC+j2Jjg6mcgn0tAumDMHzLJ8n9HmYAsC7TIS+OMxZsmO0QqAfWzJPP
  38903. 29FpHOTKyeC2nOnOcXHebD8WpHk=
  38904. -----END CERTIFICATE-----
  38905. Trustwave Global ECC P256 Certification Authority
  38906. =================================================
  38907. -----BEGIN CERTIFICATE-----
  38908. MIICYDCCAgegAwIBAgIMDWpfCD8oXD5Rld9dMAoGCCqGSM49BAMCMIGRMQswCQYDVQQGEwJVUzER
  38909. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  38910. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1NiBDZXJ0aWZp
  38911. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM1MTBaFw00MjA4MjMxOTM1MTBaMIGRMQswCQYD
  38912. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  38913. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDI1
  38914. NiBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABH77bOYj
  38915. 43MyCMpg5lOcunSNGLB4kFKA3TjASh3RqMyTpJcGOMoNFWLGjgEqZZ2q3zSRLoHB5DOSMcT9CTqm
  38916. P62jQzBBMA8GA1UdEwEB/wQFMAMBAf8wDwYDVR0PAQH/BAUDAwcGADAdBgNVHQ4EFgQUo0EGrJBt
  38917. 0UrrdaVKEJmzsaGLSvcwCgYIKoZIzj0EAwIDRwAwRAIgB+ZU2g6gWrKuEZ+Hxbb/ad4lvvigtwjz
  38918. RM4q3wghDDcCIC0mA6AFvWvR9lz4ZcyGbbOcNEhjhAnFjXca4syc4XR7
  38919. -----END CERTIFICATE-----
  38920. Trustwave Global ECC P384 Certification Authority
  38921. =================================================
  38922. -----BEGIN CERTIFICATE-----
  38923. MIICnTCCAiSgAwIBAgIMCL2Fl2yZJ6SAaEc7MAoGCCqGSM49BAMDMIGRMQswCQYDVQQGEwJVUzER
  38924. MA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRydXN0d2F2ZSBI
  38925. b2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4NCBDZXJ0aWZp
  38926. Y2F0aW9uIEF1dGhvcml0eTAeFw0xNzA4MjMxOTM2NDNaFw00MjA4MjMxOTM2NDNaMIGRMQswCQYD
  38927. VQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNVBAcTB0NoaWNhZ28xITAfBgNVBAoTGFRy
  38928. dXN0d2F2ZSBIb2xkaW5ncywgSW5jLjE6MDgGA1UEAxMxVHJ1c3R3YXZlIEdsb2JhbCBFQ0MgUDM4
  38929. NCBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTB2MBAGByqGSM49AgEGBSuBBAAiA2IABGvaDXU1CDFH
  38930. Ba5FmVXxERMuSvgQMSOjfoPTfygIOiYaOs+Xgh+AtycJj9GOMMQKmw6sWASr9zZ9lCOkmwqKi6vr
  38931. /TklZvFe/oyujUF5nQlgziip04pt89ZF1PKYhDhloKNDMEEwDwYDVR0TAQH/BAUwAwEB/zAPBgNV
  38932. HQ8BAf8EBQMDBwYAMB0GA1UdDgQWBBRVqYSJ0sEyvRjLbKYHTsjnnb6CkDAKBggqhkjOPQQDAwNn
  38933. ADBkAjA3AZKXRRJ+oPM+rRk6ct30UJMDEr5E0k9BpIycnR+j9sKS50gU/k6bpZFXrsY3crsCMGcl
  38934. CrEMXu6pY5Jv5ZAL/mYiykf9ijH3g/56vxC+GCsej/YpHpRZ744hN8tRmKVuSw==
  38935. -----END CERTIFICATE-----
  38936. <?php
  38937. namespace Composer\CaBundle;
  38938. use Psr\Log\LoggerInterface;
  38939. use Symfony\Component\Process\PhpProcess;
  38940. class CaBundle
  38941. {
  38942. private static $caPath;
  38943. private static $caFileValidity = array();
  38944. private static $useOpensslParse;
  38945. public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
  38946. {
  38947. if (self::$caPath !== null) {
  38948. return self::$caPath;
  38949. }
  38950. $caBundlePaths = array();
  38951. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_FILE');
  38952. $caBundlePaths[] = self::getEnvVariable('SSL_CERT_DIR');
  38953. $caBundlePaths[] = ini_get('openssl.cafile');
  38954. $caBundlePaths[] = ini_get('openssl.capath');
  38955. $otherLocations = array(
  38956. '/etc/pki/tls/certs/ca-bundle.crt',
  38957. '/etc/ssl/certs/ca-certificates.crt',
  38958. '/etc/ssl/ca-bundle.pem',
  38959. '/usr/local/share/certs/ca-root-nss.crt',
  38960. '/usr/ssl/certs/ca-bundle.crt',
  38961. '/opt/local/share/curl/curl-ca-bundle.crt',
  38962. '/usr/local/share/curl/curl-ca-bundle.crt',
  38963. '/usr/share/ssl/certs/ca-bundle.crt',
  38964. '/etc/ssl/cert.pem',
  38965. '/usr/local/etc/ssl/cert.pem',
  38966. '/usr/local/etc/openssl/cert.pem',
  38967. '/usr/local/etc/openssl@1.1/cert.pem',
  38968. );
  38969. foreach($otherLocations as $location) {
  38970. $otherLocations[] = dirname($location);
  38971. }
  38972. $caBundlePaths = array_merge($caBundlePaths, $otherLocations);
  38973. foreach ($caBundlePaths as $caBundle) {
  38974. if ($caBundle && self::caFileUsable($caBundle, $logger)) {
  38975. return self::$caPath = $caBundle;
  38976. }
  38977. if ($caBundle && self::caDirUsable($caBundle)) {
  38978. return self::$caPath = $caBundle;
  38979. }
  38980. }
  38981. return self::$caPath = static::getBundledCaBundlePath();
  38982. }
  38983. public static function getBundledCaBundlePath()
  38984. {
  38985. $caBundleFile = __DIR__.'/../res/cacert.pem';
  38986. if (0 === strpos($caBundleFile, 'phar://')) {
  38987. $tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-');
  38988. if (false === $tempCaBundleFile) {
  38989. throw new \RuntimeException('Could not create a temporary file to store the bundled CA file');
  38990. }
  38991. file_put_contents(
  38992. $tempCaBundleFile,
  38993. file_get_contents($caBundleFile)
  38994. );
  38995. register_shutdown_function(function() use ($tempCaBundleFile) {
  38996. @unlink($tempCaBundleFile);
  38997. });
  38998. $caBundleFile = $tempCaBundleFile;
  38999. }
  39000. return $caBundleFile;
  39001. }
  39002. public static function validateCaFile($filename, LoggerInterface $logger = null)
  39003. {
  39004. static $warned = false;
  39005. if (isset(self::$caFileValidity[$filename])) {
  39006. return self::$caFileValidity[$filename];
  39007. }
  39008. $contents = file_get_contents($filename);
  39009. if (!static::isOpensslParseSafe()) {
  39010. if (!$warned && $logger) {
  39011. $logger->warning(sprintf(
  39012. 'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
  39013. PHP_VERSION
  39014. ));
  39015. $warned = true;
  39016. }
  39017. $isValid = !empty($contents);
  39018. } elseif (is_string($contents) && strlen($contents) > 0) {
  39019. $contents = preg_replace("/^(\\-+(?:BEGIN|END))\\s+TRUSTED\\s+(CERTIFICATE\\-+)\$/m", '$1 $2', $contents);
  39020. if (null === $contents) {
  39021. $isValid = false;
  39022. } else {
  39023. $isValid = (bool) openssl_x509_parse($contents);
  39024. }
  39025. } else {
  39026. $isValid = false;
  39027. }
  39028. if ($logger) {
  39029. $logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
  39030. }
  39031. return self::$caFileValidity[$filename] = $isValid;
  39032. }
  39033. public static function isOpensslParseSafe()
  39034. {
  39035. if (null !== self::$useOpensslParse) {
  39036. return self::$useOpensslParse;
  39037. }
  39038. if (PHP_VERSION_ID >= 50600) {
  39039. return self::$useOpensslParse = true;
  39040. }
  39041. if (
  39042. (PHP_VERSION_ID < 50400 && PHP_VERSION_ID >= 50328)
  39043. || (PHP_VERSION_ID < 50500 && PHP_VERSION_ID >= 50423)
  39044. || PHP_VERSION_ID >= 50507
  39045. ) {
  39046. return self::$useOpensslParse = true;
  39047. }
  39048. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  39049. return self::$useOpensslParse = false;
  39050. }
  39051. $compareDistroVersionPrefix = function ($prefix, $fixedVersion) {
  39052. $regex = '{^'.preg_quote($prefix).'([0-9]+)$}';
  39053. if (preg_match($regex, PHP_VERSION, $m)) {
  39054. return ((int) $m[1]) >= $fixedVersion;
  39055. }
  39056. return false;
  39057. };
  39058. if (
  39059. $compareDistroVersionPrefix('5.3.3-7+squeeze', 18)
  39060. || $compareDistroVersionPrefix('5.4.4-14+deb7u', 7)
  39061. || $compareDistroVersionPrefix('5.3.10-1ubuntu3.', 9)
  39062. ) {
  39063. return self::$useOpensslParse = true;
  39064. }
  39065. if (!class_exists('Symfony\Component\Process\PhpProcess')) {
  39066. return self::$useOpensslParse = false;
  39067. }
  39068. $cert = 'LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUVwRENDQTR5Z0F3SUJBZ0lKQUp6dThyNnU2ZUJjTUEwR0NTcUdTSWIzRFFFQkJRVUFNSUhETVFzd0NRWUQKVlFRR0V3SkVSVEVjTUJvR0ExVUVDQXdUVG05eVpISm9aV2x1TFZkbGMzUm1ZV3hsYmpFUU1BNEdBMVVFQnd3SApTOE9Ed3Jac2JqRVVNQklHQTFVRUNnd0xVMlZyZEdsdmJrVnBibk14SHpBZEJnTlZCQXNNRmsxaGJHbGphVzkxCmN5QkRaWEowSUZObFkzUnBiMjR4SVRBZkJnTlZCQU1NR0cxaGJHbGphVzkxY3k1elpXdDBhVzl1WldsdWN5NWsKWlRFcU1DZ0dDU3FHU0liM0RRRUpBUlliYzNSbFptRnVMbVZ6YzJWeVFITmxhM1JwYjI1bGFXNXpMbVJsTUhVWQpaREU1TnpBd01UQXhNREF3TURBd1dnQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBCkFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUEKQUFBQUFBQVhEVEUwTVRFeU9ERXhNemt6TlZvd2djTXhDekFKQmdOVkJBWVRBa1JGTVJ3d0dnWURWUVFJREJOTwpiM0prY21obGFXNHRWMlZ6ZEdaaGJHVnVNUkF3RGdZRFZRUUhEQWRMdzRQQ3RteHVNUlF3RWdZRFZRUUtEQXRUClpXdDBhVzl1UldsdWN6RWZNQjBHQTFVRUN3d1dUV0ZzYVdOcGIzVnpJRU5sY25RZ1UyVmpkR2x2YmpFaE1COEcKQTFVRUF3d1liV0ZzYVdOcGIzVnpMbk5sYTNScGIyNWxhVzV6TG1SbE1Tb3dLQVlKS29aSWh2Y05BUWtCRmh0egpkR1ZtWVc0dVpYTnpaWEpBYzJWcmRHbHZibVZwYm5NdVpHVXdnZ0VpTUEwR0NTcUdTSWIzRFFFQkFRVUFBNElCCkR3QXdnZ0VLQW9JQkFRRERBZjNobDdKWTBYY0ZuaXlFSnBTU0RxbjBPcUJyNlFQNjV1c0pQUnQvOFBhRG9xQnUKd0VZVC9OYSs2ZnNnUGpDMHVLOURaZ1dnMnRIV1dvYW5TYmxBTW96NVBINlorUzRTSFJaN2UyZERJalBqZGhqaAowbUxnMlVNTzV5cDBWNzk3R2dzOWxOdDZKUmZIODFNTjJvYlhXczROdHp0TE11RDZlZ3FwcjhkRGJyMzRhT3M4CnBrZHVpNVVhd1Raa3N5NXBMUEhxNWNNaEZHbTA2djY1Q0xvMFYyUGQ5K0tBb2tQclBjTjVLTEtlYno3bUxwazYKU01lRVhPS1A0aWRFcXh5UTdPN2ZCdUhNZWRzUWh1K3ByWTNzaTNCVXlLZlF0UDVDWm5YMmJwMHdLSHhYMTJEWAoxbmZGSXQ5RGJHdkhUY3lPdU4rblpMUEJtM3ZXeG50eUlJdlZBZ01CQUFHalFqQkFNQWtHQTFVZEV3UUNNQUF3CkVRWUpZSVpJQVliNFFnRUJCQVFEQWdlQU1Bc0dBMVVkRHdRRUF3SUZvREFUQmdOVkhTVUVEREFLQmdnckJnRUYKQlFjREFqQU5CZ2txaGtpRzl3MEJBUVVGQUFPQ0FRRUFHMGZaWVlDVGJkajFYWWMrMVNub2FQUit2SThDOENhRAo4KzBVWWhkbnlVNGdnYTBCQWNEclk5ZTk0ZUVBdTZacXljRjZGakxxWFhkQWJvcHBXb2NyNlQ2R0QxeDMzQ2tsClZBcnpHL0t4UW9oR0QySmVxa2hJTWxEb214SE83a2EzOStPYThpMnZXTFZ5alU4QVp2V01BcnVIYTRFRU55RzcKbFcyQWFnYUZLRkNyOVRuWFRmcmR4R1ZFYnY3S1ZRNmJkaGc1cDVTanBXSDErTXEwM3VSM1pYUEJZZHlWODMxOQpvMGxWajFLRkkyRENML2xpV2lzSlJvb2YrMWNSMzVDdGQwd1lCY3BCNlRac2xNY09QbDc2ZHdLd0pnZUpvMlFnClpzZm1jMnZDMS9xT2xOdU5xLzBUenprVkd2OEVUVDNDZ2FVK1VYZTRYT1Z2a2NjZWJKbjJkZz09Ci0tLS0tRU5EIENFUlRJRklDQVRFLS0tLS0K';
  39069. $script = <<<'EOT'
  39070. error_reporting(-1);
  39071. $info = openssl_x509_parse(base64_decode('%s'));
  39072. var_dump(PHP_VERSION, $info['issuer']['emailAddress'], $info['validFrom_time_t']);
  39073. EOT;
  39074. $script = '<'."?php\n".sprintf($script, $cert);
  39075. try {
  39076. $process = new PhpProcess($script);
  39077. $process->mustRun();
  39078. } catch (\Exception $e) {
  39079. return self::$useOpensslParse = false;
  39080. }
  39081. $output = preg_split('{\r?\n}', trim($process->getOutput()));
  39082. $errorOutput = trim($process->getErrorOutput());
  39083. if (
  39084. is_array($output)
  39085. && count($output) === 3
  39086. && $output[0] === sprintf('string(%d) "%s"', strlen(PHP_VERSION), PHP_VERSION)
  39087. && $output[1] === 'string(27) "stefan.esser@sektioneins.de"'
  39088. && $output[2] === 'int(-1)'
  39089. && preg_match('{openssl_x509_parse\(\): illegal (?:ASN1 data type for|length in) timestamp in - on line \d+}', $errorOutput)
  39090. ) {
  39091. return self::$useOpensslParse = true;
  39092. }
  39093. return self::$useOpensslParse = false;
  39094. }
  39095. public static function reset()
  39096. {
  39097. self::$caFileValidity = array();
  39098. self::$caPath = null;
  39099. self::$useOpensslParse = null;
  39100. }
  39101. private static function getEnvVariable($name)
  39102. {
  39103. if (isset($_SERVER[$name])) {
  39104. return (string) $_SERVER[$name];
  39105. }
  39106. if (PHP_SAPI === 'cli' && ($value = getenv($name)) !== false && $value !== null) {
  39107. return (string) $value;
  39108. }
  39109. return false;
  39110. }
  39111. private static function caFileUsable($certFile, LoggerInterface $logger = null)
  39112. {
  39113. return $certFile && @is_file($certFile) && @is_readable($certFile) && static::validateCaFile($certFile, $logger);
  39114. }
  39115. private static function caDirUsable($certDir)
  39116. {
  39117. return $certDir && @is_dir($certDir) && @is_readable($certDir) && glob($certDir . '/*');
  39118. }
  39119. }
  39120. <?php return array (
  39121. 'root' =>
  39122. array (
  39123. 'pretty_version' => '2.0.9',
  39124. 'version' => '2.0.9.0',
  39125. 'aliases' =>
  39126. array (
  39127. ),
  39128. 'reference' => '591c2c155cac0d2d7f34af41d3b1e29bcbfc685e',
  39129. 'name' => 'composer/composer',
  39130. ),
  39131. 'versions' =>
  39132. array (
  39133. 'composer/ca-bundle' =>
  39134. array (
  39135. 'pretty_version' => '1.2.9',
  39136. 'version' => '1.2.9.0',
  39137. 'aliases' =>
  39138. array (
  39139. ),
  39140. 'reference' => '78a0e288fdcebf92aa2318a8d3656168da6ac1a5',
  39141. ),
  39142. 'composer/composer' =>
  39143. array (
  39144. 'pretty_version' => '2.0.9',
  39145. 'version' => '2.0.9.0',
  39146. 'aliases' =>
  39147. array (
  39148. ),
  39149. 'reference' => '591c2c155cac0d2d7f34af41d3b1e29bcbfc685e',
  39150. ),
  39151. 'composer/semver' =>
  39152. array (
  39153. 'pretty_version' => '3.2.4',
  39154. 'version' => '3.2.4.0',
  39155. 'aliases' =>
  39156. array (
  39157. ),
  39158. 'reference' => 'a02fdf930a3c1c3ed3a49b5f63859c0c20e10464',
  39159. ),
  39160. 'composer/spdx-licenses' =>
  39161. array (
  39162. 'pretty_version' => '1.5.5',
  39163. 'version' => '1.5.5.0',
  39164. 'aliases' =>
  39165. array (
  39166. ),
  39167. 'reference' => 'de30328a7af8680efdc03e396aad24befd513200',
  39168. ),
  39169. 'composer/xdebug-handler' =>
  39170. array (
  39171. 'pretty_version' => '1.4.5',
  39172. 'version' => '1.4.5.0',
  39173. 'aliases' =>
  39174. array (
  39175. ),
  39176. 'reference' => 'f28d44c286812c714741478d968104c5e604a1d4',
  39177. ),
  39178. 'justinrainbow/json-schema' =>
  39179. array (
  39180. 'pretty_version' => '5.2.10',
  39181. 'version' => '5.2.10.0',
  39182. 'aliases' =>
  39183. array (
  39184. ),
  39185. 'reference' => '2ba9c8c862ecd5510ed16c6340aa9f6eadb4f31b',
  39186. ),
  39187. 'psr/log' =>
  39188. array (
  39189. 'pretty_version' => '1.1.3',
  39190. 'version' => '1.1.3.0',
  39191. 'aliases' =>
  39192. array (
  39193. ),
  39194. 'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
  39195. ),
  39196. 'react/promise' =>
  39197. array (
  39198. 'pretty_version' => 'v1.2.1',
  39199. 'version' => '1.2.1.0',
  39200. 'aliases' =>
  39201. array (
  39202. ),
  39203. 'reference' => 'eefff597e67ff66b719f8171480add3c91474a1e',
  39204. ),
  39205. 'seld/jsonlint' =>
  39206. array (
  39207. 'pretty_version' => '1.8.3',
  39208. 'version' => '1.8.3.0',
  39209. 'aliases' =>
  39210. array (
  39211. ),
  39212. 'reference' => '9ad6ce79c342fbd44df10ea95511a1b24dee5b57',
  39213. ),
  39214. 'seld/phar-utils' =>
  39215. array (
  39216. 'pretty_version' => '1.1.1',
  39217. 'version' => '1.1.1.0',
  39218. 'aliases' =>
  39219. array (
  39220. ),
  39221. 'reference' => '8674b1d84ffb47cc59a101f5d5a3b61e87d23796',
  39222. ),
  39223. 'symfony/console' =>
  39224. array (
  39225. 'pretty_version' => 'v2.8.52',
  39226. 'version' => '2.8.52.0',
  39227. 'aliases' =>
  39228. array (
  39229. ),
  39230. 'reference' => 'cbcf4b5e233af15cd2bbd50dee1ccc9b7927dc12',
  39231. ),
  39232. 'symfony/debug' =>
  39233. array (
  39234. 'pretty_version' => 'v2.8.52',
  39235. 'version' => '2.8.52.0',
  39236. 'aliases' =>
  39237. array (
  39238. ),
  39239. 'reference' => '74251c8d50dd3be7c4ce0c7b862497cdc641a5d0',
  39240. ),
  39241. 'symfony/filesystem' =>
  39242. array (
  39243. 'pretty_version' => 'v2.8.52',
  39244. 'version' => '2.8.52.0',
  39245. 'aliases' =>
  39246. array (
  39247. ),
  39248. 'reference' => '7ae46872dad09dffb7fe1e93a0937097339d0080',
  39249. ),
  39250. 'symfony/finder' =>
  39251. array (
  39252. 'pretty_version' => 'v2.8.52',
  39253. 'version' => '2.8.52.0',
  39254. 'aliases' =>
  39255. array (
  39256. ),
  39257. 'reference' => '1444eac52273e345d9b95129bf914639305a9ba4',
  39258. ),
  39259. 'symfony/polyfill-ctype' =>
  39260. array (
  39261. 'pretty_version' => 'v1.19.0',
  39262. 'version' => '1.19.0.0',
  39263. 'aliases' =>
  39264. array (
  39265. ),
  39266. 'reference' => 'aed596913b70fae57be53d86faa2e9ef85a2297b',
  39267. ),
  39268. 'symfony/polyfill-mbstring' =>
  39269. array (
  39270. 'pretty_version' => 'v1.19.0',
  39271. 'version' => '1.19.0.0',
  39272. 'aliases' =>
  39273. array (
  39274. ),
  39275. 'reference' => 'b5f7b932ee6fa802fc792eabd77c4c88084517ce',
  39276. ),
  39277. 'symfony/process' =>
  39278. array (
  39279. 'pretty_version' => 'v2.8.52',
  39280. 'version' => '2.8.52.0',
  39281. 'aliases' =>
  39282. array (
  39283. ),
  39284. 'reference' => 'c3591a09c78639822b0b290d44edb69bf9f05dc8',
  39285. ),
  39286. ),
  39287. );
  39288. Copyright (C) 2015 Composer
  39289. Permission is hereby granted, free of charge, to any person obtaining a copy of
  39290. this software and associated documentation files (the "Software"), to deal in
  39291. the Software without restriction, including without limitation the rights to
  39292. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  39293. of the Software, and to permit persons to whom the Software is furnished to do
  39294. so, subject to the following conditions:
  39295. The above copyright notice and this permission notice shall be included in all
  39296. copies or substantial portions of the Software.
  39297. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  39298. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  39299. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  39300. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  39301. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  39302. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  39303. SOFTWARE.
  39304. <?php
  39305. namespace Composer\Semver;
  39306. use Composer\Semver\Constraint\Constraint;
  39307. class Comparator
  39308. {
  39309. public static function greaterThan($version1, $version2)
  39310. {
  39311. return self::compare($version1, '>', $version2);
  39312. }
  39313. public static function greaterThanOrEqualTo($version1, $version2)
  39314. {
  39315. return self::compare($version1, '>=', $version2);
  39316. }
  39317. public static function lessThan($version1, $version2)
  39318. {
  39319. return self::compare($version1, '<', $version2);
  39320. }
  39321. public static function lessThanOrEqualTo($version1, $version2)
  39322. {
  39323. return self::compare($version1, '<=', $version2);
  39324. }
  39325. public static function equalTo($version1, $version2)
  39326. {
  39327. return self::compare($version1, '==', $version2);
  39328. }
  39329. public static function notEqualTo($version1, $version2)
  39330. {
  39331. return self::compare($version1, '!=', $version2);
  39332. }
  39333. public static function compare($version1, $operator, $version2)
  39334. {
  39335. $constraint = new Constraint($operator, $version2);
  39336. return $constraint->matchSpecific(new Constraint('==', $version1), true);
  39337. }
  39338. }
  39339. <?php
  39340. namespace Composer\Semver;
  39341. use Composer\Semver\Constraint\Constraint;
  39342. use Composer\Semver\Constraint\ConstraintInterface;
  39343. class CompilingMatcher
  39344. {
  39345. private static $compiledCheckerCache = array();
  39346. private static $enabled;
  39347. private static $transOpInt = array(
  39348. Constraint::OP_EQ => '==',
  39349. Constraint::OP_LT => '<',
  39350. Constraint::OP_LE => '<=',
  39351. Constraint::OP_GT => '>',
  39352. Constraint::OP_GE => '>=',
  39353. Constraint::OP_NE => '!=',
  39354. );
  39355. public static function match(ConstraintInterface $constraint, $operator, $version)
  39356. {
  39357. if (self::$enabled === null) {
  39358. self::$enabled = !\in_array('eval', explode(',', ini_get('disable_functions')), true);
  39359. }
  39360. if (!self::$enabled) {
  39361. return $constraint->matches(new Constraint(self::$transOpInt[$operator], $version));
  39362. }
  39363. $cacheKey = $operator.$constraint;
  39364. if (!isset(self::$compiledCheckerCache[$cacheKey])) {
  39365. $code = $constraint->compile($operator);
  39366. self::$compiledCheckerCache[$cacheKey] = $function = eval('return function($v, $b){return '.$code.';};');
  39367. } else {
  39368. $function = self::$compiledCheckerCache[$cacheKey];
  39369. }
  39370. return $function($version, strpos($version, 'dev-') === 0);
  39371. }
  39372. }
  39373. <?php
  39374. namespace Composer\Semver\Constraint;
  39375. class Bound
  39376. {
  39377. private $version;
  39378. private $isInclusive;
  39379. public function __construct($version, $isInclusive)
  39380. {
  39381. $this->version = $version;
  39382. $this->isInclusive = $isInclusive;
  39383. }
  39384. public function getVersion()
  39385. {
  39386. return $this->version;
  39387. }
  39388. public function isInclusive()
  39389. {
  39390. return $this->isInclusive;
  39391. }
  39392. public function isZero()
  39393. {
  39394. return $this->getVersion() === '0.0.0.0-dev' && $this->isInclusive();
  39395. }
  39396. public function isPositiveInfinity()
  39397. {
  39398. return $this->getVersion() === PHP_INT_MAX.'.0.0.0' && !$this->isInclusive();
  39399. }
  39400. public function compareTo(Bound $other, $operator)
  39401. {
  39402. if (!\in_array($operator, array('<', '>'), true)) {
  39403. throw new \InvalidArgumentException('Does not support any other operator other than > or <.');
  39404. }
  39405. if ($this == $other) {
  39406. return false;
  39407. }
  39408. $compareResult = version_compare($this->getVersion(), $other->getVersion());
  39409. if (0 !== $compareResult) {
  39410. return (('>' === $operator) ? 1 : -1) === $compareResult;
  39411. }
  39412. return '>' === $operator ? $other->isInclusive() : !$other->isInclusive();
  39413. }
  39414. public function __toString()
  39415. {
  39416. return sprintf(
  39417. '%s [%s]',
  39418. $this->getVersion(),
  39419. $this->isInclusive() ? 'inclusive' : 'exclusive'
  39420. );
  39421. }
  39422. public static function zero()
  39423. {
  39424. return new Bound('0.0.0.0-dev', true);
  39425. }
  39426. public static function positiveInfinity()
  39427. {
  39428. return new Bound(PHP_INT_MAX.'.0.0.0', false);
  39429. }
  39430. }
  39431. <?php
  39432. namespace Composer\Semver\Constraint;
  39433. class Constraint implements ConstraintInterface
  39434. {
  39435. const OP_EQ = 0;
  39436. const OP_LT = 1;
  39437. const OP_LE = 2;
  39438. const OP_GT = 3;
  39439. const OP_GE = 4;
  39440. const OP_NE = 5;
  39441. private static $transOpStr = array(
  39442. '=' => self::OP_EQ,
  39443. '==' => self::OP_EQ,
  39444. '<' => self::OP_LT,
  39445. '<=' => self::OP_LE,
  39446. '>' => self::OP_GT,
  39447. '>=' => self::OP_GE,
  39448. '<>' => self::OP_NE,
  39449. '!=' => self::OP_NE,
  39450. );
  39451. private static $transOpInt = array(
  39452. self::OP_EQ => '==',
  39453. self::OP_LT => '<',
  39454. self::OP_LE => '<=',
  39455. self::OP_GT => '>',
  39456. self::OP_GE => '>=',
  39457. self::OP_NE => '!=',
  39458. );
  39459. protected $operator;
  39460. protected $version;
  39461. protected $prettyString;
  39462. protected $lowerBound;
  39463. protected $upperBound;
  39464. public function __construct($operator, $version)
  39465. {
  39466. if (!isset(self::$transOpStr[$operator])) {
  39467. throw new \InvalidArgumentException(sprintf(
  39468. 'Invalid operator "%s" given, expected one of: %s',
  39469. $operator,
  39470. implode(', ', self::getSupportedOperators())
  39471. ));
  39472. }
  39473. $this->operator = self::$transOpStr[$operator];
  39474. $this->version = $version;
  39475. }
  39476. public function getVersion()
  39477. {
  39478. return $this->version;
  39479. }
  39480. public function getOperator()
  39481. {
  39482. return self::$transOpInt[$this->operator];
  39483. }
  39484. public function matches(ConstraintInterface $provider)
  39485. {
  39486. if ($provider instanceof self) {
  39487. return $this->matchSpecific($provider);
  39488. }
  39489. return $provider->matches($this);
  39490. }
  39491. public function setPrettyString($prettyString)
  39492. {
  39493. $this->prettyString = $prettyString;
  39494. }
  39495. public function getPrettyString()
  39496. {
  39497. if ($this->prettyString) {
  39498. return $this->prettyString;
  39499. }
  39500. return $this->__toString();
  39501. }
  39502. public static function getSupportedOperators()
  39503. {
  39504. return array_keys(self::$transOpStr);
  39505. }
  39506. public static function getOperatorConstant($operator)
  39507. {
  39508. return self::$transOpStr[$operator];
  39509. }
  39510. public function versionCompare($a, $b, $operator, $compareBranches = false)
  39511. {
  39512. if (!isset(self::$transOpStr[$operator])) {
  39513. throw new \InvalidArgumentException(sprintf(
  39514. 'Invalid operator "%s" given, expected one of: %s',
  39515. $operator,
  39516. implode(', ', self::getSupportedOperators())
  39517. ));
  39518. }
  39519. $aIsBranch = strpos($a, 'dev-') === 0;
  39520. $bIsBranch = strpos($b, 'dev-') === 0;
  39521. if ($operator === '!=' && ($aIsBranch || $bIsBranch)) {
  39522. return $a !== $b;
  39523. }
  39524. if ($aIsBranch && $bIsBranch) {
  39525. return $operator === '==' && $a === $b;
  39526. }
  39527. if (!$compareBranches && ($aIsBranch || $bIsBranch)) {
  39528. return false;
  39529. }
  39530. return \version_compare($a, $b, $operator);
  39531. }
  39532. public function compile($otherOperator)
  39533. {
  39534. if (strpos($this->version, 'dev-') === 0) {
  39535. if (self::OP_EQ === $this->operator) {
  39536. if (self::OP_EQ === $otherOperator) {
  39537. return sprintf('$b && $v === %s', \var_export($this->version, true));
  39538. }
  39539. if (self::OP_NE === $otherOperator) {
  39540. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  39541. }
  39542. return 'false';
  39543. }
  39544. if (self::OP_NE === $this->operator) {
  39545. if (self::OP_EQ === $otherOperator) {
  39546. return sprintf('!$b || $v !== %s', \var_export($this->version, true));
  39547. }
  39548. if (self::OP_NE === $otherOperator) {
  39549. return 'true';
  39550. }
  39551. return '!$b';
  39552. }
  39553. return 'false';
  39554. }
  39555. if (self::OP_EQ === $this->operator) {
  39556. if (self::OP_EQ === $otherOperator) {
  39557. return sprintf('\version_compare($v, %s, \'==\')', \var_export($this->version, true));
  39558. }
  39559. if (self::OP_NE === $otherOperator) {
  39560. return sprintf('$b || \version_compare($v, %s, \'!=\')', \var_export($this->version, true));
  39561. }
  39562. return sprintf('!$b && \version_compare(%s, $v, \'%s\')', \var_export($this->version, true), self::$transOpInt[$otherOperator]);
  39563. }
  39564. if (self::OP_NE === $this->operator) {
  39565. if (self::OP_EQ === $otherOperator) {
  39566. return sprintf('$b || (!$b && \version_compare($v, %s, \'!=\'))', \var_export($this->version, true));
  39567. }
  39568. if (self::OP_NE === $otherOperator) {
  39569. return 'true';
  39570. }
  39571. return '!$b';
  39572. }
  39573. if (self::OP_LT === $this->operator || self::OP_LE === $this->operator) {
  39574. if (self::OP_LT === $otherOperator || self::OP_LE === $otherOperator) {
  39575. return '!$b';
  39576. }
  39577. } elseif (self::OP_GT === $this->operator || self::OP_GE === $this->operator) {
  39578. if (self::OP_GT === $otherOperator || self::OP_GE === $otherOperator) {
  39579. return '!$b';
  39580. }
  39581. }
  39582. if (self::OP_NE === $otherOperator) {
  39583. return 'true';
  39584. }
  39585. $codeComparison = sprintf('\version_compare($v, %s, \'%s\')', \var_export($this->version, true), self::$transOpInt[$this->operator]);
  39586. if ($this->operator === self::OP_LE) {
  39587. if ($otherOperator === self::OP_GT) {
  39588. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  39589. }
  39590. } elseif ($this->operator === self::OP_GE) {
  39591. if ($otherOperator === self::OP_LT) {
  39592. return sprintf('!$b && \version_compare($v, %s, \'!=\') && ', \var_export($this->version, true)) . $codeComparison;
  39593. }
  39594. }
  39595. return sprintf('!$b && %s', $codeComparison);
  39596. }
  39597. public function matchSpecific(Constraint $provider, $compareBranches = false)
  39598. {
  39599. $noEqualOp = str_replace('=', '', self::$transOpInt[$this->operator]);
  39600. $providerNoEqualOp = str_replace('=', '', self::$transOpInt[$provider->operator]);
  39601. $isEqualOp = self::OP_EQ === $this->operator;
  39602. $isNonEqualOp = self::OP_NE === $this->operator;
  39603. $isProviderEqualOp = self::OP_EQ === $provider->operator;
  39604. $isProviderNonEqualOp = self::OP_NE === $provider->operator;
  39605. if ($isNonEqualOp || $isProviderNonEqualOp) {
  39606. if ($isNonEqualOp && !$isProviderNonEqualOp && !$isProviderEqualOp && strpos($provider->version, 'dev-') === 0) {
  39607. return false;
  39608. }
  39609. if ($isProviderNonEqualOp && !$isNonEqualOp && !$isEqualOp && strpos($this->version, 'dev-') === 0) {
  39610. return false;
  39611. }
  39612. if (!$isEqualOp && !$isProviderEqualOp) {
  39613. return true;
  39614. }
  39615. return $this->versionCompare($provider->version, $this->version, '!=', $compareBranches);
  39616. }
  39617. if ($this->operator !== self::OP_EQ && $noEqualOp === $providerNoEqualOp) {
  39618. return !(strpos($this->version, 'dev-') === 0 || strpos($provider->version, 'dev-') === 0);
  39619. }
  39620. $version1 = $isEqualOp ? $this->version : $provider->version;
  39621. $version2 = $isEqualOp ? $provider->version : $this->version;
  39622. $operator = $isEqualOp ? $provider->operator : $this->operator;
  39623. if ($this->versionCompare($version1, $version2, self::$transOpInt[$operator], $compareBranches)) {
  39624. return !(self::$transOpInt[$provider->operator] === $providerNoEqualOp
  39625. && self::$transOpInt[$this->operator] !== $noEqualOp
  39626. && \version_compare($provider->version, $this->version, '=='));
  39627. }
  39628. return false;
  39629. }
  39630. public function __toString()
  39631. {
  39632. return self::$transOpInt[$this->operator] . ' ' . $this->version;
  39633. }
  39634. public function getLowerBound()
  39635. {
  39636. $this->extractBounds();
  39637. return $this->lowerBound;
  39638. }
  39639. public function getUpperBound()
  39640. {
  39641. $this->extractBounds();
  39642. return $this->upperBound;
  39643. }
  39644. private function extractBounds()
  39645. {
  39646. if (null !== $this->lowerBound) {
  39647. return;
  39648. }
  39649. if (strpos($this->version, 'dev-') === 0) {
  39650. $this->lowerBound = Bound::zero();
  39651. $this->upperBound = Bound::positiveInfinity();
  39652. return;
  39653. }
  39654. switch ($this->operator) {
  39655. case self::OP_EQ:
  39656. $this->lowerBound = new Bound($this->version, true);
  39657. $this->upperBound = new Bound($this->version, true);
  39658. break;
  39659. case self::OP_LT:
  39660. $this->lowerBound = Bound::zero();
  39661. $this->upperBound = new Bound($this->version, false);
  39662. break;
  39663. case self::OP_LE:
  39664. $this->lowerBound = Bound::zero();
  39665. $this->upperBound = new Bound($this->version, true);
  39666. break;
  39667. case self::OP_GT:
  39668. $this->lowerBound = new Bound($this->version, false);
  39669. $this->upperBound = Bound::positiveInfinity();
  39670. break;
  39671. case self::OP_GE:
  39672. $this->lowerBound = new Bound($this->version, true);
  39673. $this->upperBound = Bound::positiveInfinity();
  39674. break;
  39675. case self::OP_NE:
  39676. $this->lowerBound = Bound::zero();
  39677. $this->upperBound = Bound::positiveInfinity();
  39678. break;
  39679. }
  39680. }
  39681. }
  39682. <?php
  39683. namespace Composer\Semver\Constraint;
  39684. interface ConstraintInterface
  39685. {
  39686. public function matches(ConstraintInterface $provider);
  39687. public function compile($operator);
  39688. public function getUpperBound();
  39689. public function getLowerBound();
  39690. public function getPrettyString();
  39691. public function setPrettyString($prettyString);
  39692. public function __toString();
  39693. }
  39694. <?php
  39695. namespace Composer\Semver\Constraint;
  39696. class MatchAllConstraint implements ConstraintInterface
  39697. {
  39698. protected $prettyString;
  39699. public function matches(ConstraintInterface $provider)
  39700. {
  39701. return true;
  39702. }
  39703. public function compile($operator)
  39704. {
  39705. return 'true';
  39706. }
  39707. public function setPrettyString($prettyString)
  39708. {
  39709. $this->prettyString = $prettyString;
  39710. }
  39711. public function getPrettyString()
  39712. {
  39713. if ($this->prettyString) {
  39714. return $this->prettyString;
  39715. }
  39716. return (string) $this;
  39717. }
  39718. public function __toString()
  39719. {
  39720. return '*';
  39721. }
  39722. public function getUpperBound()
  39723. {
  39724. return Bound::positiveInfinity();
  39725. }
  39726. public function getLowerBound()
  39727. {
  39728. return Bound::zero();
  39729. }
  39730. }
  39731. <?php
  39732. namespace Composer\Semver\Constraint;
  39733. class MatchNoneConstraint implements ConstraintInterface
  39734. {
  39735. protected $prettyString;
  39736. public function matches(ConstraintInterface $provider)
  39737. {
  39738. return false;
  39739. }
  39740. public function compile($operator)
  39741. {
  39742. return 'false';
  39743. }
  39744. public function setPrettyString($prettyString)
  39745. {
  39746. $this->prettyString = $prettyString;
  39747. }
  39748. public function getPrettyString()
  39749. {
  39750. if ($this->prettyString) {
  39751. return $this->prettyString;
  39752. }
  39753. return (string) $this;
  39754. }
  39755. public function __toString()
  39756. {
  39757. return '[]';
  39758. }
  39759. public function getUpperBound()
  39760. {
  39761. return new Bound('0.0.0.0-dev', false);
  39762. }
  39763. public function getLowerBound()
  39764. {
  39765. return new Bound('0.0.0.0-dev', false);
  39766. }
  39767. }
  39768. <?php
  39769. namespace Composer\Semver\Constraint;
  39770. class MultiConstraint implements ConstraintInterface
  39771. {
  39772. protected $constraints;
  39773. protected $prettyString;
  39774. protected $string;
  39775. protected $conjunctive;
  39776. protected $lowerBound;
  39777. protected $upperBound;
  39778. public function __construct(array $constraints, $conjunctive = true)
  39779. {
  39780. if (\count($constraints) < 2) {
  39781. throw new \InvalidArgumentException(
  39782. 'Must provide at least two constraints for a MultiConstraint. Use '.
  39783. 'the regular Constraint class for one constraint only or MatchAllConstraint for none. You may use '.
  39784. 'MultiConstraint::create() which optimizes and handles those cases automatically.'
  39785. );
  39786. }
  39787. $this->constraints = $constraints;
  39788. $this->conjunctive = $conjunctive;
  39789. }
  39790. public function getConstraints()
  39791. {
  39792. return $this->constraints;
  39793. }
  39794. public function isConjunctive()
  39795. {
  39796. return $this->conjunctive;
  39797. }
  39798. public function isDisjunctive()
  39799. {
  39800. return !$this->conjunctive;
  39801. }
  39802. public function compile($otherOperator)
  39803. {
  39804. $parts = array();
  39805. foreach ($this->constraints as $constraint) {
  39806. $code = $constraint->compile($otherOperator);
  39807. if ($code === 'true') {
  39808. if (!$this->conjunctive) {
  39809. return 'true';
  39810. }
  39811. } elseif ($code === 'false') {
  39812. if ($this->conjunctive) {
  39813. return 'false';
  39814. }
  39815. } else {
  39816. $parts[] = '('.$code.')';
  39817. }
  39818. }
  39819. if (!$parts) {
  39820. return $this->conjunctive ? 'true' : 'false';
  39821. }
  39822. return $this->conjunctive ? implode('&&', $parts) : implode('||', $parts);
  39823. }
  39824. public function matches(ConstraintInterface $provider)
  39825. {
  39826. if (false === $this->conjunctive) {
  39827. foreach ($this->constraints as $constraint) {
  39828. if ($provider->matches($constraint)) {
  39829. return true;
  39830. }
  39831. }
  39832. return false;
  39833. }
  39834. foreach ($this->constraints as $constraint) {
  39835. if (!$provider->matches($constraint)) {
  39836. return false;
  39837. }
  39838. }
  39839. return true;
  39840. }
  39841. public function setPrettyString($prettyString)
  39842. {
  39843. $this->prettyString = $prettyString;
  39844. }
  39845. public function getPrettyString()
  39846. {
  39847. if ($this->prettyString) {
  39848. return $this->prettyString;
  39849. }
  39850. return (string) $this;
  39851. }
  39852. public function __toString()
  39853. {
  39854. if ($this->string !== null) {
  39855. return $this->string;
  39856. }
  39857. $constraints = array();
  39858. foreach ($this->constraints as $constraint) {
  39859. $constraints[] = (string) $constraint;
  39860. }
  39861. return $this->string = '[' . implode($this->conjunctive ? ' ' : ' || ', $constraints) . ']';
  39862. }
  39863. public function getLowerBound()
  39864. {
  39865. $this->extractBounds();
  39866. return $this->lowerBound;
  39867. }
  39868. public function getUpperBound()
  39869. {
  39870. $this->extractBounds();
  39871. return $this->upperBound;
  39872. }
  39873. public static function create(array $constraints, $conjunctive = true)
  39874. {
  39875. if (0 === \count($constraints)) {
  39876. return new MatchAllConstraint();
  39877. }
  39878. if (1 === \count($constraints)) {
  39879. return $constraints[0];
  39880. }
  39881. $optimized = self::optimizeConstraints($constraints, $conjunctive);
  39882. if ($optimized !== null) {
  39883. list($constraints, $conjunctive) = $optimized;
  39884. if (\count($constraints) === 1) {
  39885. return $constraints[0];
  39886. }
  39887. }
  39888. return new self($constraints, $conjunctive);
  39889. }
  39890. private static function optimizeConstraints(array $constraints, $conjunctive)
  39891. {
  39892. if (!$conjunctive) {
  39893. $left = $constraints[0];
  39894. $mergedConstraints = array();
  39895. $optimized = false;
  39896. for ($i = 1, $l = \count($constraints); $i < $l; $i++) {
  39897. $right = $constraints[$i];
  39898. if (
  39899. $left instanceof self
  39900. && $left->conjunctive
  39901. && $right instanceof self
  39902. && $right->conjunctive
  39903. && \count($left->constraints) === 2
  39904. && \count($right->constraints) === 2
  39905. && ($left0 = (string) $left->constraints[0])
  39906. && $left0[0] === '>' && $left0[1] === '='
  39907. && ($left1 = (string) $left->constraints[1])
  39908. && $left1[0] === '<'
  39909. && ($right0 = (string) $right->constraints[0])
  39910. && $right0[0] === '>' && $right0[1] === '='
  39911. && ($right1 = (string) $right->constraints[1])
  39912. && $right1[0] === '<'
  39913. && substr($left1, 2) === substr($right0, 3)
  39914. ) {
  39915. $optimized = true;
  39916. $left = new MultiConstraint(
  39917. array(
  39918. $left->constraints[0],
  39919. $right->constraints[1],
  39920. ),
  39921. true);
  39922. } else {
  39923. $mergedConstraints[] = $left;
  39924. $left = $right;
  39925. }
  39926. }
  39927. if ($optimized) {
  39928. $mergedConstraints[] = $left;
  39929. return array($mergedConstraints, false);
  39930. }
  39931. }
  39932. return null;
  39933. }
  39934. private function extractBounds()
  39935. {
  39936. if (null !== $this->lowerBound) {
  39937. return;
  39938. }
  39939. foreach ($this->constraints as $constraint) {
  39940. if (null === $this->lowerBound && null === $this->upperBound) {
  39941. $this->lowerBound = $constraint->getLowerBound();
  39942. $this->upperBound = $constraint->getUpperBound();
  39943. continue;
  39944. }
  39945. if ($constraint->getLowerBound()->compareTo($this->lowerBound, $this->isConjunctive() ? '>' : '<')) {
  39946. $this->lowerBound = $constraint->getLowerBound();
  39947. }
  39948. if ($constraint->getUpperBound()->compareTo($this->upperBound, $this->isConjunctive() ? '<' : '>')) {
  39949. $this->upperBound = $constraint->getUpperBound();
  39950. }
  39951. }
  39952. }
  39953. }
  39954. <?php
  39955. namespace Composer\Semver;
  39956. use Composer\Semver\Constraint\Constraint;
  39957. class Interval
  39958. {
  39959. private $start;
  39960. private $end;
  39961. public function __construct(Constraint $start, Constraint $end)
  39962. {
  39963. $this->start = $start;
  39964. $this->end = $end;
  39965. }
  39966. public function getStart()
  39967. {
  39968. return $this->start;
  39969. }
  39970. public function getEnd()
  39971. {
  39972. return $this->end;
  39973. }
  39974. public static function fromZero()
  39975. {
  39976. static $zero;
  39977. if (null === $zero) {
  39978. $zero = new Constraint('>=', '0.0.0.0-dev');
  39979. }
  39980. return $zero;
  39981. }
  39982. public static function untilPositiveInfinity()
  39983. {
  39984. static $positiveInfinity;
  39985. if (null === $positiveInfinity) {
  39986. $positiveInfinity = new Constraint('<', PHP_INT_MAX.'.0.0.0');
  39987. }
  39988. return $positiveInfinity;
  39989. }
  39990. public static function any()
  39991. {
  39992. return new self(self::fromZero(), self::untilPositiveInfinity());
  39993. }
  39994. public static function anyDev()
  39995. {
  39996. return array('names' => array(), 'exclude' => true);
  39997. }
  39998. public static function noDev()
  39999. {
  40000. return array('names' => array(), 'exclude' => false);
  40001. }
  40002. }
  40003. <?php
  40004. namespace Composer\Semver;
  40005. use Composer\Semver\Constraint\Constraint;
  40006. use Composer\Semver\Constraint\ConstraintInterface;
  40007. use Composer\Semver\Constraint\MatchAllConstraint;
  40008. use Composer\Semver\Constraint\MatchNoneConstraint;
  40009. use Composer\Semver\Constraint\MultiConstraint;
  40010. class Intervals
  40011. {
  40012. private static $intervalsCache = array();
  40013. private static $opSortOrder = array(
  40014. '>=' => -3,
  40015. '<' => -2,
  40016. '>' => 2,
  40017. '<=' => 3,
  40018. );
  40019. public static function clear()
  40020. {
  40021. self::$intervalsCache = array();
  40022. }
  40023. public static function isSubsetOf(ConstraintInterface $candidate, ConstraintInterface $constraint)
  40024. {
  40025. if ($constraint instanceof MatchAllConstraint) {
  40026. return true;
  40027. }
  40028. if ($candidate instanceof MatchNoneConstraint || $constraint instanceof MatchNoneConstraint) {
  40029. return false;
  40030. }
  40031. $intersectionIntervals = self::get(new MultiConstraint(array($candidate, $constraint), true));
  40032. $candidateIntervals = self::get($candidate);
  40033. if (\count($intersectionIntervals['numeric']) !== \count($candidateIntervals['numeric'])) {
  40034. return false;
  40035. }
  40036. foreach ($intersectionIntervals['numeric'] as $index => $interval) {
  40037. if (!isset($candidateIntervals['numeric'][$index])) {
  40038. return false;
  40039. }
  40040. if ((string) $candidateIntervals['numeric'][$index]->getStart() !== (string) $interval->getStart()) {
  40041. return false;
  40042. }
  40043. if ((string) $candidateIntervals['numeric'][$index]->getEnd() !== (string) $interval->getEnd()) {
  40044. return false;
  40045. }
  40046. }
  40047. if ($intersectionIntervals['branches']['exclude'] !== $candidateIntervals['branches']['exclude']) {
  40048. return false;
  40049. }
  40050. if (\count($intersectionIntervals['branches']['names']) !== \count($candidateIntervals['branches']['names'])) {
  40051. return false;
  40052. }
  40053. foreach ($intersectionIntervals['branches']['names'] as $index => $name) {
  40054. if ($name !== $candidateIntervals['branches']['names'][$index]) {
  40055. return false;
  40056. }
  40057. }
  40058. return true;
  40059. }
  40060. public static function haveIntersections(ConstraintInterface $a, ConstraintInterface $b)
  40061. {
  40062. if ($a instanceof MatchAllConstraint || $b instanceof MatchAllConstraint) {
  40063. return true;
  40064. }
  40065. if ($a instanceof MatchNoneConstraint || $b instanceof MatchNoneConstraint) {
  40066. return false;
  40067. }
  40068. $intersectionIntervals = self::generateIntervals(new MultiConstraint(array($a, $b), true), true);
  40069. return \count($intersectionIntervals['numeric']) > 0 || $intersectionIntervals['branches']['exclude'] || \count($intersectionIntervals['branches']['names']) > 0;
  40070. }
  40071. public static function compactConstraint(ConstraintInterface $constraint)
  40072. {
  40073. if (!$constraint instanceof MultiConstraint) {
  40074. return $constraint;
  40075. }
  40076. $intervals = self::generateIntervals($constraint);
  40077. $constraints = array();
  40078. $hasNumericMatchAll = false;
  40079. if (\count($intervals['numeric']) === 1 && (string) $intervals['numeric'][0]->getStart() === (string) Interval::fromZero() && (string) $intervals['numeric'][0]->getEnd() === (string) Interval::untilPositiveInfinity()) {
  40080. $constraints[] = $intervals['numeric'][0]->getStart();
  40081. $hasNumericMatchAll = true;
  40082. } else {
  40083. $unEqualConstraints = array();
  40084. for ($i = 0, $count = \count($intervals['numeric']); $i < $count; $i++) {
  40085. $interval = $intervals['numeric'][$i];
  40086. if ($interval->getEnd()->getOperator() === '<' && $i+1 < $count) {
  40087. $nextInterval = $intervals['numeric'][$i+1];
  40088. if ($interval->getEnd()->getVersion() === $nextInterval->getStart()->getVersion() && $nextInterval->getStart()->getOperator() === '>') {
  40089. if (\count($unEqualConstraints) === 0 && (string) $interval->getStart() !== (string) Interval::fromZero()) {
  40090. $unEqualConstraints[] = $interval->getStart();
  40091. }
  40092. $unEqualConstraints[] = new Constraint('!=', $interval->getEnd()->getVersion());
  40093. continue;
  40094. }
  40095. }
  40096. if (\count($unEqualConstraints) > 0) {
  40097. if ((string) $interval->getEnd() !== (string) Interval::untilPositiveInfinity()) {
  40098. $unEqualConstraints[] = $interval->getEnd();
  40099. }
  40100. if (\count($unEqualConstraints) > 1) {
  40101. $constraints[] = new MultiConstraint($unEqualConstraints, true);
  40102. } else {
  40103. $constraints[] = $unEqualConstraints[0];
  40104. }
  40105. $unEqualConstraints = array();
  40106. continue;
  40107. }
  40108. if ($interval->getStart()->getVersion() === $interval->getEnd()->getVersion() && $interval->getStart()->getOperator() === '>=' && $interval->getEnd()->getOperator() === '<=') {
  40109. $constraints[] = new Constraint('==', $interval->getStart()->getVersion());
  40110. continue;
  40111. }
  40112. if ((string) $interval->getStart() === (string) Interval::fromZero()) {
  40113. $constraints[] = $interval->getEnd();
  40114. } elseif ((string) $interval->getEnd() === (string) Interval::untilPositiveInfinity()) {
  40115. $constraints[] = $interval->getStart();
  40116. } else {
  40117. $constraints[] = new MultiConstraint(array($interval->getStart(), $interval->getEnd()), true);
  40118. }
  40119. }
  40120. }
  40121. $devConstraints = array();
  40122. if (0 === \count($intervals['branches']['names'])) {
  40123. if ($intervals['branches']['exclude']) {
  40124. if ($hasNumericMatchAll) {
  40125. return new MatchAllConstraint;
  40126. }
  40127. }
  40128. } else {
  40129. foreach ($intervals['branches']['names'] as $branchName) {
  40130. if ($intervals['branches']['exclude']) {
  40131. $devConstraints[] = new Constraint('!=', $branchName);
  40132. } else {
  40133. $devConstraints[] = new Constraint('==', $branchName);
  40134. }
  40135. }
  40136. if ($intervals['branches']['exclude']) {
  40137. if (\count($constraints) > 1) {
  40138. return new MultiConstraint(array_merge(
  40139. array(new MultiConstraint($constraints, false)),
  40140. $devConstraints
  40141. ), true);
  40142. }
  40143. if (\count($constraints) === 1 && (string)$constraints[0] === (string)Interval::fromZero()) {
  40144. if (\count($devConstraints) > 1) {
  40145. return new MultiConstraint($devConstraints, true);
  40146. }
  40147. return $devConstraints[0];
  40148. }
  40149. return new MultiConstraint(array_merge($constraints, $devConstraints), true);
  40150. }
  40151. $constraints = array_merge($constraints, $devConstraints);
  40152. }
  40153. if (\count($constraints) > 1) {
  40154. return new MultiConstraint($constraints, false);
  40155. }
  40156. if (\count($constraints) === 1) {
  40157. return $constraints[0];
  40158. }
  40159. return new MatchNoneConstraint;
  40160. }
  40161. public static function get(ConstraintInterface $constraint)
  40162. {
  40163. $key = (string) $constraint;
  40164. if (!isset(self::$intervalsCache[$key])) {
  40165. self::$intervalsCache[$key] = self::generateIntervals($constraint);
  40166. }
  40167. return self::$intervalsCache[$key];
  40168. }
  40169. private static function generateIntervals(ConstraintInterface $constraint, $stopOnFirstValidInterval = false)
  40170. {
  40171. if ($constraint instanceof MatchAllConstraint) {
  40172. return array('numeric' => array(new Interval(Interval::fromZero(), Interval::untilPositiveInfinity())), 'branches' => Interval::anyDev());
  40173. }
  40174. if ($constraint instanceof MatchNoneConstraint) {
  40175. return array('numeric' => array(), 'branches' => array('names' => array(), 'exclude' => false));
  40176. }
  40177. if ($constraint instanceof Constraint) {
  40178. return self::generateSingleConstraintIntervals($constraint);
  40179. }
  40180. if (!$constraint instanceof MultiConstraint) {
  40181. throw new \UnexpectedValueException('The constraint passed in should be an MatchAllConstraint, Constraint or MultiConstraint instance, got '.\get_class($constraint).'.');
  40182. }
  40183. $constraints = $constraint->getConstraints();
  40184. $numericGroups = array();
  40185. $constraintBranches = array();
  40186. foreach ($constraints as $c) {
  40187. $res = self::get($c);
  40188. $numericGroups[] = $res['numeric'];
  40189. $constraintBranches[] = $res['branches'];
  40190. }
  40191. if ($constraint->isDisjunctive()) {
  40192. $branches = Interval::noDev();
  40193. foreach ($constraintBranches as $b) {
  40194. if ($b['exclude']) {
  40195. if ($branches['exclude']) {
  40196. $branches['names'] = array_intersect($branches['names'], $b['names']);
  40197. } else {
  40198. $branches['exclude'] = true;
  40199. $branches['names'] = array_diff($b['names'], $branches['names']);
  40200. }
  40201. } else {
  40202. if ($branches['exclude']) {
  40203. $branches['names'] = array_diff($branches['names'], $b['names']);
  40204. } else {
  40205. $branches['names'] = array_merge($branches['names'], $b['names']);
  40206. }
  40207. }
  40208. }
  40209. } else {
  40210. $branches = Interval::anyDev();
  40211. foreach ($constraintBranches as $b) {
  40212. if ($b['exclude']) {
  40213. if ($branches['exclude']) {
  40214. $branches['names'] = array_merge($branches['names'], $b['names']);
  40215. } else {
  40216. $branches['names'] = array_diff($branches['names'], $b['names']);
  40217. }
  40218. } else {
  40219. if ($branches['exclude']) {
  40220. $branches['names'] = array_diff($b['names'], $branches['names']);
  40221. $branches['exclude'] = false;
  40222. } else {
  40223. $branches['names'] = array_intersect($branches['names'], $b['names']);
  40224. }
  40225. }
  40226. }
  40227. }
  40228. $branches['names'] = array_unique($branches['names']);
  40229. if (\count($numericGroups) === 1) {
  40230. return array('numeric' => $numericGroups[0], 'branches' => $branches);
  40231. }
  40232. $borders = array();
  40233. foreach ($numericGroups as $group) {
  40234. foreach ($group as $interval) {
  40235. $borders[] = array('version' => $interval->getStart()->getVersion(), 'operator' => $interval->getStart()->getOperator(), 'side' => 'start');
  40236. $borders[] = array('version' => $interval->getEnd()->getVersion(), 'operator' => $interval->getEnd()->getOperator(), 'side' => 'end');
  40237. }
  40238. }
  40239. $opSortOrder = self::$opSortOrder;
  40240. usort($borders, function ($a, $b) use ($opSortOrder) {
  40241. $order = version_compare($a['version'], $b['version']);
  40242. if ($order === 0) {
  40243. return $opSortOrder[$a['operator']] - $opSortOrder[$b['operator']];
  40244. }
  40245. return $order;
  40246. });
  40247. $activeIntervals = 0;
  40248. $intervals = array();
  40249. $index = 0;
  40250. $activationThreshold = $constraint->isConjunctive() ? \count($numericGroups) : 1;
  40251. $active = false;
  40252. $start = null;
  40253. foreach ($borders as $border) {
  40254. if ($border['side'] === 'start') {
  40255. $activeIntervals++;
  40256. } else {
  40257. $activeIntervals--;
  40258. }
  40259. if (!$active && $activeIntervals >= $activationThreshold) {
  40260. $start = new Constraint($border['operator'], $border['version']);
  40261. $active = true;
  40262. }
  40263. if ($active && $activeIntervals < $activationThreshold) {
  40264. $active = false;
  40265. if (
  40266. version_compare($start->getVersion(), $border['version'], '=')
  40267. && (
  40268. ($start->getOperator() === '>' && $border['operator'] === '<=')
  40269. || ($start->getOperator() === '>=' && $border['operator'] === '<')
  40270. )
  40271. ) {
  40272. unset($intervals[$index]);
  40273. } else {
  40274. $intervals[$index] = new Interval($start, new Constraint($border['operator'], $border['version']));
  40275. $index++;
  40276. if ($stopOnFirstValidInterval) {
  40277. break;
  40278. }
  40279. }
  40280. $start = null;
  40281. }
  40282. }
  40283. return array('numeric' => $intervals, 'branches' => $branches);
  40284. }
  40285. private static function generateSingleConstraintIntervals(Constraint $constraint)
  40286. {
  40287. $op = $constraint->getOperator();
  40288. if (strpos($constraint->getVersion(), 'dev-') === 0) {
  40289. $intervals = array();
  40290. $branches = array('names' => array(), 'exclude' => false);
  40291. if ($op === '!=') {
  40292. $intervals[] = new Interval(Interval::fromZero(), Interval::untilPositiveInfinity());
  40293. $branches = array('names' => array($constraint->getVersion()), 'exclude' => true);
  40294. } elseif ($op === '==') {
  40295. $branches['names'][] = $constraint->getVersion();
  40296. }
  40297. return array(
  40298. 'numeric' => $intervals,
  40299. 'branches' => $branches,
  40300. );
  40301. }
  40302. if ($op[0] === '>') {
  40303. return array('numeric' => array(new Interval($constraint, Interval::untilPositiveInfinity())), 'branches' => Interval::noDev());
  40304. }
  40305. if ($op[0] === '<') {
  40306. return array('numeric' => array(new Interval(Interval::fromZero(), $constraint)), 'branches' => Interval::noDev());
  40307. }
  40308. if ($op === '!=') {
  40309. return array('numeric' => array(
  40310. new Interval(Interval::fromZero(), new Constraint('<', $constraint->getVersion())),
  40311. new Interval(new Constraint('>', $constraint->getVersion()), Interval::untilPositiveInfinity()),
  40312. ), 'branches' => Interval::anyDev());
  40313. }
  40314. return array('numeric' => array(
  40315. new Interval(new Constraint('>=', $constraint->getVersion()), new Constraint('<=', $constraint->getVersion())),
  40316. ), 'branches' => Interval::noDev());
  40317. }
  40318. }
  40319. <?php
  40320. namespace Composer\Semver;
  40321. use Composer\Semver\Constraint\Constraint;
  40322. class Semver
  40323. {
  40324. const SORT_ASC = 1;
  40325. const SORT_DESC = -1;
  40326. private static $versionParser;
  40327. public static function satisfies($version, $constraints)
  40328. {
  40329. if (null === self::$versionParser) {
  40330. self::$versionParser = new VersionParser();
  40331. }
  40332. $versionParser = self::$versionParser;
  40333. $provider = new Constraint('==', $versionParser->normalize($version));
  40334. $parsedConstraints = $versionParser->parseConstraints($constraints);
  40335. return $parsedConstraints->matches($provider);
  40336. }
  40337. public static function satisfiedBy(array $versions, $constraints)
  40338. {
  40339. $versions = array_filter($versions, function ($version) use ($constraints) {
  40340. return Semver::satisfies($version, $constraints);
  40341. });
  40342. return array_values($versions);
  40343. }
  40344. public static function sort(array $versions)
  40345. {
  40346. return self::usort($versions, self::SORT_ASC);
  40347. }
  40348. public static function rsort(array $versions)
  40349. {
  40350. return self::usort($versions, self::SORT_DESC);
  40351. }
  40352. private static function usort(array $versions, $direction)
  40353. {
  40354. if (null === self::$versionParser) {
  40355. self::$versionParser = new VersionParser();
  40356. }
  40357. $versionParser = self::$versionParser;
  40358. $normalized = array();
  40359. foreach ($versions as $key => $version) {
  40360. $normalizedVersion = $versionParser->normalize($version);
  40361. $normalizedVersion = $versionParser->normalizeDefaultBranch($normalizedVersion);
  40362. $normalized[] = array($normalizedVersion, $key);
  40363. }
  40364. usort($normalized, function (array $left, array $right) use ($direction) {
  40365. if ($left[0] === $right[0]) {
  40366. return 0;
  40367. }
  40368. if (Comparator::lessThan($left[0], $right[0])) {
  40369. return -$direction;
  40370. }
  40371. return $direction;
  40372. });
  40373. $sorted = array();
  40374. foreach ($normalized as $item) {
  40375. $sorted[] = $versions[$item[1]];
  40376. }
  40377. return $sorted;
  40378. }
  40379. }
  40380. <?php
  40381. namespace Composer\Semver;
  40382. use Composer\Semver\Constraint\ConstraintInterface;
  40383. use Composer\Semver\Constraint\MatchAllConstraint;
  40384. use Composer\Semver\Constraint\MultiConstraint;
  40385. use Composer\Semver\Constraint\Constraint;
  40386. class VersionParser
  40387. {
  40388. private static $modifierRegex = '[._-]?(?:(stable|beta|b|RC|alpha|a|patch|pl|p)((?:[.-]?\d+)*+)?)?([.-]?dev)?';
  40389. private static $stabilitiesRegex = 'stable|RC|beta|alpha|dev';
  40390. public static function parseStability($version)
  40391. {
  40392. $version = preg_replace('{#.+$}', '', $version);
  40393. if (strpos($version, 'dev-') === 0 || '-dev' === substr($version, -4)) {
  40394. return 'dev';
  40395. }
  40396. preg_match('{' . self::$modifierRegex . '(?:\+.*)?$}i', strtolower($version), $match);
  40397. if (!empty($match[3])) {
  40398. return 'dev';
  40399. }
  40400. if (!empty($match[1])) {
  40401. if ('beta' === $match[1] || 'b' === $match[1]) {
  40402. return 'beta';
  40403. }
  40404. if ('alpha' === $match[1] || 'a' === $match[1]) {
  40405. return 'alpha';
  40406. }
  40407. if ('rc' === $match[1]) {
  40408. return 'RC';
  40409. }
  40410. }
  40411. return 'stable';
  40412. }
  40413. public static function normalizeStability($stability)
  40414. {
  40415. $stability = strtolower($stability);
  40416. return $stability === 'rc' ? 'RC' : $stability;
  40417. }
  40418. public function normalize($version, $fullVersion = null)
  40419. {
  40420. $version = trim($version);
  40421. $origVersion = $version;
  40422. if (null === $fullVersion) {
  40423. $fullVersion = $version;
  40424. }
  40425. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $version, $match)) {
  40426. $version = $match[1];
  40427. }
  40428. if (preg_match('{@(?:' . self::$stabilitiesRegex . ')$}i', $version, $match)) {
  40429. $version = substr($version, 0, strlen($version) - strlen($match[0]));
  40430. }
  40431. if (\in_array($version, array('master', 'trunk', 'default'), true)) {
  40432. $version = 'dev-' . $version;
  40433. }
  40434. if (stripos($version, 'dev-') === 0) {
  40435. return 'dev-' . substr($version, 4);
  40436. }
  40437. if (preg_match('{^([^,\s+]++)\+[^\s]++$}', $version, $match)) {
  40438. $version = $match[1];
  40439. }
  40440. if (preg_match('{^v?(\d{1,5})(\.\d++)?(\.\d++)?(\.\d++)?' . self::$modifierRegex . '$}i', $version, $matches)) {
  40441. $version = $matches[1]
  40442. . (!empty($matches[2]) ? $matches[2] : '.0')
  40443. . (!empty($matches[3]) ? $matches[3] : '.0')
  40444. . (!empty($matches[4]) ? $matches[4] : '.0');
  40445. $index = 5;
  40446. } elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)' . self::$modifierRegex . '$}i', $version, $matches)) {
  40447. $version = preg_replace('{\D}', '.', $matches[1]);
  40448. $index = 2;
  40449. }
  40450. if (isset($index)) {
  40451. if (!empty($matches[$index])) {
  40452. if ('stable' === $matches[$index]) {
  40453. return $version;
  40454. }
  40455. $version .= '-' . $this->expandStability($matches[$index]) . (isset($matches[$index + 1]) && '' !== $matches[$index + 1] ? ltrim($matches[$index + 1], '.-') : '');
  40456. }
  40457. if (!empty($matches[$index + 2])) {
  40458. $version .= '-dev';
  40459. }
  40460. return $version;
  40461. }
  40462. if (preg_match('{(.*?)[.-]?dev$}i', $version, $match)) {
  40463. try {
  40464. $normalized = $this->normalizeBranch($match[1]);
  40465. if (strpos($normalized, 'dev-') === false) {
  40466. return $normalized;
  40467. }
  40468. } catch (\Exception $e) {
  40469. }
  40470. }
  40471. $extraMessage = '';
  40472. if (preg_match('{ +as +' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))?$}', $fullVersion)) {
  40473. $extraMessage = ' in "' . $fullVersion . '", the alias must be an exact version';
  40474. } elseif (preg_match('{^' . preg_quote($version) . '(?:@(?:'.self::$stabilitiesRegex.'))? +as +}', $fullVersion)) {
  40475. $extraMessage = ' in "' . $fullVersion . '", the alias source must be an exact version, if it is a branch name you should prefix it with dev-';
  40476. }
  40477. throw new \UnexpectedValueException('Invalid version string "' . $origVersion . '"' . $extraMessage);
  40478. }
  40479. public function parseNumericAliasPrefix($branch)
  40480. {
  40481. if (preg_match('{^(?P<version>(\d++\\.)*\d++)(?:\.x)?-dev$}i', $branch, $matches)) {
  40482. return $matches['version'] . '.';
  40483. }
  40484. return false;
  40485. }
  40486. public function normalizeBranch($name)
  40487. {
  40488. $name = trim($name);
  40489. if (preg_match('{^v?(\d++)(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?(\.(?:\d++|[xX*]))?$}i', $name, $matches)) {
  40490. $version = '';
  40491. for ($i = 1; $i < 5; ++$i) {
  40492. $version .= isset($matches[$i]) ? str_replace(array('*', 'X'), 'x', $matches[$i]) : '.x';
  40493. }
  40494. return str_replace('x', '9999999', $version) . '-dev';
  40495. }
  40496. return 'dev-' . $name;
  40497. }
  40498. public function normalizeDefaultBranch($name)
  40499. {
  40500. if ($name === 'dev-master' || $name === 'dev-default' || $name === 'dev-trunk') {
  40501. return '9999999-dev';
  40502. }
  40503. return $name;
  40504. }
  40505. public function parseConstraints($constraints)
  40506. {
  40507. $prettyConstraint = $constraints;
  40508. $orConstraints = preg_split('{\s*\|\|?\s*}', trim($constraints));
  40509. $orGroups = array();
  40510. foreach ($orConstraints as $constraints) {
  40511. $andConstraints = preg_split('{(?<!^|as|[=>< ,]) *(?<!-)[, ](?!-) *(?!,|as|$)}', $constraints);
  40512. if (\count($andConstraints) > 1) {
  40513. $constraintObjects = array();
  40514. foreach ($andConstraints as $constraint) {
  40515. foreach ($this->parseConstraint($constraint) as $parsedConstraint) {
  40516. $constraintObjects[] = $parsedConstraint;
  40517. }
  40518. }
  40519. } else {
  40520. $constraintObjects = $this->parseConstraint($andConstraints[0]);
  40521. }
  40522. if (1 === \count($constraintObjects)) {
  40523. $constraint = $constraintObjects[0];
  40524. } else {
  40525. $constraint = new MultiConstraint($constraintObjects);
  40526. }
  40527. $orGroups[] = $constraint;
  40528. }
  40529. $constraint = MultiConstraint::create($orGroups, false);
  40530. $constraint->setPrettyString($prettyConstraint);
  40531. return $constraint;
  40532. }
  40533. private function parseConstraint($constraint)
  40534. {
  40535. if (preg_match('{^([^,\s]++) ++as ++([^,\s]++)$}', $constraint, $match)) {
  40536. $constraint = $match[1];
  40537. }
  40538. if (preg_match('{^([^,\s]*?)@(' . self::$stabilitiesRegex . ')$}i', $constraint, $match)) {
  40539. $constraint = '' !== $match[1] ? $match[1] : '*';
  40540. if ($match[2] !== 'stable') {
  40541. $stabilityModifier = $match[2];
  40542. }
  40543. }
  40544. if (preg_match('{^(dev-[^,\s@]+?|[^,\s@]+?\.x-dev)#.+$}i', $constraint, $match)) {
  40545. $constraint = $match[1];
  40546. }
  40547. if (preg_match('{^(v)?[xX*](\.[xX*])*$}i', $constraint, $match)) {
  40548. if (!empty($match[1]) || !empty($match[2])) {
  40549. return array(new Constraint('>=', '0.0.0.0-dev'));
  40550. }
  40551. return array(new MatchAllConstraint());
  40552. }
  40553. $versionRegex = 'v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.(\d++))?(?:' . self::$modifierRegex . '|\.([xX*][.-]?dev))(?:\+[^\s]+)?';
  40554. if (preg_match('{^~>?' . $versionRegex . '$}i', $constraint, $matches)) {
  40555. if (strpos($constraint, '~>') === 0) {
  40556. throw new \UnexpectedValueException(
  40557. 'Could not parse version constraint ' . $constraint . ': ' .
  40558. 'Invalid operator "~>", you probably meant to use the "~" operator'
  40559. );
  40560. }
  40561. if (isset($matches[4]) && '' !== $matches[4] && null !== $matches[4]) {
  40562. $position = 4;
  40563. } elseif (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  40564. $position = 3;
  40565. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  40566. $position = 2;
  40567. } else {
  40568. $position = 1;
  40569. }
  40570. if (!empty($matches[8])) {
  40571. $position++;
  40572. }
  40573. $stabilitySuffix = '';
  40574. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  40575. $stabilitySuffix .= '-dev';
  40576. }
  40577. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  40578. $lowerBound = new Constraint('>=', $lowVersion);
  40579. $highPosition = max(1, $position - 1);
  40580. $highVersion = $this->manipulateVersionString($matches, $highPosition, 1) . '-dev';
  40581. $upperBound = new Constraint('<', $highVersion);
  40582. return array(
  40583. $lowerBound,
  40584. $upperBound,
  40585. );
  40586. }
  40587. if (preg_match('{^\^' . $versionRegex . '($)}i', $constraint, $matches)) {
  40588. if ('0' !== $matches[1] || '' === $matches[2] || null === $matches[2]) {
  40589. $position = 1;
  40590. } elseif ('0' !== $matches[2] || '' === $matches[3] || null === $matches[3]) {
  40591. $position = 2;
  40592. } else {
  40593. $position = 3;
  40594. }
  40595. $stabilitySuffix = '';
  40596. if (empty($matches[5]) && empty($matches[7]) && empty($matches[8])) {
  40597. $stabilitySuffix .= '-dev';
  40598. }
  40599. $lowVersion = $this->normalize(substr($constraint . $stabilitySuffix, 1));
  40600. $lowerBound = new Constraint('>=', $lowVersion);
  40601. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  40602. $upperBound = new Constraint('<', $highVersion);
  40603. return array(
  40604. $lowerBound,
  40605. $upperBound,
  40606. );
  40607. }
  40608. if (preg_match('{^v?(\d++)(?:\.(\d++))?(?:\.(\d++))?(?:\.[xX*])++$}', $constraint, $matches)) {
  40609. if (isset($matches[3]) && '' !== $matches[3] && null !== $matches[3]) {
  40610. $position = 3;
  40611. } elseif (isset($matches[2]) && '' !== $matches[2] && null !== $matches[2]) {
  40612. $position = 2;
  40613. } else {
  40614. $position = 1;
  40615. }
  40616. $lowVersion = $this->manipulateVersionString($matches, $position) . '-dev';
  40617. $highVersion = $this->manipulateVersionString($matches, $position, 1) . '-dev';
  40618. if ($lowVersion === '0.0.0.0-dev') {
  40619. return array(new Constraint('<', $highVersion));
  40620. }
  40621. return array(
  40622. new Constraint('>=', $lowVersion),
  40623. new Constraint('<', $highVersion),
  40624. );
  40625. }
  40626. if (preg_match('{^(?P<from>' . $versionRegex . ') +- +(?P<to>' . $versionRegex . ')($)}i', $constraint, $matches)) {
  40627. $lowStabilitySuffix = '';
  40628. if (empty($matches[6]) && empty($matches[8]) && empty($matches[9])) {
  40629. $lowStabilitySuffix = '-dev';
  40630. }
  40631. $lowVersion = $this->normalize($matches['from']);
  40632. $lowerBound = new Constraint('>=', $lowVersion . $lowStabilitySuffix);
  40633. $empty = function ($x) {
  40634. return ($x === 0 || $x === '0') ? false : empty($x);
  40635. };
  40636. if ((!$empty($matches[12]) && !$empty($matches[13])) || !empty($matches[15]) || !empty($matches[17]) || !empty($matches[18])) {
  40637. $highVersion = $this->normalize($matches['to']);
  40638. $upperBound = new Constraint('<=', $highVersion);
  40639. } else {
  40640. $highMatch = array('', $matches[11], $matches[12], $matches[13], $matches[14]);
  40641. $this->normalize($matches['to']);
  40642. $highVersion = $this->manipulateVersionString($highMatch, $empty($matches[12]) ? 1 : 2, 1) . '-dev';
  40643. $upperBound = new Constraint('<', $highVersion);
  40644. }
  40645. return array(
  40646. $lowerBound,
  40647. $upperBound,
  40648. );
  40649. }
  40650. if (preg_match('{^(<>|!=|>=?|<=?|==?)?\s*(.*)}', $constraint, $matches)) {
  40651. try {
  40652. try {
  40653. $version = $this->normalize($matches[2]);
  40654. } catch (\UnexpectedValueException $e) {
  40655. if (substr($matches[2], -4) === '-dev' && preg_match('{^[0-9a-zA-Z-./]+$}', $matches[2])) {
  40656. $version = $this->normalize('dev-'.substr($matches[2], 0, -4));
  40657. } else {
  40658. throw $e;
  40659. }
  40660. }
  40661. $op = $matches[1] ?: '=';
  40662. if ($op !== '==' && $op !== '=' && !empty($stabilityModifier) && self::parseStability($version) === 'stable') {
  40663. $version .= '-' . $stabilityModifier;
  40664. } elseif ('<' === $op || '>=' === $op) {
  40665. if (!preg_match('/-' . self::$modifierRegex . '$/', strtolower($matches[2]))) {
  40666. if (strpos($matches[2], 'dev-') !== 0) {
  40667. $version .= '-dev';
  40668. }
  40669. }
  40670. }
  40671. return array(new Constraint($matches[1] ?: '=', $version));
  40672. } catch (\Exception $e) {
  40673. }
  40674. }
  40675. $message = 'Could not parse version constraint ' . $constraint;
  40676. if (isset($e)) {
  40677. $message .= ': ' . $e->getMessage();
  40678. }
  40679. throw new \UnexpectedValueException($message);
  40680. }
  40681. private function manipulateVersionString($matches, $position, $increment = 0, $pad = '0')
  40682. {
  40683. for ($i = 4; $i > 0; --$i) {
  40684. if ($i > $position) {
  40685. $matches[$i] = $pad;
  40686. } elseif ($i === $position && $increment) {
  40687. $matches[$i] += $increment;
  40688. if ($matches[$i] < 0) {
  40689. $matches[$i] = $pad;
  40690. --$position;
  40691. if ($i === 1) {
  40692. return null;
  40693. }
  40694. }
  40695. }
  40696. }
  40697. return $matches[1] . '.' . $matches[2] . '.' . $matches[3] . '.' . $matches[4];
  40698. }
  40699. private function expandStability($stability)
  40700. {
  40701. $stability = strtolower($stability);
  40702. switch ($stability) {
  40703. case 'a':
  40704. return 'alpha';
  40705. case 'b':
  40706. return 'beta';
  40707. case 'p':
  40708. case 'pl':
  40709. return 'patch';
  40710. case 'rc':
  40711. return 'RC';
  40712. default:
  40713. return $stability;
  40714. }
  40715. }
  40716. }
  40717. Copyright (C) 2015 Composer
  40718. Permission is hereby granted, free of charge, to any person obtaining a copy of
  40719. this software and associated documentation files (the "Software"), to deal in
  40720. the Software without restriction, including without limitation the rights to
  40721. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  40722. of the Software, and to permit persons to whom the Software is furnished to do
  40723. so, subject to the following conditions:
  40724. The above copyright notice and this permission notice shall be included in all
  40725. copies or substantial portions of the Software.
  40726. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  40727. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  40728. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  40729. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  40730. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  40731. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  40732. SOFTWARE.
  40733. {
  40734. "389-exception": [
  40735. "389 Directory Server Exception"
  40736. ],
  40737. "Autoconf-exception-2.0": [
  40738. "Autoconf exception 2.0"
  40739. ],
  40740. "Autoconf-exception-3.0": [
  40741. "Autoconf exception 3.0"
  40742. ],
  40743. "Bison-exception-2.2": [
  40744. "Bison exception 2.2"
  40745. ],
  40746. "Bootloader-exception": [
  40747. "Bootloader Distribution Exception"
  40748. ],
  40749. "Classpath-exception-2.0": [
  40750. "Classpath exception 2.0"
  40751. ],
  40752. "CLISP-exception-2.0": [
  40753. "CLISP exception 2.0"
  40754. ],
  40755. "DigiRule-FOSS-exception": [
  40756. "DigiRule FOSS License Exception"
  40757. ],
  40758. "eCos-exception-2.0": [
  40759. "eCos exception 2.0"
  40760. ],
  40761. "Fawkes-Runtime-exception": [
  40762. "Fawkes Runtime Exception"
  40763. ],
  40764. "FLTK-exception": [
  40765. "FLTK exception"
  40766. ],
  40767. "Font-exception-2.0": [
  40768. "Font exception 2.0"
  40769. ],
  40770. "freertos-exception-2.0": [
  40771. "FreeRTOS Exception 2.0"
  40772. ],
  40773. "GCC-exception-2.0": [
  40774. "GCC Runtime Library exception 2.0"
  40775. ],
  40776. "GCC-exception-3.1": [
  40777. "GCC Runtime Library exception 3.1"
  40778. ],
  40779. "gnu-javamail-exception": [
  40780. "GNU JavaMail exception"
  40781. ],
  40782. "GPL-3.0-linking-exception": [
  40783. "GPL-3.0 Linking Exception"
  40784. ],
  40785. "GPL-3.0-linking-source-exception": [
  40786. "GPL-3.0 Linking Exception (with Corresponding Source)"
  40787. ],
  40788. "GPL-CC-1.0": [
  40789. "GPL Cooperation Commitment 1.0"
  40790. ],
  40791. "i2p-gpl-java-exception": [
  40792. "i2p GPL+Java Exception"
  40793. ],
  40794. "LGPL-3.0-linking-exception": [
  40795. "LGPL-3.0 Linking Exception"
  40796. ],
  40797. "Libtool-exception": [
  40798. "Libtool Exception"
  40799. ],
  40800. "Linux-syscall-note": [
  40801. "Linux Syscall Note"
  40802. ],
  40803. "LLVM-exception": [
  40804. "LLVM Exception"
  40805. ],
  40806. "LZMA-exception": [
  40807. "LZMA exception"
  40808. ],
  40809. "mif-exception": [
  40810. "Macros and Inline Functions Exception"
  40811. ],
  40812. "Nokia-Qt-exception-1.1": [
  40813. "Nokia Qt LGPL exception 1.1"
  40814. ],
  40815. "OCaml-LGPL-linking-exception": [
  40816. "OCaml LGPL Linking Exception"
  40817. ],
  40818. "OCCT-exception-1.0": [
  40819. "Open CASCADE Exception 1.0"
  40820. ],
  40821. "OpenJDK-assembly-exception-1.0": [
  40822. "OpenJDK Assembly exception 1.0"
  40823. ],
  40824. "openvpn-openssl-exception": [
  40825. "OpenVPN OpenSSL Exception"
  40826. ],
  40827. "PS-or-PDF-font-exception-20170817": [
  40828. "PS/PDF font exception (2017-08-17)"
  40829. ],
  40830. "Qt-GPL-exception-1.0": [
  40831. "Qt GPL exception 1.0"
  40832. ],
  40833. "Qt-LGPL-exception-1.1": [
  40834. "Qt LGPL exception 1.1"
  40835. ],
  40836. "Qwt-exception-1.0": [
  40837. "Qwt exception 1.0"
  40838. ],
  40839. "SHL-2.0": [
  40840. "Solderpad Hardware License v2.0"
  40841. ],
  40842. "SHL-2.1": [
  40843. "Solderpad Hardware License v2.1"
  40844. ],
  40845. "Swift-exception": [
  40846. "Swift Exception"
  40847. ],
  40848. "u-boot-exception-2.0": [
  40849. "U-Boot exception 2.0"
  40850. ],
  40851. "Universal-FOSS-exception-1.0": [
  40852. "Universal FOSS Exception, Version 1.0"
  40853. ],
  40854. "WxWindows-exception-3.1": [
  40855. "WxWindows Library Exception 3.1"
  40856. ]
  40857. }{
  40858. "0BSD": [
  40859. "BSD Zero Clause License",
  40860. true,
  40861. false
  40862. ],
  40863. "AAL": [
  40864. "Attribution Assurance License",
  40865. true,
  40866. false
  40867. ],
  40868. "Abstyles": [
  40869. "Abstyles License",
  40870. false,
  40871. false
  40872. ],
  40873. "Adobe-2006": [
  40874. "Adobe Systems Incorporated Source Code License Agreement",
  40875. false,
  40876. false
  40877. ],
  40878. "Adobe-Glyph": [
  40879. "Adobe Glyph List License",
  40880. false,
  40881. false
  40882. ],
  40883. "ADSL": [
  40884. "Amazon Digital Services License",
  40885. false,
  40886. false
  40887. ],
  40888. "AFL-1.1": [
  40889. "Academic Free License v1.1",
  40890. true,
  40891. false
  40892. ],
  40893. "AFL-1.2": [
  40894. "Academic Free License v1.2",
  40895. true,
  40896. false
  40897. ],
  40898. "AFL-2.0": [
  40899. "Academic Free License v2.0",
  40900. true,
  40901. false
  40902. ],
  40903. "AFL-2.1": [
  40904. "Academic Free License v2.1",
  40905. true,
  40906. false
  40907. ],
  40908. "AFL-3.0": [
  40909. "Academic Free License v3.0",
  40910. true,
  40911. false
  40912. ],
  40913. "Afmparse": [
  40914. "Afmparse License",
  40915. false,
  40916. false
  40917. ],
  40918. "AGPL-1.0": [
  40919. "Affero General Public License v1.0",
  40920. false,
  40921. true
  40922. ],
  40923. "AGPL-1.0-only": [
  40924. "Affero General Public License v1.0 only",
  40925. false,
  40926. false
  40927. ],
  40928. "AGPL-1.0-or-later": [
  40929. "Affero General Public License v1.0 or later",
  40930. false,
  40931. false
  40932. ],
  40933. "AGPL-3.0": [
  40934. "GNU Affero General Public License v3.0",
  40935. true,
  40936. true
  40937. ],
  40938. "AGPL-3.0-only": [
  40939. "GNU Affero General Public License v3.0 only",
  40940. true,
  40941. false
  40942. ],
  40943. "AGPL-3.0-or-later": [
  40944. "GNU Affero General Public License v3.0 or later",
  40945. true,
  40946. false
  40947. ],
  40948. "Aladdin": [
  40949. "Aladdin Free Public License",
  40950. false,
  40951. false
  40952. ],
  40953. "AMDPLPA": [
  40954. "AMD's plpa_map.c License",
  40955. false,
  40956. false
  40957. ],
  40958. "AML": [
  40959. "Apple MIT License",
  40960. false,
  40961. false
  40962. ],
  40963. "AMPAS": [
  40964. "Academy of Motion Picture Arts and Sciences BSD",
  40965. false,
  40966. false
  40967. ],
  40968. "ANTLR-PD": [
  40969. "ANTLR Software Rights Notice",
  40970. false,
  40971. false
  40972. ],
  40973. "ANTLR-PD-fallback": [
  40974. "ANTLR Software Rights Notice with license fallback",
  40975. false,
  40976. false
  40977. ],
  40978. "Apache-1.0": [
  40979. "Apache License 1.0",
  40980. false,
  40981. false
  40982. ],
  40983. "Apache-1.1": [
  40984. "Apache License 1.1",
  40985. true,
  40986. false
  40987. ],
  40988. "Apache-2.0": [
  40989. "Apache License 2.0",
  40990. true,
  40991. false
  40992. ],
  40993. "APAFML": [
  40994. "Adobe Postscript AFM License",
  40995. false,
  40996. false
  40997. ],
  40998. "APL-1.0": [
  40999. "Adaptive Public License 1.0",
  41000. true,
  41001. false
  41002. ],
  41003. "APSL-1.0": [
  41004. "Apple Public Source License 1.0",
  41005. true,
  41006. false
  41007. ],
  41008. "APSL-1.1": [
  41009. "Apple Public Source License 1.1",
  41010. true,
  41011. false
  41012. ],
  41013. "APSL-1.2": [
  41014. "Apple Public Source License 1.2",
  41015. true,
  41016. false
  41017. ],
  41018. "APSL-2.0": [
  41019. "Apple Public Source License 2.0",
  41020. true,
  41021. false
  41022. ],
  41023. "Artistic-1.0": [
  41024. "Artistic License 1.0",
  41025. true,
  41026. false
  41027. ],
  41028. "Artistic-1.0-cl8": [
  41029. "Artistic License 1.0 w/clause 8",
  41030. true,
  41031. false
  41032. ],
  41033. "Artistic-1.0-Perl": [
  41034. "Artistic License 1.0 (Perl)",
  41035. true,
  41036. false
  41037. ],
  41038. "Artistic-2.0": [
  41039. "Artistic License 2.0",
  41040. true,
  41041. false
  41042. ],
  41043. "Bahyph": [
  41044. "Bahyph License",
  41045. false,
  41046. false
  41047. ],
  41048. "Barr": [
  41049. "Barr License",
  41050. false,
  41051. false
  41052. ],
  41053. "Beerware": [
  41054. "Beerware License",
  41055. false,
  41056. false
  41057. ],
  41058. "BitTorrent-1.0": [
  41059. "BitTorrent Open Source License v1.0",
  41060. false,
  41061. false
  41062. ],
  41063. "BitTorrent-1.1": [
  41064. "BitTorrent Open Source License v1.1",
  41065. false,
  41066. false
  41067. ],
  41068. "blessing": [
  41069. "SQLite Blessing",
  41070. false,
  41071. false
  41072. ],
  41073. "BlueOak-1.0.0": [
  41074. "Blue Oak Model License 1.0.0",
  41075. false,
  41076. false
  41077. ],
  41078. "Borceux": [
  41079. "Borceux license",
  41080. false,
  41081. false
  41082. ],
  41083. "BSD-1-Clause": [
  41084. "BSD 1-Clause License",
  41085. true,
  41086. false
  41087. ],
  41088. "BSD-2-Clause": [
  41089. "BSD 2-Clause \"Simplified\" License",
  41090. true,
  41091. false
  41092. ],
  41093. "BSD-2-Clause-FreeBSD": [
  41094. "BSD 2-Clause FreeBSD License",
  41095. false,
  41096. true
  41097. ],
  41098. "BSD-2-Clause-NetBSD": [
  41099. "BSD 2-Clause NetBSD License",
  41100. false,
  41101. true
  41102. ],
  41103. "BSD-2-Clause-Patent": [
  41104. "BSD-2-Clause Plus Patent License",
  41105. true,
  41106. false
  41107. ],
  41108. "BSD-2-Clause-Views": [
  41109. "BSD 2-Clause with views sentence",
  41110. false,
  41111. false
  41112. ],
  41113. "BSD-3-Clause": [
  41114. "BSD 3-Clause \"New\" or \"Revised\" License",
  41115. true,
  41116. false
  41117. ],
  41118. "BSD-3-Clause-Attribution": [
  41119. "BSD with attribution",
  41120. false,
  41121. false
  41122. ],
  41123. "BSD-3-Clause-Clear": [
  41124. "BSD 3-Clause Clear License",
  41125. false,
  41126. false
  41127. ],
  41128. "BSD-3-Clause-LBNL": [
  41129. "Lawrence Berkeley National Labs BSD variant license",
  41130. true,
  41131. false
  41132. ],
  41133. "BSD-3-Clause-No-Nuclear-License": [
  41134. "BSD 3-Clause No Nuclear License",
  41135. false,
  41136. false
  41137. ],
  41138. "BSD-3-Clause-No-Nuclear-License-2014": [
  41139. "BSD 3-Clause No Nuclear License 2014",
  41140. false,
  41141. false
  41142. ],
  41143. "BSD-3-Clause-No-Nuclear-Warranty": [
  41144. "BSD 3-Clause No Nuclear Warranty",
  41145. false,
  41146. false
  41147. ],
  41148. "BSD-3-Clause-Open-MPI": [
  41149. "BSD 3-Clause Open MPI variant",
  41150. false,
  41151. false
  41152. ],
  41153. "BSD-4-Clause": [
  41154. "BSD 4-Clause \"Original\" or \"Old\" License",
  41155. false,
  41156. false
  41157. ],
  41158. "BSD-4-Clause-UC": [
  41159. "BSD-4-Clause (University of California-Specific)",
  41160. false,
  41161. false
  41162. ],
  41163. "BSD-Protection": [
  41164. "BSD Protection License",
  41165. false,
  41166. false
  41167. ],
  41168. "BSD-Source-Code": [
  41169. "BSD Source Code Attribution",
  41170. false,
  41171. false
  41172. ],
  41173. "BSL-1.0": [
  41174. "Boost Software License 1.0",
  41175. true,
  41176. false
  41177. ],
  41178. "BUSL-1.1": [
  41179. "Business Source License 1.1",
  41180. false,
  41181. false
  41182. ],
  41183. "bzip2-1.0.5": [
  41184. "bzip2 and libbzip2 License v1.0.5",
  41185. false,
  41186. false
  41187. ],
  41188. "bzip2-1.0.6": [
  41189. "bzip2 and libbzip2 License v1.0.6",
  41190. false,
  41191. false
  41192. ],
  41193. "CAL-1.0": [
  41194. "Cryptographic Autonomy License 1.0",
  41195. true,
  41196. false
  41197. ],
  41198. "CAL-1.0-Combined-Work-Exception": [
  41199. "Cryptographic Autonomy License 1.0 (Combined Work Exception)",
  41200. true,
  41201. false
  41202. ],
  41203. "Caldera": [
  41204. "Caldera License",
  41205. false,
  41206. false
  41207. ],
  41208. "CATOSL-1.1": [
  41209. "Computer Associates Trusted Open Source License 1.1",
  41210. true,
  41211. false
  41212. ],
  41213. "CC-BY-1.0": [
  41214. "Creative Commons Attribution 1.0 Generic",
  41215. false,
  41216. false
  41217. ],
  41218. "CC-BY-2.0": [
  41219. "Creative Commons Attribution 2.0 Generic",
  41220. false,
  41221. false
  41222. ],
  41223. "CC-BY-2.5": [
  41224. "Creative Commons Attribution 2.5 Generic",
  41225. false,
  41226. false
  41227. ],
  41228. "CC-BY-3.0": [
  41229. "Creative Commons Attribution 3.0 Unported",
  41230. false,
  41231. false
  41232. ],
  41233. "CC-BY-3.0-AT": [
  41234. "Creative Commons Attribution 3.0 Austria",
  41235. false,
  41236. false
  41237. ],
  41238. "CC-BY-3.0-US": [
  41239. "Creative Commons Attribution 3.0 United States",
  41240. false,
  41241. false
  41242. ],
  41243. "CC-BY-4.0": [
  41244. "Creative Commons Attribution 4.0 International",
  41245. false,
  41246. false
  41247. ],
  41248. "CC-BY-NC-1.0": [
  41249. "Creative Commons Attribution Non Commercial 1.0 Generic",
  41250. false,
  41251. false
  41252. ],
  41253. "CC-BY-NC-2.0": [
  41254. "Creative Commons Attribution Non Commercial 2.0 Generic",
  41255. false,
  41256. false
  41257. ],
  41258. "CC-BY-NC-2.5": [
  41259. "Creative Commons Attribution Non Commercial 2.5 Generic",
  41260. false,
  41261. false
  41262. ],
  41263. "CC-BY-NC-3.0": [
  41264. "Creative Commons Attribution Non Commercial 3.0 Unported",
  41265. false,
  41266. false
  41267. ],
  41268. "CC-BY-NC-4.0": [
  41269. "Creative Commons Attribution Non Commercial 4.0 International",
  41270. false,
  41271. false
  41272. ],
  41273. "CC-BY-NC-ND-1.0": [
  41274. "Creative Commons Attribution Non Commercial No Derivatives 1.0 Generic",
  41275. false,
  41276. false
  41277. ],
  41278. "CC-BY-NC-ND-2.0": [
  41279. "Creative Commons Attribution Non Commercial No Derivatives 2.0 Generic",
  41280. false,
  41281. false
  41282. ],
  41283. "CC-BY-NC-ND-2.5": [
  41284. "Creative Commons Attribution Non Commercial No Derivatives 2.5 Generic",
  41285. false,
  41286. false
  41287. ],
  41288. "CC-BY-NC-ND-3.0": [
  41289. "Creative Commons Attribution Non Commercial No Derivatives 3.0 Unported",
  41290. false,
  41291. false
  41292. ],
  41293. "CC-BY-NC-ND-3.0-IGO": [
  41294. "Creative Commons Attribution Non Commercial No Derivatives 3.0 IGO",
  41295. false,
  41296. false
  41297. ],
  41298. "CC-BY-NC-ND-4.0": [
  41299. "Creative Commons Attribution Non Commercial No Derivatives 4.0 International",
  41300. false,
  41301. false
  41302. ],
  41303. "CC-BY-NC-SA-1.0": [
  41304. "Creative Commons Attribution Non Commercial Share Alike 1.0 Generic",
  41305. false,
  41306. false
  41307. ],
  41308. "CC-BY-NC-SA-2.0": [
  41309. "Creative Commons Attribution Non Commercial Share Alike 2.0 Generic",
  41310. false,
  41311. false
  41312. ],
  41313. "CC-BY-NC-SA-2.5": [
  41314. "Creative Commons Attribution Non Commercial Share Alike 2.5 Generic",
  41315. false,
  41316. false
  41317. ],
  41318. "CC-BY-NC-SA-3.0": [
  41319. "Creative Commons Attribution Non Commercial Share Alike 3.0 Unported",
  41320. false,
  41321. false
  41322. ],
  41323. "CC-BY-NC-SA-4.0": [
  41324. "Creative Commons Attribution Non Commercial Share Alike 4.0 International",
  41325. false,
  41326. false
  41327. ],
  41328. "CC-BY-ND-1.0": [
  41329. "Creative Commons Attribution No Derivatives 1.0 Generic",
  41330. false,
  41331. false
  41332. ],
  41333. "CC-BY-ND-2.0": [
  41334. "Creative Commons Attribution No Derivatives 2.0 Generic",
  41335. false,
  41336. false
  41337. ],
  41338. "CC-BY-ND-2.5": [
  41339. "Creative Commons Attribution No Derivatives 2.5 Generic",
  41340. false,
  41341. false
  41342. ],
  41343. "CC-BY-ND-3.0": [
  41344. "Creative Commons Attribution No Derivatives 3.0 Unported",
  41345. false,
  41346. false
  41347. ],
  41348. "CC-BY-ND-4.0": [
  41349. "Creative Commons Attribution No Derivatives 4.0 International",
  41350. false,
  41351. false
  41352. ],
  41353. "CC-BY-SA-1.0": [
  41354. "Creative Commons Attribution Share Alike 1.0 Generic",
  41355. false,
  41356. false
  41357. ],
  41358. "CC-BY-SA-2.0": [
  41359. "Creative Commons Attribution Share Alike 2.0 Generic",
  41360. false,
  41361. false
  41362. ],
  41363. "CC-BY-SA-2.0-UK": [
  41364. "Creative Commons Attribution Share Alike 2.0 England and Wales",
  41365. false,
  41366. false
  41367. ],
  41368. "CC-BY-SA-2.5": [
  41369. "Creative Commons Attribution Share Alike 2.5 Generic",
  41370. false,
  41371. false
  41372. ],
  41373. "CC-BY-SA-3.0": [
  41374. "Creative Commons Attribution Share Alike 3.0 Unported",
  41375. false,
  41376. false
  41377. ],
  41378. "CC-BY-SA-3.0-AT": [
  41379. "Creative Commons Attribution-Share Alike 3.0 Austria",
  41380. false,
  41381. false
  41382. ],
  41383. "CC-BY-SA-4.0": [
  41384. "Creative Commons Attribution Share Alike 4.0 International",
  41385. false,
  41386. false
  41387. ],
  41388. "CC-PDDC": [
  41389. "Creative Commons Public Domain Dedication and Certification",
  41390. false,
  41391. false
  41392. ],
  41393. "CC0-1.0": [
  41394. "Creative Commons Zero v1.0 Universal",
  41395. false,
  41396. false
  41397. ],
  41398. "CDDL-1.0": [
  41399. "Common Development and Distribution License 1.0",
  41400. true,
  41401. false
  41402. ],
  41403. "CDDL-1.1": [
  41404. "Common Development and Distribution License 1.1",
  41405. false,
  41406. false
  41407. ],
  41408. "CDLA-Permissive-1.0": [
  41409. "Community Data License Agreement Permissive 1.0",
  41410. false,
  41411. false
  41412. ],
  41413. "CDLA-Sharing-1.0": [
  41414. "Community Data License Agreement Sharing 1.0",
  41415. false,
  41416. false
  41417. ],
  41418. "CECILL-1.0": [
  41419. "CeCILL Free Software License Agreement v1.0",
  41420. false,
  41421. false
  41422. ],
  41423. "CECILL-1.1": [
  41424. "CeCILL Free Software License Agreement v1.1",
  41425. false,
  41426. false
  41427. ],
  41428. "CECILL-2.0": [
  41429. "CeCILL Free Software License Agreement v2.0",
  41430. false,
  41431. false
  41432. ],
  41433. "CECILL-2.1": [
  41434. "CeCILL Free Software License Agreement v2.1",
  41435. true,
  41436. false
  41437. ],
  41438. "CECILL-B": [
  41439. "CeCILL-B Free Software License Agreement",
  41440. false,
  41441. false
  41442. ],
  41443. "CECILL-C": [
  41444. "CeCILL-C Free Software License Agreement",
  41445. false,
  41446. false
  41447. ],
  41448. "CERN-OHL-1.1": [
  41449. "CERN Open Hardware Licence v1.1",
  41450. false,
  41451. false
  41452. ],
  41453. "CERN-OHL-1.2": [
  41454. "CERN Open Hardware Licence v1.2",
  41455. false,
  41456. false
  41457. ],
  41458. "CERN-OHL-P-2.0": [
  41459. "CERN Open Hardware Licence Version 2 - Permissive",
  41460. false,
  41461. false
  41462. ],
  41463. "CERN-OHL-S-2.0": [
  41464. "CERN Open Hardware Licence Version 2 - Strongly Reciprocal",
  41465. false,
  41466. false
  41467. ],
  41468. "CERN-OHL-W-2.0": [
  41469. "CERN Open Hardware Licence Version 2 - Weakly Reciprocal",
  41470. false,
  41471. false
  41472. ],
  41473. "ClArtistic": [
  41474. "Clarified Artistic License",
  41475. false,
  41476. false
  41477. ],
  41478. "CNRI-Jython": [
  41479. "CNRI Jython License",
  41480. false,
  41481. false
  41482. ],
  41483. "CNRI-Python": [
  41484. "CNRI Python License",
  41485. true,
  41486. false
  41487. ],
  41488. "CNRI-Python-GPL-Compatible": [
  41489. "CNRI Python Open Source GPL Compatible License Agreement",
  41490. false,
  41491. false
  41492. ],
  41493. "Condor-1.1": [
  41494. "Condor Public License v1.1",
  41495. false,
  41496. false
  41497. ],
  41498. "copyleft-next-0.3.0": [
  41499. "copyleft-next 0.3.0",
  41500. false,
  41501. false
  41502. ],
  41503. "copyleft-next-0.3.1": [
  41504. "copyleft-next 0.3.1",
  41505. false,
  41506. false
  41507. ],
  41508. "CPAL-1.0": [
  41509. "Common Public Attribution License 1.0",
  41510. true,
  41511. false
  41512. ],
  41513. "CPL-1.0": [
  41514. "Common Public License 1.0",
  41515. true,
  41516. false
  41517. ],
  41518. "CPOL-1.02": [
  41519. "Code Project Open License 1.02",
  41520. false,
  41521. false
  41522. ],
  41523. "Crossword": [
  41524. "Crossword License",
  41525. false,
  41526. false
  41527. ],
  41528. "CrystalStacker": [
  41529. "CrystalStacker License",
  41530. false,
  41531. false
  41532. ],
  41533. "CUA-OPL-1.0": [
  41534. "CUA Office Public License v1.0",
  41535. true,
  41536. false
  41537. ],
  41538. "Cube": [
  41539. "Cube License",
  41540. false,
  41541. false
  41542. ],
  41543. "curl": [
  41544. "curl License",
  41545. false,
  41546. false
  41547. ],
  41548. "D-FSL-1.0": [
  41549. "Deutsche Freie Software Lizenz",
  41550. false,
  41551. false
  41552. ],
  41553. "diffmark": [
  41554. "diffmark license",
  41555. false,
  41556. false
  41557. ],
  41558. "DOC": [
  41559. "DOC License",
  41560. false,
  41561. false
  41562. ],
  41563. "Dotseqn": [
  41564. "Dotseqn License",
  41565. false,
  41566. false
  41567. ],
  41568. "DSDP": [
  41569. "DSDP License",
  41570. false,
  41571. false
  41572. ],
  41573. "dvipdfm": [
  41574. "dvipdfm License",
  41575. false,
  41576. false
  41577. ],
  41578. "ECL-1.0": [
  41579. "Educational Community License v1.0",
  41580. true,
  41581. false
  41582. ],
  41583. "ECL-2.0": [
  41584. "Educational Community License v2.0",
  41585. true,
  41586. false
  41587. ],
  41588. "eCos-2.0": [
  41589. "eCos license version 2.0",
  41590. false,
  41591. true
  41592. ],
  41593. "EFL-1.0": [
  41594. "Eiffel Forum License v1.0",
  41595. true,
  41596. false
  41597. ],
  41598. "EFL-2.0": [
  41599. "Eiffel Forum License v2.0",
  41600. true,
  41601. false
  41602. ],
  41603. "eGenix": [
  41604. "eGenix.com Public License 1.1.0",
  41605. false,
  41606. false
  41607. ],
  41608. "Entessa": [
  41609. "Entessa Public License v1.0",
  41610. true,
  41611. false
  41612. ],
  41613. "EPICS": [
  41614. "EPICS Open License",
  41615. false,
  41616. false
  41617. ],
  41618. "EPL-1.0": [
  41619. "Eclipse Public License 1.0",
  41620. true,
  41621. false
  41622. ],
  41623. "EPL-2.0": [
  41624. "Eclipse Public License 2.0",
  41625. true,
  41626. false
  41627. ],
  41628. "ErlPL-1.1": [
  41629. "Erlang Public License v1.1",
  41630. false,
  41631. false
  41632. ],
  41633. "etalab-2.0": [
  41634. "Etalab Open License 2.0",
  41635. false,
  41636. false
  41637. ],
  41638. "EUDatagrid": [
  41639. "EU DataGrid Software License",
  41640. true,
  41641. false
  41642. ],
  41643. "EUPL-1.0": [
  41644. "European Union Public License 1.0",
  41645. false,
  41646. false
  41647. ],
  41648. "EUPL-1.1": [
  41649. "European Union Public License 1.1",
  41650. true,
  41651. false
  41652. ],
  41653. "EUPL-1.2": [
  41654. "European Union Public License 1.2",
  41655. true,
  41656. false
  41657. ],
  41658. "Eurosym": [
  41659. "Eurosym License",
  41660. false,
  41661. false
  41662. ],
  41663. "Fair": [
  41664. "Fair License",
  41665. true,
  41666. false
  41667. ],
  41668. "Frameworx-1.0": [
  41669. "Frameworx Open License 1.0",
  41670. true,
  41671. false
  41672. ],
  41673. "FreeImage": [
  41674. "FreeImage Public License v1.0",
  41675. false,
  41676. false
  41677. ],
  41678. "FSFAP": [
  41679. "FSF All Permissive License",
  41680. false,
  41681. false
  41682. ],
  41683. "FSFUL": [
  41684. "FSF Unlimited License",
  41685. false,
  41686. false
  41687. ],
  41688. "FSFULLR": [
  41689. "FSF Unlimited License (with License Retention)",
  41690. false,
  41691. false
  41692. ],
  41693. "FTL": [
  41694. "Freetype Project License",
  41695. false,
  41696. false
  41697. ],
  41698. "GFDL-1.1": [
  41699. "GNU Free Documentation License v1.1",
  41700. false,
  41701. true
  41702. ],
  41703. "GFDL-1.1-invariants-only": [
  41704. "GNU Free Documentation License v1.1 only - invariants",
  41705. false,
  41706. false
  41707. ],
  41708. "GFDL-1.1-invariants-or-later": [
  41709. "GNU Free Documentation License v1.1 or later - invariants",
  41710. false,
  41711. false
  41712. ],
  41713. "GFDL-1.1-no-invariants-only": [
  41714. "GNU Free Documentation License v1.1 only - no invariants",
  41715. false,
  41716. false
  41717. ],
  41718. "GFDL-1.1-no-invariants-or-later": [
  41719. "GNU Free Documentation License v1.1 or later - no invariants",
  41720. false,
  41721. false
  41722. ],
  41723. "GFDL-1.1-only": [
  41724. "GNU Free Documentation License v1.1 only",
  41725. false,
  41726. false
  41727. ],
  41728. "GFDL-1.1-or-later": [
  41729. "GNU Free Documentation License v1.1 or later",
  41730. false,
  41731. false
  41732. ],
  41733. "GFDL-1.2": [
  41734. "GNU Free Documentation License v1.2",
  41735. false,
  41736. true
  41737. ],
  41738. "GFDL-1.2-invariants-only": [
  41739. "GNU Free Documentation License v1.2 only - invariants",
  41740. false,
  41741. false
  41742. ],
  41743. "GFDL-1.2-invariants-or-later": [
  41744. "GNU Free Documentation License v1.2 or later - invariants",
  41745. false,
  41746. false
  41747. ],
  41748. "GFDL-1.2-no-invariants-only": [
  41749. "GNU Free Documentation License v1.2 only - no invariants",
  41750. false,
  41751. false
  41752. ],
  41753. "GFDL-1.2-no-invariants-or-later": [
  41754. "GNU Free Documentation License v1.2 or later - no invariants",
  41755. false,
  41756. false
  41757. ],
  41758. "GFDL-1.2-only": [
  41759. "GNU Free Documentation License v1.2 only",
  41760. false,
  41761. false
  41762. ],
  41763. "GFDL-1.2-or-later": [
  41764. "GNU Free Documentation License v1.2 or later",
  41765. false,
  41766. false
  41767. ],
  41768. "GFDL-1.3": [
  41769. "GNU Free Documentation License v1.3",
  41770. false,
  41771. true
  41772. ],
  41773. "GFDL-1.3-invariants-only": [
  41774. "GNU Free Documentation License v1.3 only - invariants",
  41775. false,
  41776. false
  41777. ],
  41778. "GFDL-1.3-invariants-or-later": [
  41779. "GNU Free Documentation License v1.3 or later - invariants",
  41780. false,
  41781. false
  41782. ],
  41783. "GFDL-1.3-no-invariants-only": [
  41784. "GNU Free Documentation License v1.3 only - no invariants",
  41785. false,
  41786. false
  41787. ],
  41788. "GFDL-1.3-no-invariants-or-later": [
  41789. "GNU Free Documentation License v1.3 or later - no invariants",
  41790. false,
  41791. false
  41792. ],
  41793. "GFDL-1.3-only": [
  41794. "GNU Free Documentation License v1.3 only",
  41795. false,
  41796. false
  41797. ],
  41798. "GFDL-1.3-or-later": [
  41799. "GNU Free Documentation License v1.3 or later",
  41800. false,
  41801. false
  41802. ],
  41803. "Giftware": [
  41804. "Giftware License",
  41805. false,
  41806. false
  41807. ],
  41808. "GL2PS": [
  41809. "GL2PS License",
  41810. false,
  41811. false
  41812. ],
  41813. "Glide": [
  41814. "3dfx Glide License",
  41815. false,
  41816. false
  41817. ],
  41818. "Glulxe": [
  41819. "Glulxe License",
  41820. false,
  41821. false
  41822. ],
  41823. "GLWTPL": [
  41824. "Good Luck With That Public License",
  41825. false,
  41826. false
  41827. ],
  41828. "gnuplot": [
  41829. "gnuplot License",
  41830. false,
  41831. false
  41832. ],
  41833. "GPL-1.0": [
  41834. "GNU General Public License v1.0 only",
  41835. false,
  41836. true
  41837. ],
  41838. "GPL-1.0+": [
  41839. "GNU General Public License v1.0 or later",
  41840. false,
  41841. true
  41842. ],
  41843. "GPL-1.0-only": [
  41844. "GNU General Public License v1.0 only",
  41845. false,
  41846. false
  41847. ],
  41848. "GPL-1.0-or-later": [
  41849. "GNU General Public License v1.0 or later",
  41850. false,
  41851. false
  41852. ],
  41853. "GPL-2.0": [
  41854. "GNU General Public License v2.0 only",
  41855. true,
  41856. true
  41857. ],
  41858. "GPL-2.0+": [
  41859. "GNU General Public License v2.0 or later",
  41860. true,
  41861. true
  41862. ],
  41863. "GPL-2.0-only": [
  41864. "GNU General Public License v2.0 only",
  41865. true,
  41866. false
  41867. ],
  41868. "GPL-2.0-or-later": [
  41869. "GNU General Public License v2.0 or later",
  41870. true,
  41871. false
  41872. ],
  41873. "GPL-2.0-with-autoconf-exception": [
  41874. "GNU General Public License v2.0 w/Autoconf exception",
  41875. false,
  41876. true
  41877. ],
  41878. "GPL-2.0-with-bison-exception": [
  41879. "GNU General Public License v2.0 w/Bison exception",
  41880. false,
  41881. true
  41882. ],
  41883. "GPL-2.0-with-classpath-exception": [
  41884. "GNU General Public License v2.0 w/Classpath exception",
  41885. false,
  41886. true
  41887. ],
  41888. "GPL-2.0-with-font-exception": [
  41889. "GNU General Public License v2.0 w/Font exception",
  41890. false,
  41891. true
  41892. ],
  41893. "GPL-2.0-with-GCC-exception": [
  41894. "GNU General Public License v2.0 w/GCC Runtime Library exception",
  41895. false,
  41896. true
  41897. ],
  41898. "GPL-3.0": [
  41899. "GNU General Public License v3.0 only",
  41900. true,
  41901. true
  41902. ],
  41903. "GPL-3.0+": [
  41904. "GNU General Public License v3.0 or later",
  41905. true,
  41906. true
  41907. ],
  41908. "GPL-3.0-only": [
  41909. "GNU General Public License v3.0 only",
  41910. true,
  41911. false
  41912. ],
  41913. "GPL-3.0-or-later": [
  41914. "GNU General Public License v3.0 or later",
  41915. true,
  41916. false
  41917. ],
  41918. "GPL-3.0-with-autoconf-exception": [
  41919. "GNU General Public License v3.0 w/Autoconf exception",
  41920. false,
  41921. true
  41922. ],
  41923. "GPL-3.0-with-GCC-exception": [
  41924. "GNU General Public License v3.0 w/GCC Runtime Library exception",
  41925. true,
  41926. true
  41927. ],
  41928. "gSOAP-1.3b": [
  41929. "gSOAP Public License v1.3b",
  41930. false,
  41931. false
  41932. ],
  41933. "HaskellReport": [
  41934. "Haskell Language Report License",
  41935. false,
  41936. false
  41937. ],
  41938. "Hippocratic-2.1": [
  41939. "Hippocratic License 2.1",
  41940. false,
  41941. false
  41942. ],
  41943. "HPND": [
  41944. "Historical Permission Notice and Disclaimer",
  41945. true,
  41946. false
  41947. ],
  41948. "HPND-sell-variant": [
  41949. "Historical Permission Notice and Disclaimer - sell variant",
  41950. false,
  41951. false
  41952. ],
  41953. "HTMLTIDY": [
  41954. "HTML Tidy License",
  41955. false,
  41956. false
  41957. ],
  41958. "IBM-pibs": [
  41959. "IBM PowerPC Initialization and Boot Software",
  41960. false,
  41961. false
  41962. ],
  41963. "ICU": [
  41964. "ICU License",
  41965. false,
  41966. false
  41967. ],
  41968. "IJG": [
  41969. "Independent JPEG Group License",
  41970. false,
  41971. false
  41972. ],
  41973. "ImageMagick": [
  41974. "ImageMagick License",
  41975. false,
  41976. false
  41977. ],
  41978. "iMatix": [
  41979. "iMatix Standard Function Library Agreement",
  41980. false,
  41981. false
  41982. ],
  41983. "Imlib2": [
  41984. "Imlib2 License",
  41985. false,
  41986. false
  41987. ],
  41988. "Info-ZIP": [
  41989. "Info-ZIP License",
  41990. false,
  41991. false
  41992. ],
  41993. "Intel": [
  41994. "Intel Open Source License",
  41995. true,
  41996. false
  41997. ],
  41998. "Intel-ACPI": [
  41999. "Intel ACPI Software License Agreement",
  42000. false,
  42001. false
  42002. ],
  42003. "Interbase-1.0": [
  42004. "Interbase Public License v1.0",
  42005. false,
  42006. false
  42007. ],
  42008. "IPA": [
  42009. "IPA Font License",
  42010. true,
  42011. false
  42012. ],
  42013. "IPL-1.0": [
  42014. "IBM Public License v1.0",
  42015. true,
  42016. false
  42017. ],
  42018. "ISC": [
  42019. "ISC License",
  42020. true,
  42021. false
  42022. ],
  42023. "JasPer-2.0": [
  42024. "JasPer License",
  42025. false,
  42026. false
  42027. ],
  42028. "JPNIC": [
  42029. "Japan Network Information Center License",
  42030. false,
  42031. false
  42032. ],
  42033. "JSON": [
  42034. "JSON License",
  42035. false,
  42036. false
  42037. ],
  42038. "LAL-1.2": [
  42039. "Licence Art Libre 1.2",
  42040. false,
  42041. false
  42042. ],
  42043. "LAL-1.3": [
  42044. "Licence Art Libre 1.3",
  42045. false,
  42046. false
  42047. ],
  42048. "Latex2e": [
  42049. "Latex2e License",
  42050. false,
  42051. false
  42052. ],
  42053. "Leptonica": [
  42054. "Leptonica License",
  42055. false,
  42056. false
  42057. ],
  42058. "LGPL-2.0": [
  42059. "GNU Library General Public License v2 only",
  42060. true,
  42061. true
  42062. ],
  42063. "LGPL-2.0+": [
  42064. "GNU Library General Public License v2 or later",
  42065. true,
  42066. true
  42067. ],
  42068. "LGPL-2.0-only": [
  42069. "GNU Library General Public License v2 only",
  42070. true,
  42071. false
  42072. ],
  42073. "LGPL-2.0-or-later": [
  42074. "GNU Library General Public License v2 or later",
  42075. true,
  42076. false
  42077. ],
  42078. "LGPL-2.1": [
  42079. "GNU Lesser General Public License v2.1 only",
  42080. true,
  42081. true
  42082. ],
  42083. "LGPL-2.1+": [
  42084. "GNU Library General Public License v2.1 or later",
  42085. true,
  42086. true
  42087. ],
  42088. "LGPL-2.1-only": [
  42089. "GNU Lesser General Public License v2.1 only",
  42090. true,
  42091. false
  42092. ],
  42093. "LGPL-2.1-or-later": [
  42094. "GNU Lesser General Public License v2.1 or later",
  42095. true,
  42096. false
  42097. ],
  42098. "LGPL-3.0": [
  42099. "GNU Lesser General Public License v3.0 only",
  42100. true,
  42101. true
  42102. ],
  42103. "LGPL-3.0+": [
  42104. "GNU Lesser General Public License v3.0 or later",
  42105. true,
  42106. true
  42107. ],
  42108. "LGPL-3.0-only": [
  42109. "GNU Lesser General Public License v3.0 only",
  42110. true,
  42111. false
  42112. ],
  42113. "LGPL-3.0-or-later": [
  42114. "GNU Lesser General Public License v3.0 or later",
  42115. true,
  42116. false
  42117. ],
  42118. "LGPLLR": [
  42119. "Lesser General Public License For Linguistic Resources",
  42120. false,
  42121. false
  42122. ],
  42123. "Libpng": [
  42124. "libpng License",
  42125. false,
  42126. false
  42127. ],
  42128. "libpng-2.0": [
  42129. "PNG Reference Library version 2",
  42130. false,
  42131. false
  42132. ],
  42133. "libselinux-1.0": [
  42134. "libselinux public domain notice",
  42135. false,
  42136. false
  42137. ],
  42138. "libtiff": [
  42139. "libtiff License",
  42140. false,
  42141. false
  42142. ],
  42143. "LiLiQ-P-1.1": [
  42144. "Licence Libre du Qu\u00e9bec \u2013 Permissive version 1.1",
  42145. true,
  42146. false
  42147. ],
  42148. "LiLiQ-R-1.1": [
  42149. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 version 1.1",
  42150. true,
  42151. false
  42152. ],
  42153. "LiLiQ-Rplus-1.1": [
  42154. "Licence Libre du Qu\u00e9bec \u2013 R\u00e9ciprocit\u00e9 forte version 1.1",
  42155. true,
  42156. false
  42157. ],
  42158. "Linux-OpenIB": [
  42159. "Linux Kernel Variant of OpenIB.org license",
  42160. false,
  42161. false
  42162. ],
  42163. "LPL-1.0": [
  42164. "Lucent Public License Version 1.0",
  42165. true,
  42166. false
  42167. ],
  42168. "LPL-1.02": [
  42169. "Lucent Public License v1.02",
  42170. true,
  42171. false
  42172. ],
  42173. "LPPL-1.0": [
  42174. "LaTeX Project Public License v1.0",
  42175. false,
  42176. false
  42177. ],
  42178. "LPPL-1.1": [
  42179. "LaTeX Project Public License v1.1",
  42180. false,
  42181. false
  42182. ],
  42183. "LPPL-1.2": [
  42184. "LaTeX Project Public License v1.2",
  42185. false,
  42186. false
  42187. ],
  42188. "LPPL-1.3a": [
  42189. "LaTeX Project Public License v1.3a",
  42190. false,
  42191. false
  42192. ],
  42193. "LPPL-1.3c": [
  42194. "LaTeX Project Public License v1.3c",
  42195. true,
  42196. false
  42197. ],
  42198. "MakeIndex": [
  42199. "MakeIndex License",
  42200. false,
  42201. false
  42202. ],
  42203. "MirOS": [
  42204. "The MirOS Licence",
  42205. true,
  42206. false
  42207. ],
  42208. "MIT": [
  42209. "MIT License",
  42210. true,
  42211. false
  42212. ],
  42213. "MIT-0": [
  42214. "MIT No Attribution",
  42215. true,
  42216. false
  42217. ],
  42218. "MIT-advertising": [
  42219. "Enlightenment License (e16)",
  42220. false,
  42221. false
  42222. ],
  42223. "MIT-CMU": [
  42224. "CMU License",
  42225. false,
  42226. false
  42227. ],
  42228. "MIT-enna": [
  42229. "enna License",
  42230. false,
  42231. false
  42232. ],
  42233. "MIT-feh": [
  42234. "feh License",
  42235. false,
  42236. false
  42237. ],
  42238. "MIT-open-group": [
  42239. "MIT Open Group variant",
  42240. false,
  42241. false
  42242. ],
  42243. "MITNFA": [
  42244. "MIT +no-false-attribs license",
  42245. false,
  42246. false
  42247. ],
  42248. "Motosoto": [
  42249. "Motosoto License",
  42250. true,
  42251. false
  42252. ],
  42253. "mpich2": [
  42254. "mpich2 License",
  42255. false,
  42256. false
  42257. ],
  42258. "MPL-1.0": [
  42259. "Mozilla Public License 1.0",
  42260. true,
  42261. false
  42262. ],
  42263. "MPL-1.1": [
  42264. "Mozilla Public License 1.1",
  42265. true,
  42266. false
  42267. ],
  42268. "MPL-2.0": [
  42269. "Mozilla Public License 2.0",
  42270. true,
  42271. false
  42272. ],
  42273. "MPL-2.0-no-copyleft-exception": [
  42274. "Mozilla Public License 2.0 (no copyleft exception)",
  42275. true,
  42276. false
  42277. ],
  42278. "MS-PL": [
  42279. "Microsoft Public License",
  42280. true,
  42281. false
  42282. ],
  42283. "MS-RL": [
  42284. "Microsoft Reciprocal License",
  42285. true,
  42286. false
  42287. ],
  42288. "MTLL": [
  42289. "Matrix Template Library License",
  42290. false,
  42291. false
  42292. ],
  42293. "MulanPSL-1.0": [
  42294. "Mulan Permissive Software License, Version 1",
  42295. false,
  42296. false
  42297. ],
  42298. "MulanPSL-2.0": [
  42299. "Mulan Permissive Software License, Version 2",
  42300. true,
  42301. false
  42302. ],
  42303. "Multics": [
  42304. "Multics License",
  42305. true,
  42306. false
  42307. ],
  42308. "Mup": [
  42309. "Mup License",
  42310. false,
  42311. false
  42312. ],
  42313. "NASA-1.3": [
  42314. "NASA Open Source Agreement 1.3",
  42315. true,
  42316. false
  42317. ],
  42318. "Naumen": [
  42319. "Naumen Public License",
  42320. true,
  42321. false
  42322. ],
  42323. "NBPL-1.0": [
  42324. "Net Boolean Public License v1",
  42325. false,
  42326. false
  42327. ],
  42328. "NCGL-UK-2.0": [
  42329. "Non-Commercial Government Licence",
  42330. false,
  42331. false
  42332. ],
  42333. "NCSA": [
  42334. "University of Illinois/NCSA Open Source License",
  42335. true,
  42336. false
  42337. ],
  42338. "Net-SNMP": [
  42339. "Net-SNMP License",
  42340. false,
  42341. false
  42342. ],
  42343. "NetCDF": [
  42344. "NetCDF license",
  42345. false,
  42346. false
  42347. ],
  42348. "Newsletr": [
  42349. "Newsletr License",
  42350. false,
  42351. false
  42352. ],
  42353. "NGPL": [
  42354. "Nethack General Public License",
  42355. true,
  42356. false
  42357. ],
  42358. "NIST-PD": [
  42359. "NIST Public Domain Notice",
  42360. false,
  42361. false
  42362. ],
  42363. "NIST-PD-fallback": [
  42364. "NIST Public Domain Notice with license fallback",
  42365. false,
  42366. false
  42367. ],
  42368. "NLOD-1.0": [
  42369. "Norwegian Licence for Open Government Data",
  42370. false,
  42371. false
  42372. ],
  42373. "NLPL": [
  42374. "No Limit Public License",
  42375. false,
  42376. false
  42377. ],
  42378. "Nokia": [
  42379. "Nokia Open Source License",
  42380. true,
  42381. false
  42382. ],
  42383. "NOSL": [
  42384. "Netizen Open Source License",
  42385. false,
  42386. false
  42387. ],
  42388. "Noweb": [
  42389. "Noweb License",
  42390. false,
  42391. false
  42392. ],
  42393. "NPL-1.0": [
  42394. "Netscape Public License v1.0",
  42395. false,
  42396. false
  42397. ],
  42398. "NPL-1.1": [
  42399. "Netscape Public License v1.1",
  42400. false,
  42401. false
  42402. ],
  42403. "NPOSL-3.0": [
  42404. "Non-Profit Open Software License 3.0",
  42405. true,
  42406. false
  42407. ],
  42408. "NRL": [
  42409. "NRL License",
  42410. false,
  42411. false
  42412. ],
  42413. "NTP": [
  42414. "NTP License",
  42415. true,
  42416. false
  42417. ],
  42418. "NTP-0": [
  42419. "NTP No Attribution",
  42420. false,
  42421. false
  42422. ],
  42423. "Nunit": [
  42424. "Nunit License",
  42425. false,
  42426. true
  42427. ],
  42428. "O-UDA-1.0": [
  42429. "Open Use of Data Agreement v1.0",
  42430. false,
  42431. false
  42432. ],
  42433. "OCCT-PL": [
  42434. "Open CASCADE Technology Public License",
  42435. false,
  42436. false
  42437. ],
  42438. "OCLC-2.0": [
  42439. "OCLC Research Public License 2.0",
  42440. true,
  42441. false
  42442. ],
  42443. "ODbL-1.0": [
  42444. "ODC Open Database License v1.0",
  42445. false,
  42446. false
  42447. ],
  42448. "ODC-By-1.0": [
  42449. "Open Data Commons Attribution License v1.0",
  42450. false,
  42451. false
  42452. ],
  42453. "OFL-1.0": [
  42454. "SIL Open Font License 1.0",
  42455. false,
  42456. false
  42457. ],
  42458. "OFL-1.0-no-RFN": [
  42459. "SIL Open Font License 1.0 with no Reserved Font Name",
  42460. false,
  42461. false
  42462. ],
  42463. "OFL-1.0-RFN": [
  42464. "SIL Open Font License 1.0 with Reserved Font Name",
  42465. false,
  42466. false
  42467. ],
  42468. "OFL-1.1": [
  42469. "SIL Open Font License 1.1",
  42470. true,
  42471. false
  42472. ],
  42473. "OFL-1.1-no-RFN": [
  42474. "SIL Open Font License 1.1 with no Reserved Font Name",
  42475. true,
  42476. false
  42477. ],
  42478. "OFL-1.1-RFN": [
  42479. "SIL Open Font License 1.1 with Reserved Font Name",
  42480. true,
  42481. false
  42482. ],
  42483. "OGC-1.0": [
  42484. "OGC Software License, Version 1.0",
  42485. false,
  42486. false
  42487. ],
  42488. "OGL-Canada-2.0": [
  42489. "Open Government Licence - Canada",
  42490. false,
  42491. false
  42492. ],
  42493. "OGL-UK-1.0": [
  42494. "Open Government Licence v1.0",
  42495. false,
  42496. false
  42497. ],
  42498. "OGL-UK-2.0": [
  42499. "Open Government Licence v2.0",
  42500. false,
  42501. false
  42502. ],
  42503. "OGL-UK-3.0": [
  42504. "Open Government Licence v3.0",
  42505. false,
  42506. false
  42507. ],
  42508. "OGTSL": [
  42509. "Open Group Test Suite License",
  42510. true,
  42511. false
  42512. ],
  42513. "OLDAP-1.1": [
  42514. "Open LDAP Public License v1.1",
  42515. false,
  42516. false
  42517. ],
  42518. "OLDAP-1.2": [
  42519. "Open LDAP Public License v1.2",
  42520. false,
  42521. false
  42522. ],
  42523. "OLDAP-1.3": [
  42524. "Open LDAP Public License v1.3",
  42525. false,
  42526. false
  42527. ],
  42528. "OLDAP-1.4": [
  42529. "Open LDAP Public License v1.4",
  42530. false,
  42531. false
  42532. ],
  42533. "OLDAP-2.0": [
  42534. "Open LDAP Public License v2.0 (or possibly 2.0A and 2.0B)",
  42535. false,
  42536. false
  42537. ],
  42538. "OLDAP-2.0.1": [
  42539. "Open LDAP Public License v2.0.1",
  42540. false,
  42541. false
  42542. ],
  42543. "OLDAP-2.1": [
  42544. "Open LDAP Public License v2.1",
  42545. false,
  42546. false
  42547. ],
  42548. "OLDAP-2.2": [
  42549. "Open LDAP Public License v2.2",
  42550. false,
  42551. false
  42552. ],
  42553. "OLDAP-2.2.1": [
  42554. "Open LDAP Public License v2.2.1",
  42555. false,
  42556. false
  42557. ],
  42558. "OLDAP-2.2.2": [
  42559. "Open LDAP Public License 2.2.2",
  42560. false,
  42561. false
  42562. ],
  42563. "OLDAP-2.3": [
  42564. "Open LDAP Public License v2.3",
  42565. false,
  42566. false
  42567. ],
  42568. "OLDAP-2.4": [
  42569. "Open LDAP Public License v2.4",
  42570. false,
  42571. false
  42572. ],
  42573. "OLDAP-2.5": [
  42574. "Open LDAP Public License v2.5",
  42575. false,
  42576. false
  42577. ],
  42578. "OLDAP-2.6": [
  42579. "Open LDAP Public License v2.6",
  42580. false,
  42581. false
  42582. ],
  42583. "OLDAP-2.7": [
  42584. "Open LDAP Public License v2.7",
  42585. false,
  42586. false
  42587. ],
  42588. "OLDAP-2.8": [
  42589. "Open LDAP Public License v2.8",
  42590. true,
  42591. false
  42592. ],
  42593. "OML": [
  42594. "Open Market License",
  42595. false,
  42596. false
  42597. ],
  42598. "OpenSSL": [
  42599. "OpenSSL License",
  42600. false,
  42601. false
  42602. ],
  42603. "OPL-1.0": [
  42604. "Open Public License v1.0",
  42605. false,
  42606. false
  42607. ],
  42608. "OSET-PL-2.1": [
  42609. "OSET Public License version 2.1",
  42610. true,
  42611. false
  42612. ],
  42613. "OSL-1.0": [
  42614. "Open Software License 1.0",
  42615. true,
  42616. false
  42617. ],
  42618. "OSL-1.1": [
  42619. "Open Software License 1.1",
  42620. false,
  42621. false
  42622. ],
  42623. "OSL-2.0": [
  42624. "Open Software License 2.0",
  42625. true,
  42626. false
  42627. ],
  42628. "OSL-2.1": [
  42629. "Open Software License 2.1",
  42630. true,
  42631. false
  42632. ],
  42633. "OSL-3.0": [
  42634. "Open Software License 3.0",
  42635. true,
  42636. false
  42637. ],
  42638. "Parity-6.0.0": [
  42639. "The Parity Public License 6.0.0",
  42640. false,
  42641. false
  42642. ],
  42643. "Parity-7.0.0": [
  42644. "The Parity Public License 7.0.0",
  42645. false,
  42646. false
  42647. ],
  42648. "PDDL-1.0": [
  42649. "ODC Public Domain Dedication & License 1.0",
  42650. false,
  42651. false
  42652. ],
  42653. "PHP-3.0": [
  42654. "PHP License v3.0",
  42655. true,
  42656. false
  42657. ],
  42658. "PHP-3.01": [
  42659. "PHP License v3.01",
  42660. true,
  42661. false
  42662. ],
  42663. "Plexus": [
  42664. "Plexus Classworlds License",
  42665. false,
  42666. false
  42667. ],
  42668. "PolyForm-Noncommercial-1.0.0": [
  42669. "PolyForm Noncommercial License 1.0.0",
  42670. false,
  42671. false
  42672. ],
  42673. "PolyForm-Small-Business-1.0.0": [
  42674. "PolyForm Small Business License 1.0.0",
  42675. false,
  42676. false
  42677. ],
  42678. "PostgreSQL": [
  42679. "PostgreSQL License",
  42680. true,
  42681. false
  42682. ],
  42683. "PSF-2.0": [
  42684. "Python Software Foundation License 2.0",
  42685. false,
  42686. false
  42687. ],
  42688. "psfrag": [
  42689. "psfrag License",
  42690. false,
  42691. false
  42692. ],
  42693. "psutils": [
  42694. "psutils License",
  42695. false,
  42696. false
  42697. ],
  42698. "Python-2.0": [
  42699. "Python License 2.0",
  42700. true,
  42701. false
  42702. ],
  42703. "Qhull": [
  42704. "Qhull License",
  42705. false,
  42706. false
  42707. ],
  42708. "QPL-1.0": [
  42709. "Q Public License 1.0",
  42710. true,
  42711. false
  42712. ],
  42713. "Rdisc": [
  42714. "Rdisc License",
  42715. false,
  42716. false
  42717. ],
  42718. "RHeCos-1.1": [
  42719. "Red Hat eCos Public License v1.1",
  42720. false,
  42721. false
  42722. ],
  42723. "RPL-1.1": [
  42724. "Reciprocal Public License 1.1",
  42725. true,
  42726. false
  42727. ],
  42728. "RPL-1.5": [
  42729. "Reciprocal Public License 1.5",
  42730. true,
  42731. false
  42732. ],
  42733. "RPSL-1.0": [
  42734. "RealNetworks Public Source License v1.0",
  42735. true,
  42736. false
  42737. ],
  42738. "RSA-MD": [
  42739. "RSA Message-Digest License",
  42740. false,
  42741. false
  42742. ],
  42743. "RSCPL": [
  42744. "Ricoh Source Code Public License",
  42745. true,
  42746. false
  42747. ],
  42748. "Ruby": [
  42749. "Ruby License",
  42750. false,
  42751. false
  42752. ],
  42753. "SAX-PD": [
  42754. "Sax Public Domain Notice",
  42755. false,
  42756. false
  42757. ],
  42758. "Saxpath": [
  42759. "Saxpath License",
  42760. false,
  42761. false
  42762. ],
  42763. "SCEA": [
  42764. "SCEA Shared Source License",
  42765. false,
  42766. false
  42767. ],
  42768. "Sendmail": [
  42769. "Sendmail License",
  42770. false,
  42771. false
  42772. ],
  42773. "Sendmail-8.23": [
  42774. "Sendmail License 8.23",
  42775. false,
  42776. false
  42777. ],
  42778. "SGI-B-1.0": [
  42779. "SGI Free Software License B v1.0",
  42780. false,
  42781. false
  42782. ],
  42783. "SGI-B-1.1": [
  42784. "SGI Free Software License B v1.1",
  42785. false,
  42786. false
  42787. ],
  42788. "SGI-B-2.0": [
  42789. "SGI Free Software License B v2.0",
  42790. false,
  42791. false
  42792. ],
  42793. "SHL-0.5": [
  42794. "Solderpad Hardware License v0.5",
  42795. false,
  42796. false
  42797. ],
  42798. "SHL-0.51": [
  42799. "Solderpad Hardware License, Version 0.51",
  42800. false,
  42801. false
  42802. ],
  42803. "SimPL-2.0": [
  42804. "Simple Public License 2.0",
  42805. true,
  42806. false
  42807. ],
  42808. "SISSL": [
  42809. "Sun Industry Standards Source License v1.1",
  42810. true,
  42811. false
  42812. ],
  42813. "SISSL-1.2": [
  42814. "Sun Industry Standards Source License v1.2",
  42815. false,
  42816. false
  42817. ],
  42818. "Sleepycat": [
  42819. "Sleepycat License",
  42820. true,
  42821. false
  42822. ],
  42823. "SMLNJ": [
  42824. "Standard ML of New Jersey License",
  42825. false,
  42826. false
  42827. ],
  42828. "SMPPL": [
  42829. "Secure Messaging Protocol Public License",
  42830. false,
  42831. false
  42832. ],
  42833. "SNIA": [
  42834. "SNIA Public License 1.1",
  42835. false,
  42836. false
  42837. ],
  42838. "Spencer-86": [
  42839. "Spencer License 86",
  42840. false,
  42841. false
  42842. ],
  42843. "Spencer-94": [
  42844. "Spencer License 94",
  42845. false,
  42846. false
  42847. ],
  42848. "Spencer-99": [
  42849. "Spencer License 99",
  42850. false,
  42851. false
  42852. ],
  42853. "SPL-1.0": [
  42854. "Sun Public License v1.0",
  42855. true,
  42856. false
  42857. ],
  42858. "SSH-OpenSSH": [
  42859. "SSH OpenSSH license",
  42860. false,
  42861. false
  42862. ],
  42863. "SSH-short": [
  42864. "SSH short notice",
  42865. false,
  42866. false
  42867. ],
  42868. "SSPL-1.0": [
  42869. "Server Side Public License, v 1",
  42870. false,
  42871. false
  42872. ],
  42873. "StandardML-NJ": [
  42874. "Standard ML of New Jersey License",
  42875. false,
  42876. true
  42877. ],
  42878. "SugarCRM-1.1.3": [
  42879. "SugarCRM Public License v1.1.3",
  42880. false,
  42881. false
  42882. ],
  42883. "SWL": [
  42884. "Scheme Widget Library (SWL) Software License Agreement",
  42885. false,
  42886. false
  42887. ],
  42888. "TAPR-OHL-1.0": [
  42889. "TAPR Open Hardware License v1.0",
  42890. false,
  42891. false
  42892. ],
  42893. "TCL": [
  42894. "TCL/TK License",
  42895. false,
  42896. false
  42897. ],
  42898. "TCP-wrappers": [
  42899. "TCP Wrappers License",
  42900. false,
  42901. false
  42902. ],
  42903. "TMate": [
  42904. "TMate Open Source License",
  42905. false,
  42906. false
  42907. ],
  42908. "TORQUE-1.1": [
  42909. "TORQUE v2.5+ Software License v1.1",
  42910. false,
  42911. false
  42912. ],
  42913. "TOSL": [
  42914. "Trusster Open Source License",
  42915. false,
  42916. false
  42917. ],
  42918. "TU-Berlin-1.0": [
  42919. "Technische Universitaet Berlin License 1.0",
  42920. false,
  42921. false
  42922. ],
  42923. "TU-Berlin-2.0": [
  42924. "Technische Universitaet Berlin License 2.0",
  42925. false,
  42926. false
  42927. ],
  42928. "UCL-1.0": [
  42929. "Upstream Compatibility License v1.0",
  42930. true,
  42931. false
  42932. ],
  42933. "Unicode-DFS-2015": [
  42934. "Unicode License Agreement - Data Files and Software (2015)",
  42935. false,
  42936. false
  42937. ],
  42938. "Unicode-DFS-2016": [
  42939. "Unicode License Agreement - Data Files and Software (2016)",
  42940. true,
  42941. false
  42942. ],
  42943. "Unicode-TOU": [
  42944. "Unicode Terms of Use",
  42945. false,
  42946. false
  42947. ],
  42948. "Unlicense": [
  42949. "The Unlicense",
  42950. true,
  42951. false
  42952. ],
  42953. "UPL-1.0": [
  42954. "Universal Permissive License v1.0",
  42955. true,
  42956. false
  42957. ],
  42958. "Vim": [
  42959. "Vim License",
  42960. false,
  42961. false
  42962. ],
  42963. "VOSTROM": [
  42964. "VOSTROM Public License for Open Source",
  42965. false,
  42966. false
  42967. ],
  42968. "VSL-1.0": [
  42969. "Vovida Software License v1.0",
  42970. true,
  42971. false
  42972. ],
  42973. "W3C": [
  42974. "W3C Software Notice and License (2002-12-31)",
  42975. true,
  42976. false
  42977. ],
  42978. "W3C-19980720": [
  42979. "W3C Software Notice and License (1998-07-20)",
  42980. false,
  42981. false
  42982. ],
  42983. "W3C-20150513": [
  42984. "W3C Software Notice and Document License (2015-05-13)",
  42985. false,
  42986. false
  42987. ],
  42988. "Watcom-1.0": [
  42989. "Sybase Open Watcom Public License 1.0",
  42990. true,
  42991. false
  42992. ],
  42993. "Wsuipa": [
  42994. "Wsuipa License",
  42995. false,
  42996. false
  42997. ],
  42998. "WTFPL": [
  42999. "Do What The F*ck You Want To Public License",
  43000. false,
  43001. false
  43002. ],
  43003. "wxWindows": [
  43004. "wxWindows Library License",
  43005. false,
  43006. true
  43007. ],
  43008. "X11": [
  43009. "X11 License",
  43010. false,
  43011. false
  43012. ],
  43013. "Xerox": [
  43014. "Xerox License",
  43015. false,
  43016. false
  43017. ],
  43018. "XFree86-1.1": [
  43019. "XFree86 License 1.1",
  43020. false,
  43021. false
  43022. ],
  43023. "xinetd": [
  43024. "xinetd License",
  43025. false,
  43026. false
  43027. ],
  43028. "Xnet": [
  43029. "X.Net License",
  43030. true,
  43031. false
  43032. ],
  43033. "xpp": [
  43034. "XPP License",
  43035. false,
  43036. false
  43037. ],
  43038. "XSkat": [
  43039. "XSkat License",
  43040. false,
  43041. false
  43042. ],
  43043. "YPL-1.0": [
  43044. "Yahoo! Public License v1.0",
  43045. false,
  43046. false
  43047. ],
  43048. "YPL-1.1": [
  43049. "Yahoo! Public License v1.1",
  43050. false,
  43051. false
  43052. ],
  43053. "Zed": [
  43054. "Zed License",
  43055. false,
  43056. false
  43057. ],
  43058. "Zend-2.0": [
  43059. "Zend License v2.0",
  43060. false,
  43061. false
  43062. ],
  43063. "Zimbra-1.3": [
  43064. "Zimbra Public License v1.3",
  43065. false,
  43066. false
  43067. ],
  43068. "Zimbra-1.4": [
  43069. "Zimbra Public License v1.4",
  43070. false,
  43071. false
  43072. ],
  43073. "Zlib": [
  43074. "zlib License",
  43075. true,
  43076. false
  43077. ],
  43078. "zlib-acknowledgement": [
  43079. "zlib/libpng License with Acknowledgement",
  43080. false,
  43081. false
  43082. ],
  43083. "ZPL-1.1": [
  43084. "Zope Public License 1.1",
  43085. false,
  43086. false
  43087. ],
  43088. "ZPL-2.0": [
  43089. "Zope Public License 2.0",
  43090. true,
  43091. false
  43092. ],
  43093. "ZPL-2.1": [
  43094. "Zope Public License 2.1",
  43095. false,
  43096. false
  43097. ]
  43098. }<?php
  43099. namespace Composer\Spdx;
  43100. class SpdxLicenses
  43101. {
  43102. const LICENSES_FILE = 'spdx-licenses.json';
  43103. const EXCEPTIONS_FILE = 'spdx-exceptions.json';
  43104. private $licenses;
  43105. private $licensesExpression;
  43106. private $exceptions;
  43107. private $exceptionsExpression;
  43108. public function __construct()
  43109. {
  43110. $this->loadLicenses();
  43111. $this->loadExceptions();
  43112. }
  43113. public function getLicenseByIdentifier($identifier)
  43114. {
  43115. $key = strtolower($identifier);
  43116. if (!isset($this->licenses[$key])) {
  43117. return;
  43118. }
  43119. list($identifier, $name, $isOsiApproved, $isDeprecatedLicenseId) = $this->licenses[$key];
  43120. return array(
  43121. $name,
  43122. $isOsiApproved,
  43123. 'https://spdx.org/licenses/' . $identifier . '.html#licenseText',
  43124. $isDeprecatedLicenseId,
  43125. );
  43126. }
  43127. public function getLicenses()
  43128. {
  43129. return $this->licenses;
  43130. }
  43131. public function getExceptionByIdentifier($identifier)
  43132. {
  43133. $key = strtolower($identifier);
  43134. if (!isset($this->exceptions[$key])) {
  43135. return;
  43136. }
  43137. list($identifier, $name) = $this->exceptions[$key];
  43138. return array(
  43139. $name,
  43140. 'https://spdx.org/licenses/' . $identifier . '.html#licenseExceptionText',
  43141. );
  43142. }
  43143. public function getIdentifierByName($name)
  43144. {
  43145. foreach ($this->licenses as $licenseData) {
  43146. if ($licenseData[1] === $name) {
  43147. return $licenseData[0];
  43148. }
  43149. }
  43150. foreach ($this->exceptions as $licenseData) {
  43151. if ($licenseData[1] === $name) {
  43152. return $licenseData[0];
  43153. }
  43154. }
  43155. }
  43156. public function isOsiApprovedByIdentifier($identifier)
  43157. {
  43158. return $this->licenses[strtolower($identifier)][2];
  43159. }
  43160. public function isDeprecatedByIdentifier($identifier)
  43161. {
  43162. return $this->licenses[strtolower($identifier)][3];
  43163. }
  43164. public function validate($license)
  43165. {
  43166. if (is_array($license)) {
  43167. $count = count($license);
  43168. if ($count !== count(array_filter($license, 'is_string'))) {
  43169. throw new \InvalidArgumentException('Array of strings expected.');
  43170. }
  43171. $license = $count > 1 ? '(' . implode(' OR ', $license) . ')' : (string) reset($license);
  43172. }
  43173. if (!is_string($license)) {
  43174. throw new \InvalidArgumentException(sprintf(
  43175. 'Array or String expected, %s given.',
  43176. gettype($license)
  43177. ));
  43178. }
  43179. return $this->isValidLicenseString($license);
  43180. }
  43181. public static function getResourcesDir()
  43182. {
  43183. return dirname(__DIR__) . '/res';
  43184. }
  43185. private function loadLicenses()
  43186. {
  43187. if (null !== $this->licenses) {
  43188. return;
  43189. }
  43190. $json = file_get_contents(self::getResourcesDir() . '/' . self::LICENSES_FILE);
  43191. $this->licenses = array();
  43192. foreach (json_decode($json, true) as $identifier => $license) {
  43193. $this->licenses[strtolower($identifier)] = array($identifier, $license[0], $license[1], $license[2]);
  43194. }
  43195. }
  43196. private function loadExceptions()
  43197. {
  43198. if (null !== $this->exceptions) {
  43199. return;
  43200. }
  43201. $json = file_get_contents(self::getResourcesDir() . '/' . self::EXCEPTIONS_FILE);
  43202. $this->exceptions = array();
  43203. foreach (json_decode($json, true) as $identifier => $exception) {
  43204. $this->exceptions[strtolower($identifier)] = array($identifier, $exception[0]);
  43205. }
  43206. }
  43207. private function getLicensesExpression()
  43208. {
  43209. if (null === $this->licensesExpression) {
  43210. $licenses = array_map('preg_quote', array_keys($this->licenses));
  43211. rsort($licenses);
  43212. $licenses = implode('|', $licenses);
  43213. $this->licensesExpression = $licenses;
  43214. }
  43215. return $this->licensesExpression;
  43216. }
  43217. private function getExceptionsExpression()
  43218. {
  43219. if (null === $this->exceptionsExpression) {
  43220. $exceptions = array_map('preg_quote', array_keys($this->exceptions));
  43221. rsort($exceptions);
  43222. $exceptions = implode('|', $exceptions);
  43223. $this->exceptionsExpression = $exceptions;
  43224. }
  43225. return $this->exceptionsExpression;
  43226. }
  43227. private function isValidLicenseString($license)
  43228. {
  43229. if (isset($this->licenses[strtolower($license)])) {
  43230. return true;
  43231. }
  43232. $licenses = $this->getLicensesExpression();
  43233. $exceptions = $this->getExceptionsExpression();
  43234. $regex = <<<REGEX
  43235. {
  43236. (?(DEFINE)
  43237. # idstring: 1*( ALPHA / DIGIT / - / . )
  43238. (?<idstring>[\pL\pN.-]{1,})
  43239. # license-id: taken from list
  43240. (?<licenseid>${licenses})
  43241. # license-exception-id: taken from list
  43242. (?<licenseexceptionid>${exceptions})
  43243. # license-ref: [DocumentRef-1*(idstring):]LicenseRef-1*(idstring)
  43244. (?<licenseref>(?:DocumentRef-(?&idstring):)?LicenseRef-(?&idstring))
  43245. # simple-expresssion: license-id / license-id+ / license-ref
  43246. (?<simple_expression>(?&licenseid)\+? | (?&licenseid) | (?&licenseref))
  43247. # compound-expression: 1*(
  43248. # simple-expression /
  43249. # simple-expression WITH license-exception-id /
  43250. # compound-expression AND compound-expression /
  43251. # compound-expression OR compound-expression
  43252. # ) / ( compound-expression ) )
  43253. (?<compound_head>
  43254. (?&simple_expression) ( \s+ WITH \s+ (?&licenseexceptionid))?
  43255. | \( \s* (?&compound_expression) \s* \)
  43256. )
  43257. (?<compound_expression>
  43258. (?&compound_head) (?: \s+ (?:AND|OR) \s+ (?&compound_expression))?
  43259. )
  43260. # license-expression: 1*1(simple-expression / compound-expression)
  43261. (?<license_expression>(?&compound_expression) | (?&simple_expression))
  43262. ) # end of define
  43263. ^(NONE | NOASSERTION | (?&license_expression))$
  43264. }xi
  43265. REGEX;
  43266. $match = preg_match($regex, $license);
  43267. if (0 === $match) {
  43268. return false;
  43269. }
  43270. if (false === $match) {
  43271. throw new \RuntimeException('Regex failed to compile/run.');
  43272. }
  43273. return true;
  43274. }
  43275. }
  43276. MIT License
  43277. Copyright (c) 2017 Composer
  43278. Permission is hereby granted, free of charge, to any person obtaining a copy
  43279. of this software and associated documentation files (the "Software"), to deal
  43280. in the Software without restriction, including without limitation the rights
  43281. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  43282. copies of the Software, and to permit persons to whom the Software is
  43283. furnished to do so, subject to the following conditions:
  43284. The above copyright notice and this permission notice shall be included in all
  43285. copies or substantial portions of the Software.
  43286. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  43287. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  43288. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  43289. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  43290. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  43291. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  43292. SOFTWARE.
  43293. <?php
  43294. namespace Composer\XdebugHandler;
  43295. class PhpConfig
  43296. {
  43297. public function useOriginal()
  43298. {
  43299. $this->getDataAndReset();
  43300. return array();
  43301. }
  43302. public function useStandard()
  43303. {
  43304. if ($data = $this->getDataAndReset()) {
  43305. return array('-n', '-c', $data['tmpIni']);
  43306. }
  43307. return array();
  43308. }
  43309. public function usePersistent()
  43310. {
  43311. if ($data = $this->getDataAndReset()) {
  43312. Process::setEnv('PHPRC', $data['tmpIni']);
  43313. Process::setEnv('PHP_INI_SCAN_DIR', '');
  43314. }
  43315. return array();
  43316. }
  43317. private function getDataAndReset()
  43318. {
  43319. if ($data = XdebugHandler::getRestartSettings()) {
  43320. Process::setEnv('PHPRC', $data['phprc']);
  43321. Process::setEnv('PHP_INI_SCAN_DIR', $data['scanDir']);
  43322. }
  43323. return $data;
  43324. }
  43325. }
  43326. <?php
  43327. namespace Composer\XdebugHandler;
  43328. class Process
  43329. {
  43330. public static function addColorOption(array $args, $colorOption)
  43331. {
  43332. if (!$colorOption
  43333. || in_array($colorOption, $args)
  43334. || !preg_match('/^--([a-z]+$)|(^--[a-z]+=)/', $colorOption, $matches)) {
  43335. return $args;
  43336. }
  43337. if (isset($matches[2])) {
  43338. if (false !== ($index = array_search($matches[2].'auto', $args))) {
  43339. $args[$index] = $colorOption;
  43340. return $args;
  43341. } elseif (preg_grep('/^'.$matches[2].'/', $args)) {
  43342. return $args;
  43343. }
  43344. } elseif (in_array('--no-'.$matches[1], $args)) {
  43345. return $args;
  43346. }
  43347. if (false !== getenv('NO_COLOR')) {
  43348. return $args;
  43349. }
  43350. if (false !== ($index = array_search('--', $args))) {
  43351. array_splice($args, $index, 0, $colorOption);
  43352. } else {
  43353. $args[] = $colorOption;
  43354. }
  43355. return $args;
  43356. }
  43357. public static function escape($arg, $meta = true, $module = false)
  43358. {
  43359. if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
  43360. return "'".str_replace("'", "'\\''", $arg)."'";
  43361. }
  43362. $quote = strpbrk($arg, " \t") !== false || $arg === '';
  43363. $arg = preg_replace('/(\\\\*)"/', '$1$1\\"', $arg, -1, $dquotes);
  43364. if ($meta) {
  43365. $meta = $dquotes || preg_match('/%[^%]+%/', $arg);
  43366. if (!$meta) {
  43367. $quote = $quote || strpbrk($arg, '^&|<>()') !== false;
  43368. } elseif ($module && !$dquotes && $quote) {
  43369. $meta = false;
  43370. }
  43371. }
  43372. if ($quote) {
  43373. $arg = '"'.preg_replace('/(\\\\*)$/', '$1$1', $arg).'"';
  43374. }
  43375. if ($meta) {
  43376. $arg = preg_replace('/(["^&|<>()%])/', '^$1', $arg);
  43377. }
  43378. return $arg;
  43379. }
  43380. public static function supportsColor($output)
  43381. {
  43382. if ('Hyper' === getenv('TERM_PROGRAM')) {
  43383. return true;
  43384. }
  43385. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  43386. return (function_exists('sapi_windows_vt100_support')
  43387. && sapi_windows_vt100_support($output))
  43388. || false !== getenv('ANSICON')
  43389. || 'ON' === getenv('ConEmuANSI')
  43390. || 'xterm' === getenv('TERM');
  43391. }
  43392. if (function_exists('stream_isatty')) {
  43393. return stream_isatty($output);
  43394. }
  43395. if (function_exists('posix_isatty')) {
  43396. return posix_isatty($output);
  43397. }
  43398. $stat = fstat($output);
  43399. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  43400. }
  43401. public static function setEnv($name, $value = false)
  43402. {
  43403. $unset = false === $value;
  43404. if (!putenv($unset ? $name : $name.'='.$value)) {
  43405. return false;
  43406. }
  43407. if ($unset) {
  43408. unset($_SERVER[$name]);
  43409. } else {
  43410. $_SERVER[$name] = $value;
  43411. }
  43412. if (false !== stripos((string) ini_get('variables_order'), 'E')) {
  43413. if ($unset) {
  43414. unset($_ENV[$name]);
  43415. } else {
  43416. $_ENV[$name] = $value;
  43417. }
  43418. }
  43419. return true;
  43420. }
  43421. }
  43422. <?php
  43423. namespace Composer\XdebugHandler;
  43424. use Psr\Log\LoggerInterface;
  43425. use Psr\Log\LogLevel;
  43426. class Status
  43427. {
  43428. const ENV_RESTART = 'XDEBUG_HANDLER_RESTART';
  43429. const CHECK = 'Check';
  43430. const ERROR = 'Error';
  43431. const INFO = 'Info';
  43432. const NORESTART = 'NoRestart';
  43433. const RESTART = 'Restart';
  43434. const RESTARTING = 'Restarting';
  43435. const RESTARTED = 'Restarted';
  43436. private $debug;
  43437. private $envAllowXdebug;
  43438. private $loaded;
  43439. private $logger;
  43440. private $time;
  43441. public function __construct($envAllowXdebug, $debug)
  43442. {
  43443. $start = getenv(self::ENV_RESTART);
  43444. Process::setEnv(self::ENV_RESTART);
  43445. $this->time = $start ? round((microtime(true) - $start) * 1000) : 0;
  43446. $this->envAllowXdebug = $envAllowXdebug;
  43447. $this->debug = $debug && defined('STDERR');
  43448. }
  43449. public function setLogger(LoggerInterface $logger)
  43450. {
  43451. $this->logger = $logger;
  43452. }
  43453. public function report($op, $data)
  43454. {
  43455. if ($this->logger || $this->debug) {
  43456. call_user_func(array($this, 'report'.$op), $data);
  43457. }
  43458. }
  43459. private function output($text, $level = null)
  43460. {
  43461. if ($this->logger) {
  43462. $this->logger->log($level ?: LogLevel::DEBUG, $text);
  43463. }
  43464. if ($this->debug) {
  43465. fwrite(STDERR, sprintf('xdebug-handler[%d] %s', getmypid(), $text.PHP_EOL));
  43466. }
  43467. }
  43468. private function reportCheck($loaded)
  43469. {
  43470. $this->loaded = $loaded;
  43471. $this->output('Checking '.$this->envAllowXdebug);
  43472. }
  43473. private function reportError($error)
  43474. {
  43475. $this->output(sprintf('No restart (%s)', $error), LogLevel::WARNING);
  43476. }
  43477. private function reportInfo($info)
  43478. {
  43479. $this->output($info);
  43480. }
  43481. private function reportNoRestart()
  43482. {
  43483. $this->output($this->getLoadedMessage());
  43484. if ($this->loaded) {
  43485. $text = sprintf('No restart (%s)', $this->getEnvAllow());
  43486. if (!getenv($this->envAllowXdebug)) {
  43487. $text .= ' Allowed by application';
  43488. }
  43489. $this->output($text);
  43490. }
  43491. }
  43492. private function reportRestart()
  43493. {
  43494. $this->output($this->getLoadedMessage());
  43495. Process::setEnv(self::ENV_RESTART, (string) microtime(true));
  43496. }
  43497. private function reportRestarted()
  43498. {
  43499. $loaded = $this->getLoadedMessage();
  43500. $text = sprintf('Restarted (%d ms). %s', $this->time, $loaded);
  43501. $level = $this->loaded ? LogLevel::WARNING : null;
  43502. $this->output($text, $level);
  43503. }
  43504. private function reportRestarting($command)
  43505. {
  43506. $text = sprintf('Process restarting (%s)', $this->getEnvAllow());
  43507. $this->output($text);
  43508. $text = 'Running '.$command;
  43509. $this->output($text);
  43510. }
  43511. private function getEnvAllow()
  43512. {
  43513. return $this->envAllowXdebug.'='.getenv($this->envAllowXdebug);
  43514. }
  43515. private function getLoadedMessage()
  43516. {
  43517. $loaded = $this->loaded ? sprintf('loaded (%s)', $this->loaded) : 'not loaded';
  43518. return 'The Xdebug extension is '.$loaded;
  43519. }
  43520. }
  43521. <?php
  43522. namespace Composer\XdebugHandler;
  43523. use Psr\Log\LoggerInterface;
  43524. class XdebugHandler
  43525. {
  43526. const SUFFIX_ALLOW = '_ALLOW_XDEBUG';
  43527. const SUFFIX_INIS = '_ORIGINAL_INIS';
  43528. const RESTART_ID = 'internal';
  43529. const RESTART_SETTINGS = 'XDEBUG_HANDLER_SETTINGS';
  43530. const DEBUG = 'XDEBUG_HANDLER_DEBUG';
  43531. protected $tmpIni;
  43532. private static $inRestart;
  43533. private static $name;
  43534. private static $skipped;
  43535. private $cli;
  43536. private $colorOption;
  43537. private $debug;
  43538. private $envAllowXdebug;
  43539. private $envOriginalInis;
  43540. private $loaded;
  43541. private $persistent;
  43542. private $script;
  43543. private $statusWriter;
  43544. public function __construct($envPrefix, $colorOption = '')
  43545. {
  43546. if (!is_string($envPrefix) || empty($envPrefix) || !is_string($colorOption)) {
  43547. throw new \RuntimeException('Invalid constructor parameter');
  43548. }
  43549. self::$name = strtoupper($envPrefix);
  43550. $this->envAllowXdebug = self::$name.self::SUFFIX_ALLOW;
  43551. $this->envOriginalInis = self::$name.self::SUFFIX_INIS;
  43552. $this->colorOption = $colorOption;
  43553. if (extension_loaded('xdebug')) {
  43554. $ext = new \ReflectionExtension('xdebug');
  43555. $this->loaded = $ext->getVersion() ?: 'unknown';
  43556. }
  43557. if ($this->cli = PHP_SAPI === 'cli') {
  43558. $this->debug = getenv(self::DEBUG);
  43559. }
  43560. $this->statusWriter = new Status($this->envAllowXdebug, (bool) $this->debug);
  43561. }
  43562. public function setLogger(LoggerInterface $logger)
  43563. {
  43564. $this->statusWriter->setLogger($logger);
  43565. return $this;
  43566. }
  43567. public function setMainScript($script)
  43568. {
  43569. $this->script = $script;
  43570. return $this;
  43571. }
  43572. public function setPersistent()
  43573. {
  43574. $this->persistent = true;
  43575. return $this;
  43576. }
  43577. public function check()
  43578. {
  43579. $this->notify(Status::CHECK, $this->loaded);
  43580. $envArgs = explode('|', (string) getenv($this->envAllowXdebug));
  43581. if (empty($envArgs[0]) && $this->requiresRestart((bool) $this->loaded)) {
  43582. $this->notify(Status::RESTART);
  43583. if ($this->prepareRestart()) {
  43584. $command = $this->getCommand();
  43585. $this->restart($command);
  43586. }
  43587. return;
  43588. }
  43589. if (self::RESTART_ID === $envArgs[0] && count($envArgs) === 5) {
  43590. $this->notify(Status::RESTARTED);
  43591. Process::setEnv($this->envAllowXdebug);
  43592. self::$inRestart = true;
  43593. if (!$this->loaded) {
  43594. self::$skipped = $envArgs[1];
  43595. }
  43596. $this->tryEnableSignals();
  43597. $this->setEnvRestartSettings($envArgs);
  43598. return;
  43599. }
  43600. $this->notify(Status::NORESTART);
  43601. if ($settings = self::getRestartSettings()) {
  43602. $this->syncSettings($settings);
  43603. }
  43604. }
  43605. public static function getAllIniFiles()
  43606. {
  43607. if (!empty(self::$name)) {
  43608. $env = getenv(self::$name.self::SUFFIX_INIS);
  43609. if (false !== $env) {
  43610. return explode(PATH_SEPARATOR, $env);
  43611. }
  43612. }
  43613. $paths = array((string) php_ini_loaded_file());
  43614. if ($scanned = php_ini_scanned_files()) {
  43615. $paths = array_merge($paths, array_map('trim', explode(',', $scanned)));
  43616. }
  43617. return $paths;
  43618. }
  43619. public static function getRestartSettings()
  43620. {
  43621. $envArgs = explode('|', (string) getenv(self::RESTART_SETTINGS));
  43622. if (count($envArgs) !== 6
  43623. || (!self::$inRestart && php_ini_loaded_file() !== $envArgs[0])) {
  43624. return;
  43625. }
  43626. return array(
  43627. 'tmpIni' => $envArgs[0],
  43628. 'scannedInis' => (bool) $envArgs[1],
  43629. 'scanDir' => '*' === $envArgs[2] ? false : $envArgs[2],
  43630. 'phprc' => '*' === $envArgs[3] ? false : $envArgs[3],
  43631. 'inis' => explode(PATH_SEPARATOR, $envArgs[4]),
  43632. 'skipped' => $envArgs[5],
  43633. );
  43634. }
  43635. public static function getSkippedVersion()
  43636. {
  43637. return (string) self::$skipped;
  43638. }
  43639. protected function requiresRestart($isLoaded)
  43640. {
  43641. return $isLoaded;
  43642. }
  43643. protected function restart($command)
  43644. {
  43645. $this->doRestart($command);
  43646. }
  43647. private function doRestart($command)
  43648. {
  43649. $this->tryEnableSignals();
  43650. $this->notify(Status::RESTARTING, $command);
  43651. if (function_exists('proc_open')) {
  43652. if (defined('PHP_WINDOWS_VERSION_BUILD') && PHP_VERSION_ID < 80000) {
  43653. $command = '"'.$command.'"';
  43654. }
  43655. $process = proc_open($command, array(), $pipes);
  43656. if (is_resource($process)) {
  43657. $exitCode = proc_close($process);
  43658. }
  43659. } else {
  43660. passthru($command, $exitCode);
  43661. }
  43662. if (!isset($exitCode)) {
  43663. $this->notify(Status::ERROR, 'Unable to restart process');
  43664. $exitCode = -1;
  43665. } else {
  43666. $this->notify(Status::INFO, 'Restarted process exited '.$exitCode);
  43667. }
  43668. if ($this->debug === '2') {
  43669. $this->notify(Status::INFO, 'Temp ini saved: '.$this->tmpIni);
  43670. } else {
  43671. @unlink($this->tmpIni);
  43672. }
  43673. exit($exitCode);
  43674. }
  43675. private function prepareRestart()
  43676. {
  43677. $error = '';
  43678. $iniFiles = self::getAllIniFiles();
  43679. $scannedInis = count($iniFiles) > 1;
  43680. $tmpDir = sys_get_temp_dir();
  43681. if (!$this->cli) {
  43682. $error = 'Unsupported SAPI: '.PHP_SAPI;
  43683. } elseif (!defined('PHP_BINARY')) {
  43684. $error = 'PHP version is too old: '.PHP_VERSION;
  43685. } elseif (!$this->checkConfiguration($info)) {
  43686. $error = $info;
  43687. } elseif (!$this->checkScanDirConfig()) {
  43688. $error = 'PHP version does not report scanned inis: '.PHP_VERSION;
  43689. } elseif (!$this->checkMainScript()) {
  43690. $error = 'Unable to access main script: '.$this->script;
  43691. } elseif (!$this->writeTmpIni($iniFiles, $tmpDir, $error)) {
  43692. $error = $error ?: 'Unable to create temp ini file at: '.$tmpDir;
  43693. } elseif (!$this->setEnvironment($scannedInis, $iniFiles)) {
  43694. $error = 'Unable to set environment variables';
  43695. }
  43696. if ($error) {
  43697. $this->notify(Status::ERROR, $error);
  43698. }
  43699. return empty($error);
  43700. }
  43701. private function writeTmpIni(array $iniFiles, $tmpDir, &$error)
  43702. {
  43703. if (!$this->tmpIni = @tempnam($tmpDir, '')) {
  43704. return false;
  43705. }
  43706. if (empty($iniFiles[0])) {
  43707. array_shift($iniFiles);
  43708. }
  43709. $content = '';
  43710. $regex = '/^\s*(zend_extension\s*=.*xdebug.*)$/mi';
  43711. foreach ($iniFiles as $file) {
  43712. if (($data = @file_get_contents($file)) === false) {
  43713. $error = 'Unable to read ini: '.$file;
  43714. return false;
  43715. }
  43716. $content .= preg_replace($regex, ';$1', $data).PHP_EOL;
  43717. }
  43718. if ($config = parse_ini_string($content)) {
  43719. $loaded = ini_get_all(null, false);
  43720. $content .= $this->mergeLoadedConfig($loaded, $config);
  43721. }
  43722. $content .= 'opcache.enable_cli=0'.PHP_EOL;
  43723. return @file_put_contents($this->tmpIni, $content);
  43724. }
  43725. private function getCommand()
  43726. {
  43727. $php = array(PHP_BINARY);
  43728. $args = array_slice($_SERVER['argv'], 1);
  43729. if (!$this->persistent) {
  43730. array_push($php, '-n', '-c', $this->tmpIni);
  43731. }
  43732. if (defined('STDOUT') && Process::supportsColor(STDOUT)) {
  43733. $args = Process::addColorOption($args, $this->colorOption);
  43734. }
  43735. $args = array_merge($php, array($this->script), $args);
  43736. $cmd = Process::escape(array_shift($args), true, true);
  43737. foreach ($args as $arg) {
  43738. $cmd .= ' '.Process::escape($arg);
  43739. }
  43740. return $cmd;
  43741. }
  43742. private function setEnvironment($scannedInis, array $iniFiles)
  43743. {
  43744. $scanDir = getenv('PHP_INI_SCAN_DIR');
  43745. $phprc = getenv('PHPRC');
  43746. if (!putenv($this->envOriginalInis.'='.implode(PATH_SEPARATOR, $iniFiles))) {
  43747. return false;
  43748. }
  43749. if ($this->persistent) {
  43750. if (!putenv('PHP_INI_SCAN_DIR=') || !putenv('PHPRC='.$this->tmpIni)) {
  43751. return false;
  43752. }
  43753. }
  43754. $envArgs = array(
  43755. self::RESTART_ID,
  43756. $this->loaded,
  43757. (int) $scannedInis,
  43758. false === $scanDir ? '*' : $scanDir,
  43759. false === $phprc ? '*' : $phprc,
  43760. );
  43761. return putenv($this->envAllowXdebug.'='.implode('|', $envArgs));
  43762. }
  43763. private function notify($op, $data = null)
  43764. {
  43765. $this->statusWriter->report($op, $data);
  43766. }
  43767. private function mergeLoadedConfig(array $loadedConfig, array $iniConfig)
  43768. {
  43769. $content = '';
  43770. foreach ($loadedConfig as $name => $value) {
  43771. if (!is_string($value)
  43772. || strpos($name, 'xdebug') === 0
  43773. || $name === 'apc.mmap_file_mask') {
  43774. continue;
  43775. }
  43776. if (!isset($iniConfig[$name]) || $iniConfig[$name] !== $value) {
  43777. $content .= $name.'="'.addcslashes($value, '\\"').'"'.PHP_EOL;
  43778. }
  43779. }
  43780. return $content;
  43781. }
  43782. private function checkMainScript()
  43783. {
  43784. if (null !== $this->script) {
  43785. return file_exists($this->script) || '--' === $this->script;
  43786. }
  43787. if (file_exists($this->script = $_SERVER['argv'][0])) {
  43788. return true;
  43789. }
  43790. $options = PHP_VERSION_ID >= 50306 ? DEBUG_BACKTRACE_IGNORE_ARGS : false;
  43791. $trace = debug_backtrace($options);
  43792. if (($main = end($trace)) && isset($main['file'])) {
  43793. return file_exists($this->script = $main['file']);
  43794. }
  43795. return false;
  43796. }
  43797. private function setEnvRestartSettings($envArgs)
  43798. {
  43799. $settings = array(
  43800. php_ini_loaded_file(),
  43801. $envArgs[2],
  43802. $envArgs[3],
  43803. $envArgs[4],
  43804. getenv($this->envOriginalInis),
  43805. self::$skipped,
  43806. );
  43807. Process::setEnv(self::RESTART_SETTINGS, implode('|', $settings));
  43808. }
  43809. private function syncSettings(array $settings)
  43810. {
  43811. if (false === getenv($this->envOriginalInis)) {
  43812. Process::setEnv($this->envOriginalInis, implode(PATH_SEPARATOR, $settings['inis']));
  43813. }
  43814. self::$skipped = $settings['skipped'];
  43815. $this->notify(Status::INFO, 'Process called with existing restart settings');
  43816. }
  43817. private function checkScanDirConfig()
  43818. {
  43819. return !(getenv('PHP_INI_SCAN_DIR')
  43820. && !PHP_CONFIG_FILE_SCAN_DIR
  43821. && (PHP_VERSION_ID < 70113
  43822. || PHP_VERSION_ID === 70200));
  43823. }
  43824. private function checkConfiguration(&$info)
  43825. {
  43826. if (false !== strpos(ini_get('disable_functions'), 'passthru')) {
  43827. $info = 'passthru function is disabled';
  43828. return false;
  43829. }
  43830. if (extension_loaded('uopz') && !ini_get('uopz.disable')) {
  43831. if (function_exists('uopz_allow_exit')) {
  43832. @uopz_allow_exit(true);
  43833. } else {
  43834. $info = 'uopz extension is not compatible';
  43835. return false;
  43836. }
  43837. }
  43838. return true;
  43839. }
  43840. private function tryEnableSignals()
  43841. {
  43842. if (!function_exists('pcntl_async_signals') || !function_exists('pcntl_signal')) {
  43843. return;
  43844. }
  43845. pcntl_async_signals(true);
  43846. $message = 'Async signals enabled';
  43847. if (!self::$inRestart) {
  43848. pcntl_signal(SIGINT, SIG_IGN);
  43849. $message .= ' (SIGINT = SIG_IGN)';
  43850. } elseif (is_int(pcntl_signal_get_handler(SIGINT))) {
  43851. pcntl_signal(SIGINT, SIG_DFL);
  43852. $message .= ' (SIGINT = SIG_DFL)';
  43853. }
  43854. $this->notify(Status::INFO, $message);
  43855. }
  43856. }
  43857. MIT License
  43858. Copyright (c) 2016
  43859. Permission is hereby granted, free of charge, to any person obtaining a copy
  43860. of this software and associated documentation files (the "Software"), to deal
  43861. in the Software without restriction, including without limitation the rights
  43862. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  43863. copies of the Software, and to permit persons to whom the Software is
  43864. furnished to do so, subject to the following conditions:
  43865. The above copyright notice and this permission notice shall be included in all
  43866. copies or substantial portions of the Software.
  43867. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  43868. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  43869. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  43870. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  43871. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  43872. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  43873. SOFTWARE.
  43874. <?php
  43875. namespace JsonSchema\Constraints;
  43876. use JsonSchema\Entity\JsonPointer;
  43877. use JsonSchema\Exception\InvalidArgumentException;
  43878. use JsonSchema\Exception\ValidationException;
  43879. use JsonSchema\Validator;
  43880. class BaseConstraint
  43881. {
  43882. protected $errors = array();
  43883. protected $errorMask = Validator::ERROR_NONE;
  43884. protected $factory;
  43885. public function __construct(Factory $factory = null)
  43886. {
  43887. $this->factory = $factory ?: new Factory();
  43888. }
  43889. public function addError(JsonPointer $path = null, $message, $constraint = '', array $more = null)
  43890. {
  43891. $error = array(
  43892. 'property' => $this->convertJsonPointerIntoPropertyPath($path ?: new JsonPointer('')),
  43893. 'pointer' => ltrim(strval($path ?: new JsonPointer('')), '#'),
  43894. 'message' => $message,
  43895. 'constraint' => $constraint,
  43896. 'context' => $this->factory->getErrorContext(),
  43897. );
  43898. if ($this->factory->getConfig(Constraint::CHECK_MODE_EXCEPTIONS)) {
  43899. throw new ValidationException(sprintf('Error validating %s: %s', $error['pointer'], $error['message']));
  43900. }
  43901. if (is_array($more) && count($more) > 0) {
  43902. $error += $more;
  43903. }
  43904. $this->errors[] = $error;
  43905. $this->errorMask |= $error['context'];
  43906. }
  43907. public function addErrors(array $errors)
  43908. {
  43909. if ($errors) {
  43910. $this->errors = array_merge($this->errors, $errors);
  43911. $errorMask = &$this->errorMask;
  43912. array_walk($errors, function ($error) use (&$errorMask) {
  43913. if (isset($error['context'])) {
  43914. $errorMask |= $error['context'];
  43915. }
  43916. });
  43917. }
  43918. }
  43919. public function getErrors($errorContext = Validator::ERROR_ALL)
  43920. {
  43921. if ($errorContext === Validator::ERROR_ALL) {
  43922. return $this->errors;
  43923. }
  43924. return array_filter($this->errors, function ($error) use ($errorContext) {
  43925. if ($errorContext & $error['context']) {
  43926. return true;
  43927. }
  43928. });
  43929. }
  43930. public function numErrors($errorContext = Validator::ERROR_ALL)
  43931. {
  43932. if ($errorContext === Validator::ERROR_ALL) {
  43933. return count($this->errors);
  43934. }
  43935. return count($this->getErrors($errorContext));
  43936. }
  43937. public function isValid()
  43938. {
  43939. return !$this->getErrors();
  43940. }
  43941. public function reset()
  43942. {
  43943. $this->errors = array();
  43944. $this->errorMask = Validator::ERROR_NONE;
  43945. }
  43946. public function getErrorMask()
  43947. {
  43948. return $this->errorMask;
  43949. }
  43950. public static function arrayToObjectRecursive($array)
  43951. {
  43952. $json = json_encode($array);
  43953. if (json_last_error() !== \JSON_ERROR_NONE) {
  43954. $message = 'Unable to encode schema array as JSON';
  43955. if (function_exists('json_last_error_msg')) {
  43956. $message .= ': ' . json_last_error_msg();
  43957. }
  43958. throw new InvalidArgumentException($message);
  43959. }
  43960. return (object) json_decode($json);
  43961. }
  43962. }
  43963. <?php
  43964. namespace JsonSchema\Constraints;
  43965. use JsonSchema\Entity\JsonPointer;
  43966. class CollectionConstraint extends Constraint
  43967. {
  43968. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null)
  43969. {
  43970. if (isset($schema->minItems) && count($value) < $schema->minItems) {
  43971. $this->addError($path, 'There must be a minimum of ' . $schema->minItems . ' items in the array', 'minItems', array('minItems' => $schema->minItems));
  43972. }
  43973. if (isset($schema->maxItems) && count($value) > $schema->maxItems) {
  43974. $this->addError($path, 'There must be a maximum of ' . $schema->maxItems . ' items in the array', 'maxItems', array('maxItems' => $schema->maxItems));
  43975. }
  43976. if (isset($schema->uniqueItems) && $schema->uniqueItems) {
  43977. $unique = $value;
  43978. if (is_array($value) && count($value)) {
  43979. $unique = array_map(function ($e) {
  43980. return var_export($e, true);
  43981. }, $value);
  43982. }
  43983. if (count(array_unique($unique)) != count($value)) {
  43984. $this->addError($path, 'There are no duplicates allowed in the array', 'uniqueItems');
  43985. }
  43986. }
  43987. if (isset($schema->items)) {
  43988. $this->validateItems($value, $schema, $path, $i);
  43989. }
  43990. }
  43991. protected function validateItems(&$value, $schema = null, JsonPointer $path = null, $i = null)
  43992. {
  43993. if (is_object($schema->items)) {
  43994. foreach ($value as $k => &$v) {
  43995. $initErrors = $this->getErrors();
  43996. $this->checkUndefined($v, $schema->items, $path, $k);
  43997. if (count($initErrors) < count($this->getErrors()) && (isset($schema->additionalItems) && $schema->additionalItems !== false)) {
  43998. $secondErrors = $this->getErrors();
  43999. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  44000. }
  44001. if (isset($secondErrors) && count($secondErrors) < count($this->getErrors())) {
  44002. $this->errors = $secondErrors;
  44003. } elseif (isset($secondErrors) && count($secondErrors) === count($this->getErrors())) {
  44004. $this->errors = $initErrors;
  44005. }
  44006. }
  44007. unset($v);
  44008. } else {
  44009. foreach ($value as $k => &$v) {
  44010. if (array_key_exists($k, $schema->items)) {
  44011. $this->checkUndefined($v, $schema->items[$k], $path, $k);
  44012. } else {
  44013. if (property_exists($schema, 'additionalItems')) {
  44014. if ($schema->additionalItems !== false) {
  44015. $this->checkUndefined($v, $schema->additionalItems, $path, $k);
  44016. } else {
  44017. $this->addError(
  44018. $path, 'The item ' . $i . '[' . $k . '] is not defined and the definition does not allow additional items', 'additionalItems', array('additionalItems' => $schema->additionalItems));
  44019. }
  44020. } else {
  44021. $this->checkUndefined($v, new \stdClass(), $path, $k);
  44022. }
  44023. }
  44024. }
  44025. unset($v);
  44026. if (count($value) > 0) {
  44027. for ($k = count($value); $k < count($schema->items); $k++) {
  44028. $undefinedInstance = $this->factory->createInstanceFor('undefined');
  44029. $this->checkUndefined($undefinedInstance, $schema->items[$k], $path, $k);
  44030. }
  44031. }
  44032. }
  44033. }
  44034. }
  44035. <?php
  44036. namespace JsonSchema\Constraints;
  44037. use JsonSchema\Entity\JsonPointer;
  44038. abstract class Constraint extends BaseConstraint implements ConstraintInterface
  44039. {
  44040. protected $inlineSchemaProperty = '$schema';
  44041. const CHECK_MODE_NONE = 0x00000000;
  44042. const CHECK_MODE_NORMAL = 0x00000001;
  44043. const CHECK_MODE_TYPE_CAST = 0x00000002;
  44044. const CHECK_MODE_COERCE_TYPES = 0x00000004;
  44045. const CHECK_MODE_APPLY_DEFAULTS = 0x00000008;
  44046. const CHECK_MODE_EXCEPTIONS = 0x00000010;
  44047. const CHECK_MODE_DISABLE_FORMAT = 0x00000020;
  44048. const CHECK_MODE_ONLY_REQUIRED_DEFAULTS = 0x00000080;
  44049. const CHECK_MODE_VALIDATE_SCHEMA = 0x00000100;
  44050. protected function incrementPath(JsonPointer $path = null, $i)
  44051. {
  44052. $path = $path ?: new JsonPointer('');
  44053. $path = $path->withPropertyPaths(
  44054. array_merge(
  44055. $path->getPropertyPaths(),
  44056. array_filter(array($i), 'strlen')
  44057. )
  44058. );
  44059. return $path;
  44060. }
  44061. protected function checkArray(&$value, $schema = null, JsonPointer $path = null, $i = null)
  44062. {
  44063. $validator = $this->factory->createInstanceFor('collection');
  44064. $validator->check($value, $schema, $path, $i);
  44065. $this->addErrors($validator->getErrors());
  44066. }
  44067. protected function checkObject(&$value, $schema = null, JsonPointer $path = null, $properties = null,
  44068. $additionalProperties = null, $patternProperties = null, $appliedDefaults = array())
  44069. {
  44070. $validator = $this->factory->createInstanceFor('object');
  44071. $validator->check($value, $schema, $path, $properties, $additionalProperties, $patternProperties, $appliedDefaults);
  44072. $this->addErrors($validator->getErrors());
  44073. }
  44074. protected function checkType(&$value, $schema = null, JsonPointer $path = null, $i = null)
  44075. {
  44076. $validator = $this->factory->createInstanceFor('type');
  44077. $validator->check($value, $schema, $path, $i);
  44078. $this->addErrors($validator->getErrors());
  44079. }
  44080. protected function checkUndefined(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  44081. {
  44082. $validator = $this->factory->createInstanceFor('undefined');
  44083. $validator->check($value, $this->factory->getSchemaStorage()->resolveRefSchema($schema), $path, $i, $fromDefault);
  44084. $this->addErrors($validator->getErrors());
  44085. }
  44086. protected function checkString($value, $schema = null, JsonPointer $path = null, $i = null)
  44087. {
  44088. $validator = $this->factory->createInstanceFor('string');
  44089. $validator->check($value, $schema, $path, $i);
  44090. $this->addErrors($validator->getErrors());
  44091. }
  44092. protected function checkNumber($value, $schema = null, JsonPointer $path = null, $i = null)
  44093. {
  44094. $validator = $this->factory->createInstanceFor('number');
  44095. $validator->check($value, $schema, $path, $i);
  44096. $this->addErrors($validator->getErrors());
  44097. }
  44098. protected function checkEnum($value, $schema = null, JsonPointer $path = null, $i = null)
  44099. {
  44100. $validator = $this->factory->createInstanceFor('enum');
  44101. $validator->check($value, $schema, $path, $i);
  44102. $this->addErrors($validator->getErrors());
  44103. }
  44104. protected function checkFormat($value, $schema = null, JsonPointer $path = null, $i = null)
  44105. {
  44106. $validator = $this->factory->createInstanceFor('format');
  44107. $validator->check($value, $schema, $path, $i);
  44108. $this->addErrors($validator->getErrors());
  44109. }
  44110. protected function getTypeCheck()
  44111. {
  44112. return $this->factory->getTypeCheck();
  44113. }
  44114. protected function convertJsonPointerIntoPropertyPath(JsonPointer $pointer)
  44115. {
  44116. $result = array_map(
  44117. function ($path) {
  44118. return sprintf(is_numeric($path) ? '[%d]' : '.%s', $path);
  44119. },
  44120. $pointer->getPropertyPaths()
  44121. );
  44122. return trim(implode('', $result), '.');
  44123. }
  44124. }
  44125. <?php
  44126. namespace JsonSchema\Constraints;
  44127. use JsonSchema\Entity\JsonPointer;
  44128. interface ConstraintInterface
  44129. {
  44130. public function getErrors();
  44131. public function addErrors(array $errors);
  44132. public function addError(JsonPointer $path = null, $message, $constraint='', array $more = null);
  44133. public function isValid();
  44134. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null);
  44135. }
  44136. <?php
  44137. namespace JsonSchema\Constraints;
  44138. use JsonSchema\Entity\JsonPointer;
  44139. class EnumConstraint extends Constraint
  44140. {
  44141. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44142. {
  44143. if ($element instanceof UndefinedConstraint && (!isset($schema->required) || !$schema->required)) {
  44144. return;
  44145. }
  44146. $type = gettype($element);
  44147. foreach ($schema->enum as $enum) {
  44148. $enumType = gettype($enum);
  44149. if ($this->factory->getConfig(self::CHECK_MODE_TYPE_CAST) && $type == 'array' && $enumType == 'object') {
  44150. if ((object) $element == $enum) {
  44151. return;
  44152. }
  44153. }
  44154. if ($type === gettype($enum)) {
  44155. if ($type == 'object') {
  44156. if ($element == $enum) {
  44157. return;
  44158. }
  44159. } elseif ($element === $enum) {
  44160. return;
  44161. }
  44162. }
  44163. }
  44164. $this->addError($path, 'Does not have a value in the enumeration ' . json_encode($schema->enum), 'enum', array('enum' => $schema->enum));
  44165. }
  44166. }
  44167. <?php
  44168. namespace JsonSchema\Constraints;
  44169. use JsonSchema\Exception\InvalidArgumentException;
  44170. use JsonSchema\SchemaStorage;
  44171. use JsonSchema\SchemaStorageInterface;
  44172. use JsonSchema\Uri\UriRetriever;
  44173. use JsonSchema\UriRetrieverInterface;
  44174. use JsonSchema\Validator;
  44175. class Factory
  44176. {
  44177. protected $schemaStorage;
  44178. protected $uriRetriever;
  44179. private $checkMode = Constraint::CHECK_MODE_NORMAL;
  44180. private $typeCheck = array();
  44181. protected $errorContext = Validator::ERROR_DOCUMENT_VALIDATION;
  44182. protected $constraintMap = array(
  44183. 'array' => 'JsonSchema\Constraints\CollectionConstraint',
  44184. 'collection' => 'JsonSchema\Constraints\CollectionConstraint',
  44185. 'object' => 'JsonSchema\Constraints\ObjectConstraint',
  44186. 'type' => 'JsonSchema\Constraints\TypeConstraint',
  44187. 'undefined' => 'JsonSchema\Constraints\UndefinedConstraint',
  44188. 'string' => 'JsonSchema\Constraints\StringConstraint',
  44189. 'number' => 'JsonSchema\Constraints\NumberConstraint',
  44190. 'enum' => 'JsonSchema\Constraints\EnumConstraint',
  44191. 'format' => 'JsonSchema\Constraints\FormatConstraint',
  44192. 'schema' => 'JsonSchema\Constraints\SchemaConstraint',
  44193. 'validator' => 'JsonSchema\Validator'
  44194. );
  44195. private $instanceCache = array();
  44196. public function __construct(
  44197. SchemaStorageInterface $schemaStorage = null,
  44198. UriRetrieverInterface $uriRetriever = null,
  44199. $checkMode = Constraint::CHECK_MODE_NORMAL
  44200. ) {
  44201. $this->setConfig($checkMode);
  44202. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  44203. $this->schemaStorage = $schemaStorage ?: new SchemaStorage($this->uriRetriever);
  44204. }
  44205. public function setConfig($checkMode = Constraint::CHECK_MODE_NORMAL)
  44206. {
  44207. $this->checkMode = $checkMode;
  44208. }
  44209. public function addConfig($options)
  44210. {
  44211. $this->checkMode |= $options;
  44212. }
  44213. public function removeConfig($options)
  44214. {
  44215. $this->checkMode &= ~$options;
  44216. }
  44217. public function getConfig($options = null)
  44218. {
  44219. if ($options === null) {
  44220. return $this->checkMode;
  44221. }
  44222. return $this->checkMode & $options;
  44223. }
  44224. public function getUriRetriever()
  44225. {
  44226. return $this->uriRetriever;
  44227. }
  44228. public function getSchemaStorage()
  44229. {
  44230. return $this->schemaStorage;
  44231. }
  44232. public function getTypeCheck()
  44233. {
  44234. if (!isset($this->typeCheck[$this->checkMode])) {
  44235. $this->typeCheck[$this->checkMode] = ($this->checkMode & Constraint::CHECK_MODE_TYPE_CAST)
  44236. ? new TypeCheck\LooseTypeCheck()
  44237. : new TypeCheck\StrictTypeCheck();
  44238. }
  44239. return $this->typeCheck[$this->checkMode];
  44240. }
  44241. public function setConstraintClass($name, $class)
  44242. {
  44243. if (!class_exists($class)) {
  44244. throw new InvalidArgumentException('Unknown constraint ' . $name);
  44245. }
  44246. if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
  44247. throw new InvalidArgumentException('Invalid class ' . $name);
  44248. }
  44249. $this->constraintMap[$name] = $class;
  44250. return $this;
  44251. }
  44252. public function createInstanceFor($constraintName)
  44253. {
  44254. if (!isset($this->constraintMap[$constraintName])) {
  44255. throw new InvalidArgumentException('Unknown constraint ' . $constraintName);
  44256. }
  44257. if (!isset($this->instanceCache[$constraintName])) {
  44258. $this->instanceCache[$constraintName] = new $this->constraintMap[$constraintName]($this);
  44259. }
  44260. return clone $this->instanceCache[$constraintName];
  44261. }
  44262. public function getErrorContext()
  44263. {
  44264. return $this->errorContext;
  44265. }
  44266. public function setErrorContext($errorContext)
  44267. {
  44268. $this->errorContext = $errorContext;
  44269. }
  44270. }
  44271. <?php
  44272. namespace JsonSchema\Constraints;
  44273. use JsonSchema\Entity\JsonPointer;
  44274. use JsonSchema\Rfc3339;
  44275. class FormatConstraint extends Constraint
  44276. {
  44277. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44278. {
  44279. if (!isset($schema->format) || $this->factory->getConfig(self::CHECK_MODE_DISABLE_FORMAT)) {
  44280. return;
  44281. }
  44282. switch ($schema->format) {
  44283. case 'date':
  44284. if (!$date = $this->validateDateTime($element, 'Y-m-d')) {
  44285. $this->addError($path, sprintf('Invalid date %s, expected format YYYY-MM-DD', json_encode($element)), 'format', array('format' => $schema->format));
  44286. }
  44287. break;
  44288. case 'time':
  44289. if (!$this->validateDateTime($element, 'H:i:s')) {
  44290. $this->addError($path, sprintf('Invalid time %s, expected format hh:mm:ss', json_encode($element)), 'format', array('format' => $schema->format));
  44291. }
  44292. break;
  44293. case 'date-time':
  44294. if (null === Rfc3339::createFromString($element)) {
  44295. $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));
  44296. }
  44297. break;
  44298. case 'utc-millisec':
  44299. if (!$this->validateDateTime($element, 'U')) {
  44300. $this->addError($path, sprintf('Invalid time %s, expected integer of milliseconds since Epoch', json_encode($element)), 'format', array('format' => $schema->format));
  44301. }
  44302. break;
  44303. case 'regex':
  44304. if (!$this->validateRegex($element)) {
  44305. $this->addError($path, 'Invalid regex format ' . $element, 'format', array('format' => $schema->format));
  44306. }
  44307. break;
  44308. case 'color':
  44309. if (!$this->validateColor($element)) {
  44310. $this->addError($path, 'Invalid color', 'format', array('format' => $schema->format));
  44311. }
  44312. break;
  44313. case 'style':
  44314. if (!$this->validateStyle($element)) {
  44315. $this->addError($path, 'Invalid style', 'format', array('format' => $schema->format));
  44316. }
  44317. break;
  44318. case 'phone':
  44319. if (!$this->validatePhone($element)) {
  44320. $this->addError($path, 'Invalid phone number', 'format', array('format' => $schema->format));
  44321. }
  44322. break;
  44323. case 'uri':
  44324. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  44325. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  44326. }
  44327. break;
  44328. case 'uriref':
  44329. case 'uri-reference':
  44330. if (null === filter_var($element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE)) {
  44331. if (substr($element, 0, 2) === '//') {
  44332. $validURL = filter_var('scheme:' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  44333. } elseif (substr($element, 0, 1) === '/') {
  44334. $validURL = filter_var('scheme://host' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  44335. } elseif (strlen($element)) {
  44336. $pathParts = explode('/', $element, 2);
  44337. if (strpos($pathParts[0], ':') !== false) {
  44338. $validURL = null;
  44339. } else {
  44340. $validURL = filter_var('scheme://host/' . $element, FILTER_VALIDATE_URL, FILTER_NULL_ON_FAILURE);
  44341. }
  44342. } else {
  44343. $validURL = null;
  44344. }
  44345. if ($validURL === null) {
  44346. $this->addError($path, 'Invalid URL format', 'format', array('format' => $schema->format));
  44347. }
  44348. }
  44349. break;
  44350. case 'email':
  44351. $filterFlags = FILTER_NULL_ON_FAILURE;
  44352. if (defined('FILTER_FLAG_EMAIL_UNICODE')) {
  44353. $filterFlags |= constant('FILTER_FLAG_EMAIL_UNICODE');
  44354. }
  44355. if (null === filter_var($element, FILTER_VALIDATE_EMAIL, $filterFlags)) {
  44356. $this->addError($path, 'Invalid email', 'format', array('format' => $schema->format));
  44357. }
  44358. break;
  44359. case 'ip-address':
  44360. case 'ipv4':
  44361. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV4)) {
  44362. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  44363. }
  44364. break;
  44365. case 'ipv6':
  44366. if (null === filter_var($element, FILTER_VALIDATE_IP, FILTER_NULL_ON_FAILURE | FILTER_FLAG_IPV6)) {
  44367. $this->addError($path, 'Invalid IP address', 'format', array('format' => $schema->format));
  44368. }
  44369. break;
  44370. case 'host-name':
  44371. case 'hostname':
  44372. if (!$this->validateHostname($element)) {
  44373. $this->addError($path, 'Invalid hostname', 'format', array('format' => $schema->format));
  44374. }
  44375. break;
  44376. default:
  44377. break;
  44378. }
  44379. }
  44380. protected function validateDateTime($datetime, $format)
  44381. {
  44382. $dt = \DateTime::createFromFormat($format, $datetime);
  44383. if (!$dt) {
  44384. return false;
  44385. }
  44386. if ($datetime === $dt->format($format)) {
  44387. return true;
  44388. }
  44389. if ((strpos('u', $format) !== -1) && (preg_match('/\.\d+Z$/', $datetime))) {
  44390. return true;
  44391. }
  44392. return false;
  44393. }
  44394. protected function validateRegex($regex)
  44395. {
  44396. return false !== @preg_match('/' . $regex . '/u', '');
  44397. }
  44398. protected function validateColor($color)
  44399. {
  44400. if (in_array(strtolower($color), array('aqua', 'black', 'blue', 'fuchsia',
  44401. 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'orange', 'purple',
  44402. 'red', 'silver', 'teal', 'white', 'yellow'))) {
  44403. return true;
  44404. }
  44405. return preg_match('/^#([a-f0-9]{3}|[a-f0-9]{6})$/i', $color);
  44406. }
  44407. protected function validateStyle($style)
  44408. {
  44409. $properties = explode(';', rtrim($style, ';'));
  44410. $invalidEntries = preg_grep('/^\s*[-a-z]+\s*:\s*.+$/i', $properties, PREG_GREP_INVERT);
  44411. return empty($invalidEntries);
  44412. }
  44413. protected function validatePhone($phone)
  44414. {
  44415. return preg_match('/^\+?(\(\d{3}\)|\d{3}) \d{3} \d{4}$/', $phone);
  44416. }
  44417. protected function validateHostname($host)
  44418. {
  44419. $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';
  44420. return preg_match($hostnameRegex, $host);
  44421. }
  44422. }
  44423. <?php
  44424. namespace JsonSchema\Constraints;
  44425. use JsonSchema\Entity\JsonPointer;
  44426. class NumberConstraint extends Constraint
  44427. {
  44428. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44429. {
  44430. if (isset($schema->exclusiveMinimum)) {
  44431. if (isset($schema->minimum)) {
  44432. if ($schema->exclusiveMinimum && $element <= $schema->minimum) {
  44433. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'exclusiveMinimum', array('minimum' => $schema->minimum));
  44434. } elseif ($element < $schema->minimum) {
  44435. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  44436. }
  44437. } else {
  44438. $this->addError($path, 'Use of exclusiveMinimum requires presence of minimum', 'missingMinimum');
  44439. }
  44440. } elseif (isset($schema->minimum) && $element < $schema->minimum) {
  44441. $this->addError($path, 'Must have a minimum value of ' . $schema->minimum, 'minimum', array('minimum' => $schema->minimum));
  44442. }
  44443. if (isset($schema->exclusiveMaximum)) {
  44444. if (isset($schema->maximum)) {
  44445. if ($schema->exclusiveMaximum && $element >= $schema->maximum) {
  44446. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'exclusiveMaximum', array('maximum' => $schema->maximum));
  44447. } elseif ($element > $schema->maximum) {
  44448. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  44449. }
  44450. } else {
  44451. $this->addError($path, 'Use of exclusiveMaximum requires presence of maximum', 'missingMaximum');
  44452. }
  44453. } elseif (isset($schema->maximum) && $element > $schema->maximum) {
  44454. $this->addError($path, 'Must have a maximum value of ' . $schema->maximum, 'maximum', array('maximum' => $schema->maximum));
  44455. }
  44456. if (isset($schema->divisibleBy) && $this->fmod($element, $schema->divisibleBy) != 0) {
  44457. $this->addError($path, 'Is not divisible by ' . $schema->divisibleBy, 'divisibleBy', array('divisibleBy' => $schema->divisibleBy));
  44458. }
  44459. if (isset($schema->multipleOf) && $this->fmod($element, $schema->multipleOf) != 0) {
  44460. $this->addError($path, 'Must be a multiple of ' . $schema->multipleOf, 'multipleOf', array('multipleOf' => $schema->multipleOf));
  44461. }
  44462. $this->checkFormat($element, $schema, $path, $i);
  44463. }
  44464. private function fmod($number1, $number2)
  44465. {
  44466. $modulus = ($number1 - round($number1 / $number2) * $number2);
  44467. $precision = 0.0000000001;
  44468. if (-$precision < $modulus && $modulus < $precision) {
  44469. return 0.0;
  44470. }
  44471. return $modulus;
  44472. }
  44473. }
  44474. <?php
  44475. namespace JsonSchema\Constraints;
  44476. use JsonSchema\Entity\JsonPointer;
  44477. class ObjectConstraint extends Constraint
  44478. {
  44479. protected $appliedDefaults = array();
  44480. public function check(&$element, $schema = null, JsonPointer $path = null, $properties = null,
  44481. $additionalProp = null, $patternProperties = null, $appliedDefaults = array())
  44482. {
  44483. if ($element instanceof UndefinedConstraint) {
  44484. return;
  44485. }
  44486. $this->appliedDefaults = $appliedDefaults;
  44487. $matches = array();
  44488. if ($patternProperties) {
  44489. $matches = $this->validatePatternProperties($element, $path, $patternProperties);
  44490. }
  44491. if ($properties) {
  44492. $this->validateProperties($element, $properties, $path);
  44493. }
  44494. $this->validateElement($element, $matches, $schema, $path, $properties, $additionalProp);
  44495. }
  44496. public function validatePatternProperties($element, JsonPointer $path = null, $patternProperties)
  44497. {
  44498. $try = array('/', '#', '+', '~', '%');
  44499. $matches = array();
  44500. foreach ($patternProperties as $pregex => $schema) {
  44501. $delimiter = '/';
  44502. foreach ($try as $delimiter) {
  44503. if (strpos($pregex, $delimiter) === false) {
  44504. break;
  44505. }
  44506. }
  44507. if (@preg_match($delimiter . $pregex . $delimiter . 'u', '') === false) {
  44508. $this->addError($path, 'The pattern "' . $pregex . '" is invalid', 'pregex', array('pregex' => $pregex));
  44509. continue;
  44510. }
  44511. foreach ($element as $i => $value) {
  44512. if (preg_match($delimiter . $pregex . $delimiter . 'u', $i)) {
  44513. $matches[] = $i;
  44514. $this->checkUndefined($value, $schema ?: new \stdClass(), $path, $i, in_array($i, $this->appliedDefaults));
  44515. }
  44516. }
  44517. }
  44518. return $matches;
  44519. }
  44520. public function validateElement($element, $matches, $schema = null, JsonPointer $path = null,
  44521. $properties = null, $additionalProp = null)
  44522. {
  44523. $this->validateMinMaxConstraint($element, $schema, $path);
  44524. foreach ($element as $i => $value) {
  44525. $definition = $this->getProperty($properties, $i);
  44526. if (!in_array($i, $matches) && $additionalProp === false && $this->inlineSchemaProperty !== $i && !$definition) {
  44527. $this->addError($path, 'The property ' . $i . ' is not defined and the definition does not allow additional properties', 'additionalProp');
  44528. }
  44529. if (!in_array($i, $matches) && $additionalProp && !$definition) {
  44530. if ($additionalProp === true) {
  44531. $this->checkUndefined($value, null, $path, $i, in_array($i, $this->appliedDefaults));
  44532. } else {
  44533. $this->checkUndefined($value, $additionalProp, $path, $i, in_array($i, $this->appliedDefaults));
  44534. }
  44535. }
  44536. $require = $this->getProperty($definition, 'requires');
  44537. if ($require && !$this->getProperty($element, $require)) {
  44538. $this->addError($path, 'The presence of the property ' . $i . ' requires that ' . $require . ' also be present', 'requires');
  44539. }
  44540. $property = $this->getProperty($element, $i, $this->factory->createInstanceFor('undefined'));
  44541. if (is_object($property)) {
  44542. $this->validateMinMaxConstraint(!($property instanceof UndefinedConstraint) ? $property : $element, $definition, $path);
  44543. }
  44544. }
  44545. }
  44546. public function validateProperties(&$element, $properties = null, JsonPointer $path = null)
  44547. {
  44548. $undefinedConstraint = $this->factory->createInstanceFor('undefined');
  44549. foreach ($properties as $i => $value) {
  44550. $property = &$this->getProperty($element, $i, $undefinedConstraint);
  44551. $definition = $this->getProperty($properties, $i);
  44552. if (is_object($definition)) {
  44553. $this->checkUndefined($property, $definition, $path, $i, in_array($i, $this->appliedDefaults));
  44554. }
  44555. }
  44556. }
  44557. protected function &getProperty(&$element, $property, $fallback = null)
  44558. {
  44559. if (is_array($element) && (isset($element[$property]) || array_key_exists($property, $element)) ) {
  44560. return $element[$property];
  44561. } elseif (is_object($element) && property_exists($element, $property)) {
  44562. return $element->$property;
  44563. }
  44564. return $fallback;
  44565. }
  44566. protected function validateMinMaxConstraint($element, $objectDefinition, JsonPointer $path = null)
  44567. {
  44568. if (isset($objectDefinition->minProperties) && !is_object($objectDefinition->minProperties)) {
  44569. if ($this->getTypeCheck()->propertyCount($element) < $objectDefinition->minProperties) {
  44570. $this->addError($path, 'Must contain a minimum of ' . $objectDefinition->minProperties . ' properties', 'minProperties', array('minProperties' => $objectDefinition->minProperties));
  44571. }
  44572. }
  44573. if (isset($objectDefinition->maxProperties) && !is_object($objectDefinition->maxProperties)) {
  44574. if ($this->getTypeCheck()->propertyCount($element) > $objectDefinition->maxProperties) {
  44575. $this->addError($path, 'Must contain no more than ' . $objectDefinition->maxProperties . ' properties', 'maxProperties', array('maxProperties' => $objectDefinition->maxProperties));
  44576. }
  44577. }
  44578. }
  44579. }
  44580. <?php
  44581. namespace JsonSchema\Constraints;
  44582. use JsonSchema\Entity\JsonPointer;
  44583. use JsonSchema\Exception\InvalidArgumentException;
  44584. use JsonSchema\Exception\InvalidSchemaException;
  44585. use JsonSchema\Exception\RuntimeException;
  44586. use JsonSchema\Validator;
  44587. class SchemaConstraint extends Constraint
  44588. {
  44589. const DEFAULT_SCHEMA_SPEC = 'http://json-schema.org/draft-04/schema#';
  44590. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44591. {
  44592. if ($schema !== null) {
  44593. $validationSchema = $schema;
  44594. } elseif ($this->getTypeCheck()->propertyExists($element, $this->inlineSchemaProperty)) {
  44595. $validationSchema = $this->getTypeCheck()->propertyGet($element, $this->inlineSchemaProperty);
  44596. } else {
  44597. throw new InvalidArgumentException('no schema found to verify against');
  44598. }
  44599. if (is_array($validationSchema)) {
  44600. $validationSchema = BaseConstraint::arrayToObjectRecursive($validationSchema);
  44601. }
  44602. if ($this->factory->getConfig(self::CHECK_MODE_VALIDATE_SCHEMA)) {
  44603. if (!$this->getTypeCheck()->isObject($validationSchema)) {
  44604. throw new RuntimeException('Cannot validate the schema of a non-object');
  44605. }
  44606. if ($this->getTypeCheck()->propertyExists($validationSchema, '$schema')) {
  44607. $schemaSpec = $this->getTypeCheck()->propertyGet($validationSchema, '$schema');
  44608. } else {
  44609. $schemaSpec = self::DEFAULT_SCHEMA_SPEC;
  44610. }
  44611. $schemaStorage = $this->factory->getSchemaStorage();
  44612. if (!$this->getTypeCheck()->isObject($schemaSpec)) {
  44613. $schemaSpec = $schemaStorage->getSchema($schemaSpec);
  44614. }
  44615. $initialErrorCount = $this->numErrors();
  44616. $initialConfig = $this->factory->getConfig();
  44617. $initialContext = $this->factory->getErrorContext();
  44618. $this->factory->removeConfig(self::CHECK_MODE_VALIDATE_SCHEMA | self::CHECK_MODE_APPLY_DEFAULTS);
  44619. $this->factory->addConfig(self::CHECK_MODE_TYPE_CAST);
  44620. $this->factory->setErrorContext(Validator::ERROR_SCHEMA_VALIDATION);
  44621. try {
  44622. $this->check($validationSchema, $schemaSpec);
  44623. } catch (\Exception $e) {
  44624. if ($this->factory->getConfig(self::CHECK_MODE_EXCEPTIONS)) {
  44625. throw new InvalidSchemaException('Schema did not pass validation', 0, $e);
  44626. }
  44627. }
  44628. if ($this->numErrors() > $initialErrorCount) {
  44629. $this->addError($path, 'Schema is not valid', 'schema');
  44630. }
  44631. $this->factory->setConfig($initialConfig);
  44632. $this->factory->setErrorContext($initialContext);
  44633. }
  44634. $this->checkUndefined($element, $validationSchema, $path, $i);
  44635. }
  44636. }
  44637. <?php
  44638. namespace JsonSchema\Constraints;
  44639. use JsonSchema\Entity\JsonPointer;
  44640. class StringConstraint extends Constraint
  44641. {
  44642. public function check(&$element, $schema = null, JsonPointer $path = null, $i = null)
  44643. {
  44644. if (isset($schema->maxLength) && $this->strlen($element) > $schema->maxLength) {
  44645. $this->addError($path, 'Must be at most ' . $schema->maxLength . ' characters long', 'maxLength', array(
  44646. 'maxLength' => $schema->maxLength,
  44647. ));
  44648. }
  44649. if (isset($schema->minLength) && $this->strlen($element) < $schema->minLength) {
  44650. $this->addError($path, 'Must be at least ' . $schema->minLength . ' characters long', 'minLength', array(
  44651. 'minLength' => $schema->minLength,
  44652. ));
  44653. }
  44654. if (isset($schema->pattern) && !preg_match('#' . str_replace('#', '\\#', $schema->pattern) . '#u', $element)) {
  44655. $this->addError($path, 'Does not match the regex pattern ' . $schema->pattern, 'pattern', array(
  44656. 'pattern' => $schema->pattern,
  44657. ));
  44658. }
  44659. $this->checkFormat($element, $schema, $path, $i);
  44660. }
  44661. private function strlen($string)
  44662. {
  44663. if (extension_loaded('mbstring')) {
  44664. return mb_strlen($string, mb_detect_encoding($string));
  44665. }
  44666. return strlen($string);
  44667. }
  44668. }
  44669. <?php
  44670. namespace JsonSchema\Constraints\TypeCheck;
  44671. class LooseTypeCheck implements TypeCheckInterface
  44672. {
  44673. public static function isObject($value)
  44674. {
  44675. return
  44676. is_object($value) ||
  44677. (is_array($value) && (count($value) == 0 || self::isAssociativeArray($value)));
  44678. }
  44679. public static function isArray($value)
  44680. {
  44681. return
  44682. is_array($value) &&
  44683. (count($value) == 0 || !self::isAssociativeArray($value));
  44684. }
  44685. public static function propertyGet($value, $property)
  44686. {
  44687. if (is_object($value)) {
  44688. return $value->{$property};
  44689. }
  44690. return $value[$property];
  44691. }
  44692. public static function propertySet(&$value, $property, $data)
  44693. {
  44694. if (is_object($value)) {
  44695. $value->{$property} = $data;
  44696. } else {
  44697. $value[$property] = $data;
  44698. }
  44699. }
  44700. public static function propertyExists($value, $property)
  44701. {
  44702. if (is_object($value)) {
  44703. return property_exists($value, $property);
  44704. }
  44705. return array_key_exists($property, $value);
  44706. }
  44707. public static function propertyCount($value)
  44708. {
  44709. if (is_object($value)) {
  44710. return count(get_object_vars($value));
  44711. }
  44712. return count($value);
  44713. }
  44714. private static function isAssociativeArray($arr)
  44715. {
  44716. return array_keys($arr) !== range(0, count($arr) - 1);
  44717. }
  44718. }
  44719. <?php
  44720. namespace JsonSchema\Constraints\TypeCheck;
  44721. class StrictTypeCheck implements TypeCheckInterface
  44722. {
  44723. public static function isObject($value)
  44724. {
  44725. return is_object($value);
  44726. }
  44727. public static function isArray($value)
  44728. {
  44729. return is_array($value);
  44730. }
  44731. public static function propertyGet($value, $property)
  44732. {
  44733. return $value->{$property};
  44734. }
  44735. public static function propertySet(&$value, $property, $data)
  44736. {
  44737. $value->{$property} = $data;
  44738. }
  44739. public static function propertyExists($value, $property)
  44740. {
  44741. return property_exists($value, $property);
  44742. }
  44743. public static function propertyCount($value)
  44744. {
  44745. if (!is_object($value)) {
  44746. return 0;
  44747. }
  44748. return count(get_object_vars($value));
  44749. }
  44750. }
  44751. <?php
  44752. namespace JsonSchema\Constraints\TypeCheck;
  44753. interface TypeCheckInterface
  44754. {
  44755. public static function isObject($value);
  44756. public static function isArray($value);
  44757. public static function propertyGet($value, $property);
  44758. public static function propertySet(&$value, $property, $data);
  44759. public static function propertyExists($value, $property);
  44760. public static function propertyCount($value);
  44761. }
  44762. <?php
  44763. namespace JsonSchema\Constraints;
  44764. use JsonSchema\Entity\JsonPointer;
  44765. use JsonSchema\Exception\InvalidArgumentException;
  44766. use UnexpectedValueException as StandardUnexpectedValueException;
  44767. class TypeConstraint extends Constraint
  44768. {
  44769. public static $wording = array(
  44770. 'integer' => 'an integer',
  44771. 'number' => 'a number',
  44772. 'boolean' => 'a boolean',
  44773. 'object' => 'an object',
  44774. 'array' => 'an array',
  44775. 'string' => 'a string',
  44776. 'null' => 'a null',
  44777. 'any' => null,
  44778. 0 => null,
  44779. );
  44780. public function check(&$value = null, $schema = null, JsonPointer $path = null, $i = null)
  44781. {
  44782. $type = isset($schema->type) ? $schema->type : null;
  44783. $isValid = false;
  44784. $wording = array();
  44785. if (is_array($type)) {
  44786. $this->validateTypesArray($value, $type, $wording, $isValid, $path);
  44787. } elseif (is_object($type)) {
  44788. $this->checkUndefined($value, $type, $path);
  44789. return;
  44790. } else {
  44791. $isValid = $this->validateType($value, $type);
  44792. }
  44793. if ($isValid === false) {
  44794. if (!is_array($type)) {
  44795. $this->validateTypeNameWording($type);
  44796. $wording[] = self::$wording[$type];
  44797. }
  44798. $this->addError($path, ucwords(gettype($value)) . ' value found, but ' .
  44799. $this->implodeWith($wording, ', ', 'or') . ' is required', 'type');
  44800. }
  44801. }
  44802. protected function validateTypesArray(&$value, array $type, &$validTypesWording, &$isValid, $path)
  44803. {
  44804. foreach ($type as $tp) {
  44805. if (is_object($tp)) {
  44806. if (!$isValid) {
  44807. $validator = $this->factory->createInstanceFor('type');
  44808. $subSchema = new \stdClass();
  44809. $subSchema->type = $tp;
  44810. $validator->check($value, $subSchema, $path, null);
  44811. $error = $validator->getErrors();
  44812. $isValid = !(bool) $error;
  44813. $validTypesWording[] = self::$wording['object'];
  44814. }
  44815. } else {
  44816. $this->validateTypeNameWording($tp);
  44817. $validTypesWording[] = self::$wording[$tp];
  44818. if (!$isValid) {
  44819. $isValid = $this->validateType($value, $tp);
  44820. }
  44821. }
  44822. }
  44823. }
  44824. protected function implodeWith(array $elements, $delimiter = ', ', $listEnd = false)
  44825. {
  44826. if ($listEnd === false || !isset($elements[1])) {
  44827. return implode($delimiter, $elements);
  44828. }
  44829. $lastElement = array_slice($elements, -1);
  44830. $firsElements = join($delimiter, array_slice($elements, 0, -1));
  44831. $implodedElements = array_merge(array($firsElements), $lastElement);
  44832. return join(" $listEnd ", $implodedElements);
  44833. }
  44834. protected function validateTypeNameWording($type)
  44835. {
  44836. if (!isset(self::$wording[$type])) {
  44837. throw new StandardUnexpectedValueException(
  44838. sprintf(
  44839. 'No wording for %s available, expected wordings are: [%s]',
  44840. var_export($type, true),
  44841. implode(', ', array_filter(self::$wording)))
  44842. );
  44843. }
  44844. }
  44845. protected function validateType(&$value, $type)
  44846. {
  44847. if (!$type) {
  44848. return true;
  44849. }
  44850. if ('any' === $type) {
  44851. return true;
  44852. }
  44853. if ('object' === $type) {
  44854. return $this->getTypeCheck()->isObject($value);
  44855. }
  44856. if ('array' === $type) {
  44857. return $this->getTypeCheck()->isArray($value);
  44858. }
  44859. $coerce = $this->factory->getConfig(Constraint::CHECK_MODE_COERCE_TYPES);
  44860. if ('integer' === $type) {
  44861. if ($coerce) {
  44862. $value = $this->toInteger($value);
  44863. }
  44864. return is_int($value);
  44865. }
  44866. if ('number' === $type) {
  44867. if ($coerce) {
  44868. $value = $this->toNumber($value);
  44869. }
  44870. return is_numeric($value) && !is_string($value);
  44871. }
  44872. if ('boolean' === $type) {
  44873. if ($coerce) {
  44874. $value = $this->toBoolean($value);
  44875. }
  44876. return is_bool($value);
  44877. }
  44878. if ('string' === $type) {
  44879. return is_string($value);
  44880. }
  44881. if ('email' === $type) {
  44882. return is_string($value);
  44883. }
  44884. if ('null' === $type) {
  44885. return is_null($value);
  44886. }
  44887. throw new InvalidArgumentException((is_object($value) ? 'object' : $value) . ' is an invalid type for ' . $type);
  44888. }
  44889. protected function toBoolean($value)
  44890. {
  44891. if ($value === 'true') {
  44892. return true;
  44893. }
  44894. if ($value === 'false') {
  44895. return false;
  44896. }
  44897. return $value;
  44898. }
  44899. protected function toNumber($value)
  44900. {
  44901. if (is_numeric($value)) {
  44902. return $value + 0;
  44903. }
  44904. return $value;
  44905. }
  44906. protected function toInteger($value)
  44907. {
  44908. if (is_numeric($value) && (int) $value == $value) {
  44909. return (int) $value;
  44910. }
  44911. return $value;
  44912. }
  44913. }
  44914. <?php
  44915. namespace JsonSchema\Constraints;
  44916. use JsonSchema\Constraints\TypeCheck\LooseTypeCheck;
  44917. use JsonSchema\Entity\JsonPointer;
  44918. use JsonSchema\Exception\ValidationException;
  44919. use JsonSchema\Uri\UriResolver;
  44920. class UndefinedConstraint extends Constraint
  44921. {
  44922. protected $appliedDefaults = array();
  44923. public function check(&$value, $schema = null, JsonPointer $path = null, $i = null, $fromDefault = false)
  44924. {
  44925. if (is_null($schema) || !is_object($schema)) {
  44926. return;
  44927. }
  44928. $path = $this->incrementPath($path ?: new JsonPointer(''), $i);
  44929. if ($fromDefault) {
  44930. $path->setFromDefault();
  44931. }
  44932. $this->validateCommonProperties($value, $schema, $path, $i);
  44933. $this->validateOfProperties($value, $schema, $path, '');
  44934. $this->validateTypes($value, $schema, $path, $i);
  44935. }
  44936. public function validateTypes(&$value, $schema, JsonPointer $path, $i = null)
  44937. {
  44938. if ($this->getTypeCheck()->isArray($value)) {
  44939. $this->checkArray($value, $schema, $path, $i);
  44940. }
  44941. if (LooseTypeCheck::isObject($value)) {
  44942. $this->checkObject(
  44943. $value,
  44944. $schema,
  44945. $path,
  44946. isset($schema->properties) ? $schema->properties : null,
  44947. isset($schema->additionalProperties) ? $schema->additionalProperties : null,
  44948. isset($schema->patternProperties) ? $schema->patternProperties : null,
  44949. $this->appliedDefaults
  44950. );
  44951. }
  44952. if (is_string($value)) {
  44953. $this->checkString($value, $schema, $path, $i);
  44954. }
  44955. if (is_numeric($value)) {
  44956. $this->checkNumber($value, $schema, $path, $i);
  44957. }
  44958. if (isset($schema->enum)) {
  44959. $this->checkEnum($value, $schema, $path, $i);
  44960. }
  44961. }
  44962. protected function validateCommonProperties(&$value, $schema, JsonPointer $path, $i = '')
  44963. {
  44964. if (isset($schema->extends)) {
  44965. if (is_string($schema->extends)) {
  44966. $schema->extends = $this->validateUri($schema, $schema->extends);
  44967. }
  44968. if (is_array($schema->extends)) {
  44969. foreach ($schema->extends as $extends) {
  44970. $this->checkUndefined($value, $extends, $path, $i);
  44971. }
  44972. } else {
  44973. $this->checkUndefined($value, $schema->extends, $path, $i);
  44974. }
  44975. }
  44976. if (!$path->fromDefault()) {
  44977. $this->applyDefaultValues($value, $schema, $path);
  44978. }
  44979. if ($this->getTypeCheck()->isObject($value)) {
  44980. if (!($value instanceof self) && isset($schema->required) && is_array($schema->required)) {
  44981. foreach ($schema->required as $required) {
  44982. if (!$this->getTypeCheck()->propertyExists($value, $required)) {
  44983. $this->addError(
  44984. $this->incrementPath($path ?: new JsonPointer(''), $required),
  44985. 'The property ' . $required . ' is required',
  44986. 'required'
  44987. );
  44988. }
  44989. }
  44990. } elseif (isset($schema->required) && !is_array($schema->required)) {
  44991. if ($schema->required && $value instanceof self) {
  44992. $propertyPaths = $path->getPropertyPaths();
  44993. $propertyName = end($propertyPaths);
  44994. $this->addError(
  44995. $path,
  44996. 'The property ' . $propertyName . ' is required',
  44997. 'required'
  44998. );
  44999. }
  45000. } else {
  45001. if ($value instanceof self) {
  45002. return;
  45003. }
  45004. }
  45005. }
  45006. if (!($value instanceof self)) {
  45007. $this->checkType($value, $schema, $path, $i);
  45008. }
  45009. if (isset($schema->disallow)) {
  45010. $initErrors = $this->getErrors();
  45011. $typeSchema = new \stdClass();
  45012. $typeSchema->type = $schema->disallow;
  45013. $this->checkType($value, $typeSchema, $path);
  45014. if (count($this->getErrors()) == count($initErrors)) {
  45015. $this->addError($path, 'Disallowed value was matched', 'disallow');
  45016. } else {
  45017. $this->errors = $initErrors;
  45018. }
  45019. }
  45020. if (isset($schema->not)) {
  45021. $initErrors = $this->getErrors();
  45022. $this->checkUndefined($value, $schema->not, $path, $i);
  45023. if (count($this->getErrors()) == count($initErrors)) {
  45024. $this->addError($path, 'Matched a schema which it should not', 'not');
  45025. } else {
  45026. $this->errors = $initErrors;
  45027. }
  45028. }
  45029. if (isset($schema->dependencies) && $this->getTypeCheck()->isObject($value)) {
  45030. $this->validateDependencies($value, $schema->dependencies, $path);
  45031. }
  45032. }
  45033. private function shouldApplyDefaultValue($requiredOnly, $schema, $name = null, $parentSchema = null)
  45034. {
  45035. if (!$requiredOnly) {
  45036. return true;
  45037. }
  45038. if (
  45039. $name !== null
  45040. && isset($parentSchema->required)
  45041. && is_array($parentSchema->required)
  45042. && in_array($name, $parentSchema->required)
  45043. ) {
  45044. return true;
  45045. }
  45046. if (isset($schema->required) && !is_array($schema->required) && $schema->required) {
  45047. return true;
  45048. }
  45049. return false;
  45050. }
  45051. protected function applyDefaultValues(&$value, $schema, $path)
  45052. {
  45053. if (!$this->factory->getConfig(self::CHECK_MODE_APPLY_DEFAULTS)) {
  45054. return;
  45055. }
  45056. $requiredOnly = $this->factory->getConfig(self::CHECK_MODE_ONLY_REQUIRED_DEFAULTS);
  45057. if (isset($schema->properties) && LooseTypeCheck::isObject($value)) {
  45058. foreach ($schema->properties as $currentProperty => $propertyDefinition) {
  45059. $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition);
  45060. if (
  45061. !LooseTypeCheck::propertyExists($value, $currentProperty)
  45062. && property_exists($propertyDefinition, 'default')
  45063. && $this->shouldApplyDefaultValue($requiredOnly, $propertyDefinition, $currentProperty, $schema)
  45064. ) {
  45065. if (is_object($propertyDefinition->default)) {
  45066. LooseTypeCheck::propertySet($value, $currentProperty, clone $propertyDefinition->default);
  45067. } else {
  45068. LooseTypeCheck::propertySet($value, $currentProperty, $propertyDefinition->default);
  45069. }
  45070. $this->appliedDefaults[] = $currentProperty;
  45071. }
  45072. }
  45073. } elseif (isset($schema->items) && LooseTypeCheck::isArray($value)) {
  45074. $items = array();
  45075. if (LooseTypeCheck::isArray($schema->items)) {
  45076. $items = $schema->items;
  45077. } elseif (isset($schema->minItems) && count($value) < $schema->minItems) {
  45078. $items = array_fill(count($value), $schema->minItems - count($value), $schema->items);
  45079. }
  45080. foreach ($items as $currentItem => $itemDefinition) {
  45081. $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
  45082. if (
  45083. !array_key_exists($currentItem, $value)
  45084. && property_exists($itemDefinition, 'default')
  45085. && $this->shouldApplyDefaultValue($requiredOnly, $itemDefinition)) {
  45086. if (is_object($itemDefinition->default)) {
  45087. $value[$currentItem] = clone $itemDefinition->default;
  45088. } else {
  45089. $value[$currentItem] = $itemDefinition->default;
  45090. }
  45091. }
  45092. $path->setFromDefault();
  45093. }
  45094. } elseif (
  45095. $value instanceof self
  45096. && property_exists($schema, 'default')
  45097. && $this->shouldApplyDefaultValue($requiredOnly, $schema)) {
  45098. $value = is_object($schema->default) ? clone $schema->default : $schema->default;
  45099. $path->setFromDefault();
  45100. }
  45101. }
  45102. protected function validateOfProperties(&$value, $schema, JsonPointer $path, $i = '')
  45103. {
  45104. if ($value instanceof self) {
  45105. return;
  45106. }
  45107. if (isset($schema->allOf)) {
  45108. $isValid = true;
  45109. foreach ($schema->allOf as $allOf) {
  45110. $initErrors = $this->getErrors();
  45111. $this->checkUndefined($value, $allOf, $path, $i);
  45112. $isValid = $isValid && (count($this->getErrors()) == count($initErrors));
  45113. }
  45114. if (!$isValid) {
  45115. $this->addError($path, 'Failed to match all schemas', 'allOf');
  45116. }
  45117. }
  45118. if (isset($schema->anyOf)) {
  45119. $isValid = false;
  45120. $startErrors = $this->getErrors();
  45121. $caughtException = null;
  45122. foreach ($schema->anyOf as $anyOf) {
  45123. $initErrors = $this->getErrors();
  45124. try {
  45125. $this->checkUndefined($value, $anyOf, $path, $i);
  45126. if ($isValid = (count($this->getErrors()) == count($initErrors))) {
  45127. break;
  45128. }
  45129. } catch (ValidationException $e) {
  45130. $isValid = false;
  45131. }
  45132. }
  45133. if (!$isValid) {
  45134. $this->addError($path, 'Failed to match at least one schema', 'anyOf');
  45135. } else {
  45136. $this->errors = $startErrors;
  45137. }
  45138. }
  45139. if (isset($schema->oneOf)) {
  45140. $allErrors = array();
  45141. $matchedSchemas = 0;
  45142. $startErrors = $this->getErrors();
  45143. foreach ($schema->oneOf as $oneOf) {
  45144. try {
  45145. $this->errors = array();
  45146. $this->checkUndefined($value, $oneOf, $path, $i);
  45147. if (count($this->getErrors()) == 0) {
  45148. $matchedSchemas++;
  45149. }
  45150. $allErrors = array_merge($allErrors, array_values($this->getErrors()));
  45151. } catch (ValidationException $e) {
  45152. }
  45153. }
  45154. if ($matchedSchemas !== 1) {
  45155. $this->addErrors(array_merge($allErrors, $startErrors));
  45156. $this->addError($path, 'Failed to match exactly one schema', 'oneOf');
  45157. } else {
  45158. $this->errors = $startErrors;
  45159. }
  45160. }
  45161. }
  45162. protected function validateDependencies($value, $dependencies, JsonPointer $path, $i = '')
  45163. {
  45164. foreach ($dependencies as $key => $dependency) {
  45165. if ($this->getTypeCheck()->propertyExists($value, $key)) {
  45166. if (is_string($dependency)) {
  45167. if (!$this->getTypeCheck()->propertyExists($value, $dependency)) {
  45168. $this->addError($path, "$key depends on $dependency and $dependency is missing", 'dependencies');
  45169. }
  45170. } elseif (is_array($dependency)) {
  45171. foreach ($dependency as $d) {
  45172. if (!$this->getTypeCheck()->propertyExists($value, $d)) {
  45173. $this->addError($path, "$key depends on $d and $d is missing", 'dependencies');
  45174. }
  45175. }
  45176. } elseif (is_object($dependency)) {
  45177. $this->checkUndefined($value, $dependency, $path, $i);
  45178. }
  45179. }
  45180. }
  45181. }
  45182. protected function validateUri($schema, $schemaUri = null)
  45183. {
  45184. $resolver = new UriResolver();
  45185. $retriever = $this->factory->getUriRetriever();
  45186. $jsonSchema = null;
  45187. if ($resolver->isValid($schemaUri)) {
  45188. $schemaId = property_exists($schema, 'id') ? $schema->id : null;
  45189. $jsonSchema = $retriever->retrieve($schemaId, $schemaUri);
  45190. }
  45191. return $jsonSchema;
  45192. }
  45193. }
  45194. <?php
  45195. namespace JsonSchema\Entity;
  45196. use JsonSchema\Exception\InvalidArgumentException;
  45197. class JsonPointer
  45198. {
  45199. private $filename;
  45200. private $propertyPaths = array();
  45201. private $fromDefault = false;
  45202. public function __construct($value)
  45203. {
  45204. if (!is_string($value)) {
  45205. throw new InvalidArgumentException('Ref value must be a string');
  45206. }
  45207. $splitRef = explode('#', $value, 2);
  45208. $this->filename = $splitRef[0];
  45209. if (array_key_exists(1, $splitRef)) {
  45210. $this->propertyPaths = $this->decodePropertyPaths($splitRef[1]);
  45211. }
  45212. }
  45213. private function decodePropertyPaths($propertyPathString)
  45214. {
  45215. $paths = array();
  45216. foreach (explode('/', trim($propertyPathString, '/')) as $path) {
  45217. $path = $this->decodePath($path);
  45218. if (is_string($path) && '' !== $path) {
  45219. $paths[] = $path;
  45220. }
  45221. }
  45222. return $paths;
  45223. }
  45224. private function encodePropertyPaths()
  45225. {
  45226. return array_map(
  45227. array($this, 'encodePath'),
  45228. $this->getPropertyPaths()
  45229. );
  45230. }
  45231. private function decodePath($path)
  45232. {
  45233. return strtr($path, array('~1' => '/', '~0' => '~', '%25' => '%'));
  45234. }
  45235. private function encodePath($path)
  45236. {
  45237. return strtr($path, array('/' => '~1', '~' => '~0', '%' => '%25'));
  45238. }
  45239. public function getFilename()
  45240. {
  45241. return $this->filename;
  45242. }
  45243. public function getPropertyPaths()
  45244. {
  45245. return $this->propertyPaths;
  45246. }
  45247. public function withPropertyPaths(array $propertyPaths)
  45248. {
  45249. $new = clone $this;
  45250. $new->propertyPaths = $propertyPaths;
  45251. return $new;
  45252. }
  45253. public function getPropertyPathAsString()
  45254. {
  45255. return rtrim('#/' . implode('/', $this->encodePropertyPaths()), '/');
  45256. }
  45257. public function __toString()
  45258. {
  45259. return $this->getFilename() . $this->getPropertyPathAsString();
  45260. }
  45261. public function setFromDefault()
  45262. {
  45263. $this->fromDefault = true;
  45264. }
  45265. public function fromDefault()
  45266. {
  45267. return $this->fromDefault;
  45268. }
  45269. }
  45270. <?php
  45271. namespace JsonSchema\Exception;
  45272. interface ExceptionInterface
  45273. {
  45274. }
  45275. <?php
  45276. namespace JsonSchema\Exception;
  45277. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  45278. {
  45279. }
  45280. <?php
  45281. namespace JsonSchema\Exception;
  45282. class InvalidConfigException extends RuntimeException
  45283. {
  45284. }
  45285. <?php
  45286. namespace JsonSchema\Exception;
  45287. class InvalidSchemaException extends RuntimeException
  45288. {
  45289. }
  45290. <?php
  45291. namespace JsonSchema\Exception;
  45292. class InvalidSchemaMediaTypeException extends RuntimeException
  45293. {
  45294. }
  45295. <?php
  45296. namespace JsonSchema\Exception;
  45297. class InvalidSourceUriException extends InvalidArgumentException
  45298. {
  45299. }
  45300. <?php
  45301. namespace JsonSchema\Exception;
  45302. class JsonDecodingException extends RuntimeException
  45303. {
  45304. public function __construct($code = JSON_ERROR_NONE, \Exception $previous = null)
  45305. {
  45306. switch ($code) {
  45307. case JSON_ERROR_DEPTH:
  45308. $message = 'The maximum stack depth has been exceeded';
  45309. break;
  45310. case JSON_ERROR_STATE_MISMATCH:
  45311. $message = 'Invalid or malformed JSON';
  45312. break;
  45313. case JSON_ERROR_CTRL_CHAR:
  45314. $message = 'Control character error, possibly incorrectly encoded';
  45315. break;
  45316. case JSON_ERROR_UTF8:
  45317. $message = 'Malformed UTF-8 characters, possibly incorrectly encoded';
  45318. break;
  45319. case JSON_ERROR_SYNTAX:
  45320. $message = 'JSON syntax is malformed';
  45321. break;
  45322. default:
  45323. $message = 'Syntax error';
  45324. }
  45325. parent::__construct($message, $code, $previous);
  45326. }
  45327. }
  45328. <?php
  45329. namespace JsonSchema\Exception;
  45330. class ResourceNotFoundException extends RuntimeException
  45331. {
  45332. }
  45333. <?php
  45334. namespace JsonSchema\Exception;
  45335. class RuntimeException extends \RuntimeException implements ExceptionInterface
  45336. {
  45337. }
  45338. <?php
  45339. namespace JsonSchema\Exception;
  45340. class UnresolvableJsonPointerException extends InvalidArgumentException
  45341. {
  45342. }
  45343. <?php
  45344. namespace JsonSchema\Exception;
  45345. class UriResolverException extends RuntimeException
  45346. {
  45347. }
  45348. <?php
  45349. namespace JsonSchema\Exception;
  45350. class ValidationException extends RuntimeException
  45351. {
  45352. }
  45353. <?php
  45354. namespace JsonSchema\Iterator;
  45355. class ObjectIterator implements \Iterator, \Countable
  45356. {
  45357. private $object;
  45358. private $position = 0;
  45359. private $data = array();
  45360. private $initialized = false;
  45361. public function __construct($object)
  45362. {
  45363. $this->object = $object;
  45364. }
  45365. public function current()
  45366. {
  45367. $this->initialize();
  45368. return $this->data[$this->position];
  45369. }
  45370. public function next()
  45371. {
  45372. $this->initialize();
  45373. $this->position++;
  45374. }
  45375. public function key()
  45376. {
  45377. $this->initialize();
  45378. return $this->position;
  45379. }
  45380. public function valid()
  45381. {
  45382. $this->initialize();
  45383. return isset($this->data[$this->position]);
  45384. }
  45385. public function rewind()
  45386. {
  45387. $this->initialize();
  45388. $this->position = 0;
  45389. }
  45390. public function count()
  45391. {
  45392. $this->initialize();
  45393. return count($this->data);
  45394. }
  45395. private function initialize()
  45396. {
  45397. if (!$this->initialized) {
  45398. $this->data = $this->buildDataFromObject($this->object);
  45399. $this->initialized = true;
  45400. }
  45401. }
  45402. private function buildDataFromObject($object)
  45403. {
  45404. $result = array();
  45405. $stack = new \SplStack();
  45406. $stack->push($object);
  45407. while (!$stack->isEmpty()) {
  45408. $current = $stack->pop();
  45409. if (is_object($current)) {
  45410. array_push($result, $current);
  45411. }
  45412. foreach ($this->getDataFromItem($current) as $propertyName => $propertyValue) {
  45413. if (is_object($propertyValue) || is_array($propertyValue)) {
  45414. $stack->push($propertyValue);
  45415. }
  45416. }
  45417. }
  45418. return $result;
  45419. }
  45420. private function getDataFromItem($item)
  45421. {
  45422. if (!is_object($item) && !is_array($item)) {
  45423. return array();
  45424. }
  45425. return is_object($item) ? get_object_vars($item) : $item;
  45426. }
  45427. }
  45428. <?php
  45429. namespace JsonSchema;
  45430. class Rfc3339
  45431. {
  45432. const REGEX = '/^(\d{4}-\d{2}-\d{2}[T ]{1}\d{2}:\d{2}:\d{2})(\.\d+)?(Z|([+-]\d{2}):?(\d{2}))$/';
  45433. public static function createFromString($string)
  45434. {
  45435. if (!preg_match(self::REGEX, strtoupper($string), $matches)) {
  45436. return null;
  45437. }
  45438. $dateAndTime = $matches[1];
  45439. $microseconds = $matches[2] ?: '.000000';
  45440. $timeZone = 'Z' !== $matches[3] ? $matches[4] . ':' . $matches[5] : '+00:00';
  45441. $dateFormat = strpos($dateAndTime, 'T') === false ? 'Y-m-d H:i:s.uP' : 'Y-m-d\TH:i:s.uP';
  45442. $dateTime = \DateTime::createFromFormat($dateFormat, $dateAndTime . $microseconds . $timeZone, new \DateTimeZone('UTC'));
  45443. return $dateTime ?: null;
  45444. }
  45445. }
  45446. <?php
  45447. namespace JsonSchema;
  45448. use JsonSchema\Constraints\BaseConstraint;
  45449. use JsonSchema\Entity\JsonPointer;
  45450. use JsonSchema\Exception\UnresolvableJsonPointerException;
  45451. use JsonSchema\Uri\UriResolver;
  45452. use JsonSchema\Uri\UriRetriever;
  45453. class SchemaStorage implements SchemaStorageInterface
  45454. {
  45455. const INTERNAL_PROVIDED_SCHEMA_URI = 'internal://provided-schema/';
  45456. protected $uriRetriever;
  45457. protected $uriResolver;
  45458. protected $schemas = array();
  45459. public function __construct(
  45460. UriRetrieverInterface $uriRetriever = null,
  45461. UriResolverInterface $uriResolver = null
  45462. ) {
  45463. $this->uriRetriever = $uriRetriever ?: new UriRetriever();
  45464. $this->uriResolver = $uriResolver ?: new UriResolver();
  45465. }
  45466. public function getUriRetriever()
  45467. {
  45468. return $this->uriRetriever;
  45469. }
  45470. public function getUriResolver()
  45471. {
  45472. return $this->uriResolver;
  45473. }
  45474. public function addSchema($id, $schema = null)
  45475. {
  45476. if (is_null($schema) && $id !== self::INTERNAL_PROVIDED_SCHEMA_URI) {
  45477. $schema = $this->uriRetriever->retrieve($id);
  45478. }
  45479. if (is_array($schema)) {
  45480. $schema = BaseConstraint::arrayToObjectRecursive($schema);
  45481. }
  45482. if (is_object($schema) && property_exists($schema, 'id')) {
  45483. if ($schema->id == 'http://json-schema.org/draft-04/schema#') {
  45484. $schema->properties->id->format = 'uri-reference';
  45485. } elseif ($schema->id == 'http://json-schema.org/draft-03/schema#') {
  45486. $schema->properties->id->format = 'uri-reference';
  45487. $schema->properties->{'$ref'}->format = 'uri-reference';
  45488. }
  45489. }
  45490. $this->expandRefs($schema, $id);
  45491. $this->schemas[$id] = $schema;
  45492. }
  45493. private function expandRefs(&$schema, $base = null)
  45494. {
  45495. if (!is_object($schema)) {
  45496. if (is_array($schema)) {
  45497. foreach ($schema as &$member) {
  45498. $this->expandRefs($member, $base);
  45499. }
  45500. }
  45501. return;
  45502. }
  45503. if (property_exists($schema, 'id') && is_string($schema->id) && $base != $schema->id) {
  45504. $base = $this->uriResolver->resolve($schema->id, $base);
  45505. }
  45506. if (property_exists($schema, '$ref') && is_string($schema->{'$ref'})) {
  45507. $refPointer = new JsonPointer($this->uriResolver->resolve($schema->{'$ref'}, $base));
  45508. $schema->{'$ref'} = (string) $refPointer;
  45509. }
  45510. foreach ($schema as &$member) {
  45511. $this->expandRefs($member, $base);
  45512. }
  45513. }
  45514. public function getSchema($id)
  45515. {
  45516. if (!array_key_exists($id, $this->schemas)) {
  45517. $this->addSchema($id);
  45518. }
  45519. return $this->schemas[$id];
  45520. }
  45521. public function resolveRef($ref)
  45522. {
  45523. $jsonPointer = new JsonPointer($ref);
  45524. $fileName = $jsonPointer->getFilename();
  45525. if (!strlen($fileName)) {
  45526. throw new UnresolvableJsonPointerException(sprintf(
  45527. "Could not resolve fragment '%s': no file is defined",
  45528. $jsonPointer->getPropertyPathAsString()
  45529. ));
  45530. }
  45531. $refSchema = $this->getSchema($fileName);
  45532. foreach ($jsonPointer->getPropertyPaths() as $path) {
  45533. if (is_object($refSchema) && property_exists($refSchema, $path)) {
  45534. $refSchema = $this->resolveRefSchema($refSchema->{$path});
  45535. } elseif (is_array($refSchema) && array_key_exists($path, $refSchema)) {
  45536. $refSchema = $this->resolveRefSchema($refSchema[$path]);
  45537. } else {
  45538. throw new UnresolvableJsonPointerException(sprintf(
  45539. 'File: %s is found, but could not resolve fragment: %s',
  45540. $jsonPointer->getFilename(),
  45541. $jsonPointer->getPropertyPathAsString()
  45542. ));
  45543. }
  45544. }
  45545. return $refSchema;
  45546. }
  45547. public function resolveRefSchema($refSchema)
  45548. {
  45549. if (is_object($refSchema) && property_exists($refSchema, '$ref') && is_string($refSchema->{'$ref'})) {
  45550. $newSchema = $this->resolveRef($refSchema->{'$ref'});
  45551. $refSchema = (object) (get_object_vars($refSchema) + get_object_vars($newSchema));
  45552. unset($refSchema->{'$ref'});
  45553. }
  45554. return $refSchema;
  45555. }
  45556. }
  45557. <?php
  45558. namespace JsonSchema;
  45559. interface SchemaStorageInterface
  45560. {
  45561. public function addSchema($id, $schema = null);
  45562. public function getSchema($id);
  45563. public function resolveRef($ref);
  45564. public function resolveRefSchema($refSchema);
  45565. }
  45566. <?php
  45567. namespace JsonSchema\Uri\Retrievers;
  45568. abstract class AbstractRetriever implements UriRetrieverInterface
  45569. {
  45570. protected $contentType;
  45571. public function getContentType()
  45572. {
  45573. return $this->contentType;
  45574. }
  45575. }
  45576. <?php
  45577. namespace JsonSchema\Uri\Retrievers;
  45578. use JsonSchema\Exception\RuntimeException;
  45579. use JsonSchema\Validator;
  45580. class Curl extends AbstractRetriever
  45581. {
  45582. protected $messageBody;
  45583. public function __construct()
  45584. {
  45585. if (!function_exists('curl_init')) {
  45586. throw new RuntimeException('cURL not installed');
  45587. }
  45588. }
  45589. public function retrieve($uri)
  45590. {
  45591. $ch = curl_init();
  45592. curl_setopt($ch, CURLOPT_URL, $uri);
  45593. curl_setopt($ch, CURLOPT_HEADER, true);
  45594. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  45595. curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: ' . Validator::SCHEMA_MEDIA_TYPE));
  45596. $response = curl_exec($ch);
  45597. if (false === $response) {
  45598. throw new \JsonSchema\Exception\ResourceNotFoundException('JSON schema not found');
  45599. }
  45600. $this->fetchMessageBody($response);
  45601. $this->fetchContentType($response);
  45602. curl_close($ch);
  45603. return $this->messageBody;
  45604. }
  45605. private function fetchMessageBody($response)
  45606. {
  45607. preg_match("/(?:\r\n){2}(.*)$/ms", $response, $match);
  45608. $this->messageBody = $match[1];
  45609. }
  45610. protected function fetchContentType($response)
  45611. {
  45612. if (0 < preg_match("/Content-Type:(\V*)/ims", $response, $match)) {
  45613. $this->contentType = trim($match[1]);
  45614. return true;
  45615. }
  45616. return false;
  45617. }
  45618. }
  45619. <?php
  45620. namespace JsonSchema\Uri\Retrievers;
  45621. use JsonSchema\Exception\ResourceNotFoundException;
  45622. class FileGetContents extends AbstractRetriever
  45623. {
  45624. protected $messageBody;
  45625. public function retrieve($uri)
  45626. {
  45627. $errorMessage = null;
  45628. set_error_handler(function ($errno, $errstr) use (&$errorMessage) {
  45629. $errorMessage = $errstr;
  45630. });
  45631. $response = file_get_contents($uri);
  45632. restore_error_handler();
  45633. if ($errorMessage) {
  45634. throw new ResourceNotFoundException($errorMessage);
  45635. }
  45636. if (false === $response) {
  45637. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  45638. }
  45639. if ($response == ''
  45640. && substr($uri, 0, 7) == 'file://' && substr($uri, -1) == '/'
  45641. ) {
  45642. throw new ResourceNotFoundException('JSON schema not found at ' . $uri);
  45643. }
  45644. $this->messageBody = $response;
  45645. if (!empty($http_response_header)) {
  45646. $this->fetchContentType($http_response_header);
  45647. } else {
  45648. $this->contentType = null;
  45649. }
  45650. return $this->messageBody;
  45651. }
  45652. private function fetchContentType(array $headers)
  45653. {
  45654. foreach ($headers as $header) {
  45655. if ($this->contentType = self::getContentTypeMatchInHeader($header)) {
  45656. return true;
  45657. }
  45658. }
  45659. return false;
  45660. }
  45661. protected static function getContentTypeMatchInHeader($header)
  45662. {
  45663. if (0 < preg_match("/Content-Type:(\V*)/ims", $header, $match)) {
  45664. return trim($match[1]);
  45665. }
  45666. return null;
  45667. }
  45668. }
  45669. <?php
  45670. namespace JsonSchema\Uri\Retrievers;
  45671. use JsonSchema\Validator;
  45672. class PredefinedArray extends AbstractRetriever
  45673. {
  45674. private $schemas;
  45675. public function __construct(array $schemas, $contentType = Validator::SCHEMA_MEDIA_TYPE)
  45676. {
  45677. $this->schemas = $schemas;
  45678. $this->contentType = $contentType;
  45679. }
  45680. public function retrieve($uri)
  45681. {
  45682. if (!array_key_exists($uri, $this->schemas)) {
  45683. throw new \JsonSchema\Exception\ResourceNotFoundException(sprintf(
  45684. 'The JSON schema "%s" was not found.',
  45685. $uri
  45686. ));
  45687. }
  45688. return $this->schemas[$uri];
  45689. }
  45690. }
  45691. <?php
  45692. namespace JsonSchema\Uri\Retrievers;
  45693. interface UriRetrieverInterface
  45694. {
  45695. public function retrieve($uri);
  45696. public function getContentType();
  45697. }
  45698. <?php
  45699. namespace JsonSchema\Uri;
  45700. use JsonSchema\Exception\UriResolverException;
  45701. use JsonSchema\UriResolverInterface;
  45702. class UriResolver implements UriResolverInterface
  45703. {
  45704. public function parse($uri)
  45705. {
  45706. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  45707. $components = array();
  45708. if (5 < count($match)) {
  45709. $components = array(
  45710. 'scheme' => $match[2],
  45711. 'authority' => $match[4],
  45712. 'path' => $match[5]
  45713. );
  45714. }
  45715. if (7 < count($match)) {
  45716. $components['query'] = $match[7];
  45717. }
  45718. if (9 < count($match)) {
  45719. $components['fragment'] = $match[9];
  45720. }
  45721. return $components;
  45722. }
  45723. public function generate(array $components)
  45724. {
  45725. $uri = $components['scheme'] . '://'
  45726. . $components['authority']
  45727. . $components['path'];
  45728. if (array_key_exists('query', $components) && strlen($components['query'])) {
  45729. $uri .= '?' . $components['query'];
  45730. }
  45731. if (array_key_exists('fragment', $components)) {
  45732. $uri .= '#' . $components['fragment'];
  45733. }
  45734. return $uri;
  45735. }
  45736. public function resolve($uri, $baseUri = null)
  45737. {
  45738. if (
  45739. !is_null($baseUri) &&
  45740. !filter_var($baseUri, \FILTER_VALIDATE_URL) &&
  45741. !preg_match('|^[^/]+://|u', $baseUri)
  45742. ) {
  45743. if (is_file($baseUri)) {
  45744. $baseUri = 'file://' . realpath($baseUri);
  45745. } elseif (is_dir($baseUri)) {
  45746. $baseUri = 'file://' . realpath($baseUri) . '/';
  45747. } else {
  45748. $baseUri = 'file://' . getcwd() . '/' . $baseUri;
  45749. }
  45750. }
  45751. if ($uri == '') {
  45752. return $baseUri;
  45753. }
  45754. $components = $this->parse($uri);
  45755. $path = $components['path'];
  45756. if (!empty($components['scheme'])) {
  45757. return $uri;
  45758. }
  45759. $baseComponents = $this->parse($baseUri);
  45760. $basePath = $baseComponents['path'];
  45761. $baseComponents['path'] = self::combineRelativePathWithBasePath($path, $basePath);
  45762. if (isset($components['fragment'])) {
  45763. $baseComponents['fragment'] = $components['fragment'];
  45764. }
  45765. return $this->generate($baseComponents);
  45766. }
  45767. public static function combineRelativePathWithBasePath($relativePath, $basePath)
  45768. {
  45769. $relativePath = self::normalizePath($relativePath);
  45770. if ($relativePath == '') {
  45771. return $basePath;
  45772. }
  45773. if ($relativePath[0] == '/') {
  45774. return $relativePath;
  45775. }
  45776. $basePathSegments = explode('/', $basePath);
  45777. preg_match('|^/?(\.\./(?:\./)*)*|', $relativePath, $match);
  45778. $numLevelUp = strlen($match[0]) /3 + 1;
  45779. if ($numLevelUp >= count($basePathSegments)) {
  45780. throw new UriResolverException(sprintf("Unable to resolve URI '%s' from base '%s'", $relativePath, $basePath));
  45781. }
  45782. $basePathSegments = array_slice($basePathSegments, 0, -$numLevelUp);
  45783. $path = preg_replace('|^/?(\.\./(\./)*)*|', '', $relativePath);
  45784. return implode('/', $basePathSegments) . '/' . $path;
  45785. }
  45786. private static function normalizePath($path)
  45787. {
  45788. $path = preg_replace('|((?<!\.)\./)*|', '', $path);
  45789. $path = preg_replace('|//|', '/', $path);
  45790. return $path;
  45791. }
  45792. public function isValid($uri)
  45793. {
  45794. $components = $this->parse($uri);
  45795. return !empty($components);
  45796. }
  45797. }
  45798. <?php
  45799. namespace JsonSchema\Uri;
  45800. use JsonSchema\Exception\InvalidSchemaMediaTypeException;
  45801. use JsonSchema\Exception\JsonDecodingException;
  45802. use JsonSchema\Exception\ResourceNotFoundException;
  45803. use JsonSchema\Uri\Retrievers\FileGetContents;
  45804. use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
  45805. use JsonSchema\UriRetrieverInterface as BaseUriRetrieverInterface;
  45806. use JsonSchema\Validator;
  45807. class UriRetriever implements BaseUriRetrieverInterface
  45808. {
  45809. protected $translationMap = array(
  45810. '|^https?://json-schema.org/draft-(0[34])/schema#?|' => 'package://dist/schema/json-schema-draft-$1.json'
  45811. );
  45812. protected $allowedInvalidContentTypeEndpoints = array(
  45813. 'http://json-schema.org/',
  45814. 'https://json-schema.org/'
  45815. );
  45816. protected $uriRetriever = null;
  45817. private $schemaCache = array();
  45818. public function addInvalidContentTypeEndpoint($endpoint)
  45819. {
  45820. $this->allowedInvalidContentTypeEndpoints[] = $endpoint;
  45821. }
  45822. public function confirmMediaType($uriRetriever, $uri)
  45823. {
  45824. $contentType = $uriRetriever->getContentType();
  45825. if (is_null($contentType)) {
  45826. return;
  45827. }
  45828. if (in_array($contentType, array(Validator::SCHEMA_MEDIA_TYPE, 'application/json'))) {
  45829. return;
  45830. }
  45831. foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
  45832. if (strpos($uri, $endpoint) === 0) {
  45833. return true;
  45834. }
  45835. }
  45836. throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
  45837. }
  45838. public function getUriRetriever()
  45839. {
  45840. if (is_null($this->uriRetriever)) {
  45841. $this->setUriRetriever(new FileGetContents());
  45842. }
  45843. return $this->uriRetriever;
  45844. }
  45845. public function resolvePointer($jsonSchema, $uri)
  45846. {
  45847. $resolver = new UriResolver();
  45848. $parsed = $resolver->parse($uri);
  45849. if (empty($parsed['fragment'])) {
  45850. return $jsonSchema;
  45851. }
  45852. $path = explode('/', $parsed['fragment']);
  45853. while ($path) {
  45854. $pathElement = array_shift($path);
  45855. if (!empty($pathElement)) {
  45856. $pathElement = str_replace('~1', '/', $pathElement);
  45857. $pathElement = str_replace('~0', '~', $pathElement);
  45858. if (!empty($jsonSchema->$pathElement)) {
  45859. $jsonSchema = $jsonSchema->$pathElement;
  45860. } else {
  45861. throw new ResourceNotFoundException(
  45862. 'Fragment "' . $parsed['fragment'] . '" not found'
  45863. . ' in ' . $uri
  45864. );
  45865. }
  45866. if (!is_object($jsonSchema)) {
  45867. throw new ResourceNotFoundException(
  45868. 'Fragment part "' . $pathElement . '" is no object '
  45869. . ' in ' . $uri
  45870. );
  45871. }
  45872. }
  45873. }
  45874. return $jsonSchema;
  45875. }
  45876. public function retrieve($uri, $baseUri = null, $translate = true)
  45877. {
  45878. $resolver = new UriResolver();
  45879. $resolvedUri = $fetchUri = $resolver->resolve($uri, $baseUri);
  45880. $arParts = $resolver->parse($resolvedUri);
  45881. if (isset($arParts['fragment'])) {
  45882. unset($arParts['fragment']);
  45883. $fetchUri = $resolver->generate($arParts);
  45884. }
  45885. if ($translate) {
  45886. $fetchUri = $this->translate($fetchUri);
  45887. }
  45888. $jsonSchema = $this->loadSchema($fetchUri);
  45889. $jsonSchema = $this->resolvePointer($jsonSchema, $resolvedUri);
  45890. if ($jsonSchema instanceof \stdClass) {
  45891. $jsonSchema->id = $resolvedUri;
  45892. }
  45893. return $jsonSchema;
  45894. }
  45895. protected function loadSchema($fetchUri)
  45896. {
  45897. if (isset($this->schemaCache[$fetchUri])) {
  45898. return $this->schemaCache[$fetchUri];
  45899. }
  45900. $uriRetriever = $this->getUriRetriever();
  45901. $contents = $this->uriRetriever->retrieve($fetchUri);
  45902. $this->confirmMediaType($uriRetriever, $fetchUri);
  45903. $jsonSchema = json_decode($contents);
  45904. if (JSON_ERROR_NONE < $error = json_last_error()) {
  45905. throw new JsonDecodingException($error);
  45906. }
  45907. $this->schemaCache[$fetchUri] = $jsonSchema;
  45908. return $jsonSchema;
  45909. }
  45910. public function setUriRetriever(UriRetrieverInterface $uriRetriever)
  45911. {
  45912. $this->uriRetriever = $uriRetriever;
  45913. return $this;
  45914. }
  45915. public function parse($uri)
  45916. {
  45917. preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
  45918. $components = array();
  45919. if (5 < count($match)) {
  45920. $components = array(
  45921. 'scheme' => $match[2],
  45922. 'authority' => $match[4],
  45923. 'path' => $match[5]
  45924. );
  45925. }
  45926. if (7 < count($match)) {
  45927. $components['query'] = $match[7];
  45928. }
  45929. if (9 < count($match)) {
  45930. $components['fragment'] = $match[9];
  45931. }
  45932. return $components;
  45933. }
  45934. public function generate(array $components)
  45935. {
  45936. $uri = $components['scheme'] . '://'
  45937. . $components['authority']
  45938. . $components['path'];
  45939. if (array_key_exists('query', $components)) {
  45940. $uri .= $components['query'];
  45941. }
  45942. if (array_key_exists('fragment', $components)) {
  45943. $uri .= $components['fragment'];
  45944. }
  45945. return $uri;
  45946. }
  45947. public function resolve($uri, $baseUri = null)
  45948. {
  45949. $components = $this->parse($uri);
  45950. $path = $components['path'];
  45951. if ((array_key_exists('scheme', $components)) && ('http' === $components['scheme'])) {
  45952. return $uri;
  45953. }
  45954. $baseComponents = $this->parse($baseUri);
  45955. $basePath = $baseComponents['path'];
  45956. $baseComponents['path'] = UriResolver::combineRelativePathWithBasePath($path, $basePath);
  45957. return $this->generate($baseComponents);
  45958. }
  45959. public function isValid($uri)
  45960. {
  45961. $components = $this->parse($uri);
  45962. return !empty($components);
  45963. }
  45964. public function setTranslation($from, $to)
  45965. {
  45966. $this->translationMap[$from] = $to;
  45967. }
  45968. public function translate($uri)
  45969. {
  45970. foreach ($this->translationMap as $from => $to) {
  45971. $uri = preg_replace($from, $to, $uri);
  45972. }
  45973. $uri = preg_replace('|^package://|', sprintf('file://%s/', realpath(__DIR__ . '/../../..')), $uri);
  45974. return $uri;
  45975. }
  45976. }
  45977. <?php
  45978. namespace JsonSchema;
  45979. interface UriResolverInterface
  45980. {
  45981. public function resolve($uri, $baseUri = null);
  45982. }
  45983. <?php
  45984. namespace JsonSchema;
  45985. interface UriRetrieverInterface
  45986. {
  45987. public function retrieve($uri, $baseUri = null);
  45988. }
  45989. <?php
  45990. namespace JsonSchema;
  45991. use JsonSchema\Constraints\BaseConstraint;
  45992. use JsonSchema\Constraints\Constraint;
  45993. class Validator extends BaseConstraint
  45994. {
  45995. const SCHEMA_MEDIA_TYPE = 'application/schema+json';
  45996. const ERROR_NONE = 0x00000000;
  45997. const ERROR_ALL = 0xFFFFFFFF;
  45998. const ERROR_DOCUMENT_VALIDATION = 0x00000001;
  45999. const ERROR_SCHEMA_VALIDATION = 0x00000002;
  46000. public function validate(&$value, $schema = null, $checkMode = null)
  46001. {
  46002. if (is_array($schema)) {
  46003. $schema = self::arrayToObjectRecursive($schema);
  46004. }
  46005. $initialCheckMode = $this->factory->getConfig();
  46006. if ($checkMode !== null) {
  46007. $this->factory->setConfig($checkMode);
  46008. }
  46009. if (is_object($schema) && property_exists($schema, 'id')) {
  46010. $schemaURI = $schema->id;
  46011. } else {
  46012. $schemaURI = SchemaStorage::INTERNAL_PROVIDED_SCHEMA_URI;
  46013. }
  46014. $this->factory->getSchemaStorage()->addSchema($schemaURI, $schema);
  46015. $validator = $this->factory->createInstanceFor('schema');
  46016. $validator->check(
  46017. $value,
  46018. $this->factory->getSchemaStorage()->getSchema($schemaURI)
  46019. );
  46020. $this->factory->setConfig($initialCheckMode);
  46021. $this->addErrors(array_unique($validator->getErrors(), SORT_REGULAR));
  46022. return $validator->getErrorMask();
  46023. }
  46024. public function check($value, $schema)
  46025. {
  46026. return $this->validate($value, $schema);
  46027. }
  46028. public function coerce(&$value, $schema)
  46029. {
  46030. return $this->validate($value, $schema, Constraint::CHECK_MODE_COERCE_TYPES);
  46031. }
  46032. }
  46033. Copyright (c) 2012 PHP Framework Interoperability Group
  46034. Permission is hereby granted, free of charge, to any person obtaining a copy
  46035. of this software and associated documentation files (the "Software"), to deal
  46036. in the Software without restriction, including without limitation the rights
  46037. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  46038. copies of the Software, and to permit persons to whom the Software is
  46039. furnished to do so, subject to the following conditions:
  46040. The above copyright notice and this permission notice shall be included in
  46041. all copies or substantial portions of the Software.
  46042. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46043. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46044. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  46045. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  46046. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  46047. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  46048. THE SOFTWARE.
  46049. <?php
  46050. namespace Psr\Log;
  46051. abstract class AbstractLogger implements LoggerInterface
  46052. {
  46053. public function emergency($message, array $context = array())
  46054. {
  46055. $this->log(LogLevel::EMERGENCY, $message, $context);
  46056. }
  46057. public function alert($message, array $context = array())
  46058. {
  46059. $this->log(LogLevel::ALERT, $message, $context);
  46060. }
  46061. public function critical($message, array $context = array())
  46062. {
  46063. $this->log(LogLevel::CRITICAL, $message, $context);
  46064. }
  46065. public function error($message, array $context = array())
  46066. {
  46067. $this->log(LogLevel::ERROR, $message, $context);
  46068. }
  46069. public function warning($message, array $context = array())
  46070. {
  46071. $this->log(LogLevel::WARNING, $message, $context);
  46072. }
  46073. public function notice($message, array $context = array())
  46074. {
  46075. $this->log(LogLevel::NOTICE, $message, $context);
  46076. }
  46077. public function info($message, array $context = array())
  46078. {
  46079. $this->log(LogLevel::INFO, $message, $context);
  46080. }
  46081. public function debug($message, array $context = array())
  46082. {
  46083. $this->log(LogLevel::DEBUG, $message, $context);
  46084. }
  46085. }
  46086. <?php
  46087. namespace Psr\Log;
  46088. class InvalidArgumentException extends \InvalidArgumentException
  46089. {
  46090. }
  46091. <?php
  46092. namespace Psr\Log;
  46093. class LogLevel
  46094. {
  46095. const EMERGENCY = 'emergency';
  46096. const ALERT = 'alert';
  46097. const CRITICAL = 'critical';
  46098. const ERROR = 'error';
  46099. const WARNING = 'warning';
  46100. const NOTICE = 'notice';
  46101. const INFO = 'info';
  46102. const DEBUG = 'debug';
  46103. }
  46104. <?php
  46105. namespace Psr\Log;
  46106. interface LoggerAwareInterface
  46107. {
  46108. public function setLogger(LoggerInterface $logger);
  46109. }
  46110. <?php
  46111. namespace Psr\Log;
  46112. trait LoggerAwareTrait
  46113. {
  46114. protected $logger;
  46115. public function setLogger(LoggerInterface $logger)
  46116. {
  46117. $this->logger = $logger;
  46118. }
  46119. }
  46120. <?php
  46121. namespace Psr\Log;
  46122. interface LoggerInterface
  46123. {
  46124. public function emergency($message, array $context = array());
  46125. public function alert($message, array $context = array());
  46126. public function critical($message, array $context = array());
  46127. public function error($message, array $context = array());
  46128. public function warning($message, array $context = array());
  46129. public function notice($message, array $context = array());
  46130. public function info($message, array $context = array());
  46131. public function debug($message, array $context = array());
  46132. public function log($level, $message, array $context = array());
  46133. }
  46134. <?php
  46135. namespace Psr\Log;
  46136. trait LoggerTrait
  46137. {
  46138. public function emergency($message, array $context = array())
  46139. {
  46140. $this->log(LogLevel::EMERGENCY, $message, $context);
  46141. }
  46142. public function alert($message, array $context = array())
  46143. {
  46144. $this->log(LogLevel::ALERT, $message, $context);
  46145. }
  46146. public function critical($message, array $context = array())
  46147. {
  46148. $this->log(LogLevel::CRITICAL, $message, $context);
  46149. }
  46150. public function error($message, array $context = array())
  46151. {
  46152. $this->log(LogLevel::ERROR, $message, $context);
  46153. }
  46154. public function warning($message, array $context = array())
  46155. {
  46156. $this->log(LogLevel::WARNING, $message, $context);
  46157. }
  46158. public function notice($message, array $context = array())
  46159. {
  46160. $this->log(LogLevel::NOTICE, $message, $context);
  46161. }
  46162. public function info($message, array $context = array())
  46163. {
  46164. $this->log(LogLevel::INFO, $message, $context);
  46165. }
  46166. public function debug($message, array $context = array())
  46167. {
  46168. $this->log(LogLevel::DEBUG, $message, $context);
  46169. }
  46170. abstract public function log($level, $message, array $context = array());
  46171. }
  46172. <?php
  46173. namespace Psr\Log;
  46174. class NullLogger extends AbstractLogger
  46175. {
  46176. public function log($level, $message, array $context = array())
  46177. {
  46178. }
  46179. }
  46180. <?php
  46181. namespace Psr\Log\Test;
  46182. class DummyTest
  46183. {
  46184. public function __toString()
  46185. {
  46186. return 'DummyTest';
  46187. }
  46188. }
  46189. <?php
  46190. namespace Psr\Log\Test;
  46191. use Psr\Log\LoggerInterface;
  46192. use Psr\Log\LogLevel;
  46193. use PHPUnit\Framework\TestCase;
  46194. abstract class LoggerInterfaceTest extends TestCase
  46195. {
  46196. abstract public function getLogger();
  46197. abstract public function getLogs();
  46198. public function testImplements()
  46199. {
  46200. $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger());
  46201. }
  46202. public function testLogsAtAllLevels($level, $message)
  46203. {
  46204. $logger = $this->getLogger();
  46205. $logger->{$level}($message, array('user' => 'Bob'));
  46206. $logger->log($level, $message, array('user' => 'Bob'));
  46207. $expected = array(
  46208. $level.' message of level '.$level.' with context: Bob',
  46209. $level.' message of level '.$level.' with context: Bob',
  46210. );
  46211. $this->assertEquals($expected, $this->getLogs());
  46212. }
  46213. public function provideLevelsAndMessages()
  46214. {
  46215. return array(
  46216. LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'),
  46217. LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'),
  46218. LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'),
  46219. LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'),
  46220. LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'),
  46221. LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'),
  46222. LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'),
  46223. LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'),
  46224. );
  46225. }
  46226. public function testThrowsOnInvalidLevel()
  46227. {
  46228. $logger = $this->getLogger();
  46229. $logger->log('invalid level', 'Foo');
  46230. }
  46231. public function testContextReplacement()
  46232. {
  46233. $logger = $this->getLogger();
  46234. $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar'));
  46235. $expected = array('info {Message {nothing} Bob Bar a}');
  46236. $this->assertEquals($expected, $this->getLogs());
  46237. }
  46238. public function testObjectCastToString()
  46239. {
  46240. if (method_exists($this, 'createPartialMock')) {
  46241. $dummy = $this->createPartialMock('Psr\Log\Test\DummyTest', array('__toString'));
  46242. } else {
  46243. $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString'));
  46244. }
  46245. $dummy->expects($this->once())
  46246. ->method('__toString')
  46247. ->will($this->returnValue('DUMMY'));
  46248. $this->getLogger()->warning($dummy);
  46249. $expected = array('warning DUMMY');
  46250. $this->assertEquals($expected, $this->getLogs());
  46251. }
  46252. public function testContextCanContainAnything()
  46253. {
  46254. $closed = fopen('php://memory', 'r');
  46255. fclose($closed);
  46256. $context = array(
  46257. 'bool' => true,
  46258. 'null' => null,
  46259. 'string' => 'Foo',
  46260. 'int' => 0,
  46261. 'float' => 0.5,
  46262. 'nested' => array('with object' => new DummyTest),
  46263. 'object' => new \DateTime,
  46264. 'resource' => fopen('php://memory', 'r'),
  46265. 'closed' => $closed,
  46266. );
  46267. $this->getLogger()->warning('Crazy context data', $context);
  46268. $expected = array('warning Crazy context data');
  46269. $this->assertEquals($expected, $this->getLogs());
  46270. }
  46271. public function testContextExceptionKeyCanBeExceptionOrOtherValues()
  46272. {
  46273. $logger = $this->getLogger();
  46274. $logger->warning('Random message', array('exception' => 'oops'));
  46275. $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail')));
  46276. $expected = array(
  46277. 'warning Random message',
  46278. 'critical Uncaught Exception!'
  46279. );
  46280. $this->assertEquals($expected, $this->getLogs());
  46281. }
  46282. }
  46283. <?php
  46284. namespace Psr\Log\Test;
  46285. use Psr\Log\AbstractLogger;
  46286. class TestLogger extends AbstractLogger
  46287. {
  46288. public $records = [];
  46289. public $recordsByLevel = [];
  46290. public function log($level, $message, array $context = [])
  46291. {
  46292. $record = [
  46293. 'level' => $level,
  46294. 'message' => $message,
  46295. 'context' => $context,
  46296. ];
  46297. $this->recordsByLevel[$record['level']][] = $record;
  46298. $this->records[] = $record;
  46299. }
  46300. public function hasRecords($level)
  46301. {
  46302. return isset($this->recordsByLevel[$level]);
  46303. }
  46304. public function hasRecord($record, $level)
  46305. {
  46306. if (is_string($record)) {
  46307. $record = ['message' => $record];
  46308. }
  46309. return $this->hasRecordThatPasses(function ($rec) use ($record) {
  46310. if ($rec['message'] !== $record['message']) {
  46311. return false;
  46312. }
  46313. if (isset($record['context']) && $rec['context'] !== $record['context']) {
  46314. return false;
  46315. }
  46316. return true;
  46317. }, $level);
  46318. }
  46319. public function hasRecordThatContains($message, $level)
  46320. {
  46321. return $this->hasRecordThatPasses(function ($rec) use ($message) {
  46322. return strpos($rec['message'], $message) !== false;
  46323. }, $level);
  46324. }
  46325. public function hasRecordThatMatches($regex, $level)
  46326. {
  46327. return $this->hasRecordThatPasses(function ($rec) use ($regex) {
  46328. return preg_match($regex, $rec['message']) > 0;
  46329. }, $level);
  46330. }
  46331. public function hasRecordThatPasses(callable $predicate, $level)
  46332. {
  46333. if (!isset($this->recordsByLevel[$level])) {
  46334. return false;
  46335. }
  46336. foreach ($this->recordsByLevel[$level] as $i => $rec) {
  46337. if (call_user_func($predicate, $rec, $i)) {
  46338. return true;
  46339. }
  46340. }
  46341. return false;
  46342. }
  46343. public function __call($method, $args)
  46344. {
  46345. if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) {
  46346. $genericMethod = $matches[1] . ('Records' !== $matches[3] ? 'Record' : '') . $matches[3];
  46347. $level = strtolower($matches[2]);
  46348. if (method_exists($this, $genericMethod)) {
  46349. $args[] = $level;
  46350. return call_user_func_array([$this, $genericMethod], $args);
  46351. }
  46352. }
  46353. throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()');
  46354. }
  46355. public function reset()
  46356. {
  46357. $this->records = [];
  46358. $this->recordsByLevel = [];
  46359. }
  46360. }
  46361. Copyright (c) 2012-2016 Jan Sorgalla
  46362. Permission is hereby granted, free of charge, to any person
  46363. obtaining a copy of this software and associated documentation
  46364. files (the "Software"), to deal in the Software without
  46365. restriction, including without limitation the rights to use,
  46366. copy, modify, merge, publish, distribute, sublicense, and/or sell
  46367. copies of the Software, and to permit persons to whom the
  46368. Software is furnished to do so, subject to the following
  46369. conditions:
  46370. The above copyright notice and this permission notice shall be
  46371. included in all copies or substantial portions of the Software.
  46372. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  46373. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  46374. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  46375. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  46376. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  46377. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  46378. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  46379. OTHER DEALINGS IN THE SOFTWARE.
  46380. <?php
  46381. namespace React\Promise;
  46382. interface CancellablePromiseInterface extends PromiseInterface
  46383. {
  46384. public function cancel();
  46385. }
  46386. <?php
  46387. namespace React\Promise;
  46388. class Deferred implements PromiseInterface, ResolverInterface, PromisorInterface, CancellablePromiseInterface
  46389. {
  46390. private $completed;
  46391. private $promise;
  46392. private $resolver;
  46393. private $handlers = array();
  46394. private $progressHandlers = array();
  46395. private $canceller;
  46396. private $requiredCancelRequests = 0;
  46397. private $cancelRequests = 0;
  46398. public function __construct($canceller = null)
  46399. {
  46400. if ($canceller !== null && !is_callable($canceller)) {
  46401. throw new \InvalidArgumentException(
  46402. sprintf(
  46403. 'The canceller argument must be null or of type callable, %s given.',
  46404. gettype($canceller)
  46405. )
  46406. );
  46407. }
  46408. $this->canceller = $canceller;
  46409. }
  46410. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46411. {
  46412. if (null !== $this->completed) {
  46413. return $this->completed->then($fulfilledHandler, $errorHandler, $progressHandler);
  46414. }
  46415. $canceller = null;
  46416. if ($this->canceller !== null) {
  46417. $this->requiredCancelRequests++;
  46418. $that = $this;
  46419. $current =& $this->cancelRequests;
  46420. $required =& $this->requiredCancelRequests;
  46421. $canceller = function () use ($that, &$current, &$required) {
  46422. if (++$current < $required) {
  46423. return;
  46424. }
  46425. $that->cancel();
  46426. };
  46427. }
  46428. $deferred = new static($canceller);
  46429. if (is_callable($progressHandler)) {
  46430. $progHandler = function ($update) use ($deferred, $progressHandler) {
  46431. try {
  46432. $deferred->progress(call_user_func($progressHandler, $update));
  46433. } catch (\Exception $e) {
  46434. $deferred->progress($e);
  46435. }
  46436. };
  46437. } else {
  46438. if (null !== $progressHandler) {
  46439. trigger_error('Invalid $progressHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46440. }
  46441. $progHandler = array($deferred, 'progress');
  46442. }
  46443. $this->handlers[] = function ($promise) use ($fulfilledHandler, $errorHandler, $deferred, $progHandler) {
  46444. $promise
  46445. ->then($fulfilledHandler, $errorHandler)
  46446. ->then(
  46447. array($deferred, 'resolve'),
  46448. array($deferred, 'reject'),
  46449. $progHandler
  46450. );
  46451. };
  46452. $this->progressHandlers[] = $progHandler;
  46453. return $deferred->promise();
  46454. }
  46455. public function resolve($result = null)
  46456. {
  46457. if (null !== $this->completed) {
  46458. return resolve($result);
  46459. }
  46460. $this->completed = resolve($result);
  46461. $this->processQueue($this->handlers, $this->completed);
  46462. $this->progressHandlers = $this->handlers = array();
  46463. return $this->completed;
  46464. }
  46465. public function reject($reason = null)
  46466. {
  46467. return $this->resolve(reject($reason));
  46468. }
  46469. public function progress($update = null)
  46470. {
  46471. if (null !== $this->completed) {
  46472. return;
  46473. }
  46474. $this->processQueue($this->progressHandlers, $update);
  46475. }
  46476. public function promise()
  46477. {
  46478. if (null === $this->promise) {
  46479. $this->promise = new DeferredPromise($this);
  46480. }
  46481. return $this->promise;
  46482. }
  46483. public function resolver()
  46484. {
  46485. if (null === $this->resolver) {
  46486. $this->resolver = new DeferredResolver($this);
  46487. }
  46488. return $this->resolver;
  46489. }
  46490. public function cancel()
  46491. {
  46492. if (null === $this->canceller || null !== $this->completed) {
  46493. return;
  46494. }
  46495. $canceller = $this->canceller;
  46496. $this->canceller = null;
  46497. try {
  46498. $that = $this;
  46499. call_user_func(
  46500. $canceller,
  46501. function ($value = null) use ($that) {
  46502. $that->resolve($value);
  46503. },
  46504. function ($reason = null) use ($that) {
  46505. $that->reject($reason);
  46506. },
  46507. function ($update = null) use ($that) {
  46508. $that->progress($update);
  46509. }
  46510. );
  46511. } catch (\Exception $e) {
  46512. $this->reject($e);
  46513. }
  46514. }
  46515. protected function processQueue($queue, $value)
  46516. {
  46517. foreach ($queue as $handler) {
  46518. call_user_func($handler, $value);
  46519. }
  46520. }
  46521. }
  46522. <?php
  46523. namespace React\Promise;
  46524. class DeferredPromise implements PromiseInterface, CancellablePromiseInterface
  46525. {
  46526. private $deferred;
  46527. public function __construct(Deferred $deferred)
  46528. {
  46529. $this->deferred = $deferred;
  46530. }
  46531. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46532. {
  46533. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  46534. }
  46535. public function cancel()
  46536. {
  46537. $this->deferred->cancel();
  46538. }
  46539. }
  46540. <?php
  46541. namespace React\Promise;
  46542. class DeferredResolver implements ResolverInterface
  46543. {
  46544. private $deferred;
  46545. public function __construct(Deferred $deferred)
  46546. {
  46547. $this->deferred = $deferred;
  46548. }
  46549. public function resolve($result = null)
  46550. {
  46551. return $this->deferred->resolve($result);
  46552. }
  46553. public function reject($reason = null)
  46554. {
  46555. return $this->deferred->reject($reason);
  46556. }
  46557. public function progress($update = null)
  46558. {
  46559. return $this->deferred->progress($update);
  46560. }
  46561. }
  46562. <?php
  46563. namespace React\Promise;
  46564. class FulfilledPromise implements PromiseInterface, CancellablePromiseInterface
  46565. {
  46566. private $result;
  46567. public function __construct($result = null)
  46568. {
  46569. $this->result = $result;
  46570. }
  46571. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46572. {
  46573. try {
  46574. $result = $this->result;
  46575. if (is_callable($fulfilledHandler)) {
  46576. $result = call_user_func($fulfilledHandler, $result);
  46577. } elseif (null !== $fulfilledHandler) {
  46578. trigger_error('Invalid $fulfilledHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46579. }
  46580. return resolve($result);
  46581. } catch (\Exception $exception) {
  46582. return new RejectedPromise($exception);
  46583. }
  46584. }
  46585. public function cancel()
  46586. {
  46587. }
  46588. }
  46589. <?php
  46590. namespace React\Promise;
  46591. class LazyPromise implements PromiseInterface, CancellablePromiseInterface
  46592. {
  46593. private $factory;
  46594. private $promise;
  46595. public function __construct($factory)
  46596. {
  46597. $this->factory = $factory;
  46598. }
  46599. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46600. {
  46601. return $this->promise()->then($fulfilledHandler, $errorHandler, $progressHandler);
  46602. }
  46603. public function cancel()
  46604. {
  46605. $promise = $this->promise();
  46606. if ($promise instanceof CancellablePromiseInterface) {
  46607. $promise->cancel();
  46608. }
  46609. }
  46610. private function promise()
  46611. {
  46612. if (null === $this->promise) {
  46613. try {
  46614. $this->promise = resolve(call_user_func($this->factory));
  46615. } catch (\Exception $exception) {
  46616. $this->promise = new RejectedPromise($exception);
  46617. }
  46618. }
  46619. return $this->promise;
  46620. }
  46621. }
  46622. <?php
  46623. namespace React\Promise;
  46624. class Promise implements PromiseInterface, CancellablePromiseInterface
  46625. {
  46626. private $deferred;
  46627. public function __construct($resolver, $canceller = null)
  46628. {
  46629. if (!is_callable($resolver)) {
  46630. throw new \InvalidArgumentException(
  46631. sprintf(
  46632. 'The resolver argument must be of type callable, %s given.',
  46633. gettype($resolver)
  46634. )
  46635. );
  46636. }
  46637. $this->deferred = new Deferred($canceller);
  46638. $this->call($resolver);
  46639. }
  46640. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46641. {
  46642. return $this->deferred->then($fulfilledHandler, $errorHandler, $progressHandler);
  46643. }
  46644. public function cancel()
  46645. {
  46646. $this->deferred->cancel();
  46647. }
  46648. private function call($callback)
  46649. {
  46650. $deferred = $this->deferred;
  46651. try {
  46652. call_user_func(
  46653. $callback,
  46654. function ($result = null) use ($deferred) {
  46655. $deferred->resolve($result);
  46656. },
  46657. function ($reason = null) use ($deferred) {
  46658. $deferred->reject($reason);
  46659. },
  46660. function ($update = null) use ($deferred) {
  46661. $deferred->progress($update);
  46662. }
  46663. );
  46664. } catch (\Exception $e) {
  46665. $this->deferred->reject($e);
  46666. }
  46667. }
  46668. }
  46669. <?php
  46670. namespace React\Promise;
  46671. interface PromiseInterface
  46672. {
  46673. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null);
  46674. }
  46675. <?php
  46676. namespace React\Promise;
  46677. interface PromisorInterface
  46678. {
  46679. public function promise();
  46680. }
  46681. <?php
  46682. namespace React\Promise;
  46683. class RejectedPromise implements PromiseInterface, CancellablePromiseInterface
  46684. {
  46685. private $reason;
  46686. public function __construct($reason = null)
  46687. {
  46688. $this->reason = $reason;
  46689. }
  46690. public function then($fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46691. {
  46692. try {
  46693. if (!is_callable($errorHandler)) {
  46694. if (null !== $errorHandler) {
  46695. trigger_error('Invalid $errorHandler argument passed to then(), must be null or callable.', E_USER_NOTICE);
  46696. }
  46697. return new RejectedPromise($this->reason);
  46698. }
  46699. return resolve(call_user_func($errorHandler, $this->reason));
  46700. } catch (\Exception $exception) {
  46701. return new RejectedPromise($exception);
  46702. }
  46703. }
  46704. public function cancel()
  46705. {
  46706. }
  46707. }
  46708. <?php
  46709. namespace React\Promise;
  46710. interface ResolverInterface
  46711. {
  46712. public function resolve($result = null);
  46713. public function reject($reason = null);
  46714. public function progress($update = null);
  46715. }
  46716. <?php
  46717. namespace React\Promise;
  46718. class Util
  46719. {
  46720. public static function promiseFor($promiseOrValue)
  46721. {
  46722. return resolve($promiseOrValue);
  46723. }
  46724. public static function rejectedPromiseFor($promiseOrValue)
  46725. {
  46726. return reject($promiseOrValue);
  46727. }
  46728. }
  46729. <?php
  46730. namespace React\Promise;
  46731. class When
  46732. {
  46733. public static function resolve($promiseOrValue = null)
  46734. {
  46735. return resolve($promiseOrValue);
  46736. }
  46737. public static function reject($promiseOrValue = null)
  46738. {
  46739. return reject($promiseOrValue);
  46740. }
  46741. public static function lazy($factory)
  46742. {
  46743. return new LazyPromise($factory);
  46744. }
  46745. public static function all($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46746. {
  46747. return all($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  46748. }
  46749. public static function any($promisesOrValues, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46750. {
  46751. return any($promisesOrValues)->then($fulfilledHandler, $errorHandler, $progressHandler);
  46752. }
  46753. public static function some($promisesOrValues, $howMany, $fulfilledHandler = null, $errorHandler = null, $progressHandler = null)
  46754. {
  46755. return some($promisesOrValues, $howMany)->then($fulfilledHandler, $errorHandler, $progressHandler);
  46756. }
  46757. public static function map($promisesOrValues, $mapFunc)
  46758. {
  46759. return map($promisesOrValues, $mapFunc);
  46760. }
  46761. public static function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  46762. {
  46763. return reduce($promisesOrValues, $reduceFunc, $initialValue);
  46764. }
  46765. }
  46766. <?php
  46767. namespace React\Promise;
  46768. function resolve($promiseOrValue = null)
  46769. {
  46770. if ($promiseOrValue instanceof PromiseInterface) {
  46771. return $promiseOrValue;
  46772. }
  46773. return new FulfilledPromise($promiseOrValue);
  46774. }
  46775. function reject($promiseOrValue = null)
  46776. {
  46777. if ($promiseOrValue instanceof PromiseInterface) {
  46778. return $promiseOrValue->then(function ($value) {
  46779. return new RejectedPromise($value);
  46780. });
  46781. }
  46782. return new RejectedPromise($promiseOrValue);
  46783. }
  46784. function all($promisesOrValues)
  46785. {
  46786. return map($promisesOrValues, function ($val) {
  46787. return $val;
  46788. });
  46789. }
  46790. function any($promisesOrValues)
  46791. {
  46792. return some($promisesOrValues, 1)->then(function($val) {
  46793. return array_shift($val);
  46794. });
  46795. }
  46796. function some($promisesOrValues, $howMany)
  46797. {
  46798. return resolve($promisesOrValues)->then(function ($array) use ($howMany) {
  46799. if (!is_array($array)) {
  46800. $array = array();
  46801. }
  46802. $len = count($array);
  46803. $toResolve = max(0, min($howMany, $len));
  46804. $values = array();
  46805. $deferred = new Deferred();
  46806. if (!$toResolve) {
  46807. $deferred->resolve($values);
  46808. } else {
  46809. $toReject = ($len - $toResolve) + 1;
  46810. $reasons = array();
  46811. $progress = array($deferred, 'progress');
  46812. $fulfillOne = function ($val, $i) use (&$values, &$toResolve, $deferred) {
  46813. $values[$i] = $val;
  46814. if (0 === --$toResolve) {
  46815. $deferred->resolve($values);
  46816. return true;
  46817. }
  46818. };
  46819. $rejectOne = function ($reason, $i) use (&$reasons, &$toReject, $deferred) {
  46820. $reasons[$i] = $reason;
  46821. if (0 === --$toReject) {
  46822. $deferred->reject($reasons);
  46823. return true;
  46824. }
  46825. };
  46826. foreach ($array as $i => $promiseOrValue) {
  46827. $fulfiller = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  46828. $reset = $fulfillOne($val, $i);
  46829. if (true === $reset) {
  46830. $fulfillOne = $rejectOne = function () {};
  46831. }
  46832. };
  46833. $rejecter = function ($val) use ($i, &$fulfillOne, &$rejectOne) {
  46834. $reset = $rejectOne($val, $i);
  46835. if (true === $reset) {
  46836. $fulfillOne = $rejectOne = function () {};
  46837. }
  46838. };
  46839. resolve($promiseOrValue)->then($fulfiller, $rejecter, $progress);
  46840. }
  46841. }
  46842. return $deferred->promise();
  46843. });
  46844. }
  46845. function map($promisesOrValues, $mapFunc)
  46846. {
  46847. return resolve($promisesOrValues)->then(function ($array) use ($mapFunc) {
  46848. if (!is_array($array)) {
  46849. $array = array();
  46850. }
  46851. $toResolve = count($array);
  46852. $results = array();
  46853. $deferred = new Deferred();
  46854. if (!$toResolve) {
  46855. $deferred->resolve($results);
  46856. } else {
  46857. $resolve = function ($item, $i) use ($mapFunc, &$results, &$toResolve, $deferred) {
  46858. resolve($item)
  46859. ->then($mapFunc)
  46860. ->then(
  46861. function ($mapped) use (&$results, $i, &$toResolve, $deferred) {
  46862. $results[$i] = $mapped;
  46863. if (0 === --$toResolve) {
  46864. $deferred->resolve($results);
  46865. }
  46866. },
  46867. array($deferred, 'reject')
  46868. );
  46869. };
  46870. foreach ($array as $i => $item) {
  46871. $resolve($item, $i);
  46872. }
  46873. }
  46874. return $deferred->promise();
  46875. });
  46876. }
  46877. function reduce($promisesOrValues, $reduceFunc , $initialValue = null)
  46878. {
  46879. return resolve($promisesOrValues)->then(function ($array) use ($reduceFunc, $initialValue) {
  46880. if (!is_array($array)) {
  46881. $array = array();
  46882. }
  46883. $total = count($array);
  46884. $i = 0;
  46885. $wrappedReduceFunc = function ($current, $val) use ($reduceFunc, $total, &$i) {
  46886. return resolve($current)->then(function ($c) use ($reduceFunc, $total, &$i, $val) {
  46887. return resolve($val)->then(function ($value) use ($reduceFunc, $total, &$i, $c) {
  46888. return call_user_func($reduceFunc, $c, $value, $i++, $total);
  46889. });
  46890. });
  46891. };
  46892. return array_reduce($array, $wrappedReduceFunc, $initialValue);
  46893. });
  46894. }
  46895. <?php
  46896. if (!function_exists('React\Promise\resolve')) {
  46897. require __DIR__.'/functions.php';
  46898. }
  46899. Copyright (c) 2011 Jordi Boggiano
  46900. Permission is hereby granted, free of charge, to any person obtaining a copy
  46901. of this software and associated documentation files (the "Software"), to deal
  46902. in the Software without restriction, including without limitation the rights
  46903. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  46904. copies of the Software, and to permit persons to whom the Software is furnished
  46905. to do so, subject to the following conditions:
  46906. The above copyright notice and this permission notice shall be included in all
  46907. copies or substantial portions of the Software.
  46908. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  46909. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46910. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  46911. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  46912. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  46913. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  46914. THE SOFTWARE.
  46915. <?php
  46916. namespace Seld\JsonLint;
  46917. class DuplicateKeyException extends ParsingException
  46918. {
  46919. public function __construct($message, $key, array $details = array())
  46920. {
  46921. $details['key'] = $key;
  46922. parent::__construct($message, $details);
  46923. }
  46924. public function getKey()
  46925. {
  46926. return $this->details['key'];
  46927. }
  46928. public function getDetails()
  46929. {
  46930. return $this->details;
  46931. }
  46932. }
  46933. <?php
  46934. namespace Seld\JsonLint;
  46935. use stdClass;
  46936. class JsonParser
  46937. {
  46938. const DETECT_KEY_CONFLICTS = 1;
  46939. const ALLOW_DUPLICATE_KEYS = 2;
  46940. const PARSE_TO_ASSOC = 4;
  46941. private $lexer;
  46942. private $flags;
  46943. private $stack;
  46944. private $vstack;
  46945. private $lstack;
  46946. private $symbols = array(
  46947. 'error' => 2,
  46948. 'JSONString' => 3,
  46949. 'STRING' => 4,
  46950. 'JSONNumber' => 5,
  46951. 'NUMBER' => 6,
  46952. 'JSONNullLiteral' => 7,
  46953. 'NULL' => 8,
  46954. 'JSONBooleanLiteral' => 9,
  46955. 'TRUE' => 10,
  46956. 'FALSE' => 11,
  46957. 'JSONText' => 12,
  46958. 'JSONValue' => 13,
  46959. 'EOF' => 14,
  46960. 'JSONObject' => 15,
  46961. 'JSONArray' => 16,
  46962. '{' => 17,
  46963. '}' => 18,
  46964. 'JSONMemberList' => 19,
  46965. 'JSONMember' => 20,
  46966. ':' => 21,
  46967. ',' => 22,
  46968. '[' => 23,
  46969. ']' => 24,
  46970. 'JSONElementList' => 25,
  46971. '$accept' => 0,
  46972. '$end' => 1,
  46973. );
  46974. private $terminals_ = array(
  46975. 2 => "error",
  46976. 4 => "STRING",
  46977. 6 => "NUMBER",
  46978. 8 => "NULL",
  46979. 10 => "TRUE",
  46980. 11 => "FALSE",
  46981. 14 => "EOF",
  46982. 17 => "{",
  46983. 18 => "}",
  46984. 21 => ":",
  46985. 22 => ",",
  46986. 23 => "[",
  46987. 24 => "]",
  46988. );
  46989. private $productions_ = array(
  46990. 0,
  46991. array(3, 1),
  46992. array(5, 1),
  46993. array(7, 1),
  46994. array(9, 1),
  46995. array(9, 1),
  46996. array(12, 2),
  46997. array(13, 1),
  46998. array(13, 1),
  46999. array(13, 1),
  47000. array(13, 1),
  47001. array(13, 1),
  47002. array(13, 1),
  47003. array(15, 2),
  47004. array(15, 3),
  47005. array(20, 3),
  47006. array(19, 1),
  47007. array(19, 3),
  47008. array(16, 2),
  47009. array(16, 3),
  47010. array(25, 1),
  47011. array(25, 3)
  47012. );
  47013. 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)),
  47014. );
  47015. private $defaultActions = array(
  47016. 16 => array(2, 6)
  47017. );
  47018. public function lint($input, $flags = 0)
  47019. {
  47020. try {
  47021. $this->parse($input, $flags);
  47022. } catch (ParsingException $e) {
  47023. return $e;
  47024. }
  47025. return null;
  47026. }
  47027. public function parse($input, $flags = 0)
  47028. {
  47029. $this->failOnBOM($input);
  47030. $this->flags = $flags;
  47031. $this->stack = array(0);
  47032. $this->vstack = array(null);
  47033. $this->lstack = array();
  47034. $yytext = '';
  47035. $yylineno = 0;
  47036. $yyleng = 0;
  47037. $recovering = 0;
  47038. $TERROR = 2;
  47039. $EOF = 1;
  47040. $this->lexer = new Lexer();
  47041. $this->lexer->setInput($input);
  47042. $yyloc = $this->lexer->yylloc;
  47043. $this->lstack[] = $yyloc;
  47044. $symbol = null;
  47045. $preErrorSymbol = null;
  47046. $state = null;
  47047. $action = null;
  47048. $a = null;
  47049. $r = null;
  47050. $yyval = new stdClass;
  47051. $p = null;
  47052. $len = null;
  47053. $newState = null;
  47054. $expected = null;
  47055. $errStr = null;
  47056. while (true) {
  47057. $state = $this->stack[\count($this->stack)-1];
  47058. if (isset($this->defaultActions[$state])) {
  47059. $action = $this->defaultActions[$state];
  47060. } else {
  47061. if ($symbol == null) {
  47062. $symbol = $this->lex();
  47063. }
  47064. $action = isset($this->table[$state][$symbol]) ? $this->table[$state][$symbol] : false;
  47065. }
  47066. if (!$action || !$action[0]) {
  47067. if (!$recovering) {
  47068. $expected = array();
  47069. foreach ($this->table[$state] as $p => $ignore) {
  47070. if (isset($this->terminals_[$p]) && $p > 2) {
  47071. $expected[] = "'" . $this->terminals_[$p] . "'";
  47072. }
  47073. }
  47074. $message = null;
  47075. if (\in_array("'STRING'", $expected) && \in_array(substr($this->lexer->match, 0, 1), array('"', "'"))) {
  47076. $message = "Invalid string";
  47077. if ("'" === substr($this->lexer->match, 0, 1)) {
  47078. $message .= ", it appears you used single quotes instead of double quotes";
  47079. } elseif (preg_match('{".+?(\\\\[^"bfnrt/\\\\u](...)?)}', $this->lexer->getFullUpcomingInput(), $match)) {
  47080. $message .= ", it appears you have an unescaped backslash at: ".$match[1];
  47081. } elseif (preg_match('{"(?:[^"]+|\\\\")*$}m', $this->lexer->getFullUpcomingInput())) {
  47082. $message .= ", it appears you forgot to terminate a string, or attempted to write a multiline string which is invalid";
  47083. }
  47084. }
  47085. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  47086. $errStr .= $this->lexer->showPosition() . "\n";
  47087. if ($message) {
  47088. $errStr .= $message;
  47089. } else {
  47090. $errStr .= (\count($expected) > 1) ? "Expected one of: " : "Expected: ";
  47091. $errStr .= implode(', ', $expected);
  47092. }
  47093. if (',' === substr(trim($this->lexer->getPastInput()), -1)) {
  47094. $errStr .= " - It appears you have an extra trailing comma";
  47095. }
  47096. $this->parseError($errStr, array(
  47097. 'text' => $this->lexer->match,
  47098. 'token' => !empty($this->terminals_[$symbol]) ? $this->terminals_[$symbol] : $symbol,
  47099. 'line' => $this->lexer->yylineno,
  47100. 'loc' => $yyloc,
  47101. 'expected' => $expected,
  47102. ));
  47103. }
  47104. if ($recovering == 3) {
  47105. if ($symbol == $EOF) {
  47106. throw new ParsingException($errStr ?: 'Parsing halted.');
  47107. }
  47108. $yyleng = $this->lexer->yyleng;
  47109. $yytext = $this->lexer->yytext;
  47110. $yylineno = $this->lexer->yylineno;
  47111. $yyloc = $this->lexer->yylloc;
  47112. $symbol = $this->lex();
  47113. }
  47114. while (true) {
  47115. if (\array_key_exists($TERROR, $this->table[$state])) {
  47116. break;
  47117. }
  47118. if ($state == 0) {
  47119. throw new ParsingException($errStr ?: 'Parsing halted.');
  47120. }
  47121. $this->popStack(1);
  47122. $state = $this->stack[\count($this->stack)-1];
  47123. }
  47124. $preErrorSymbol = $symbol;
  47125. $symbol = $TERROR;
  47126. $state = $this->stack[\count($this->stack)-1];
  47127. $action = isset($this->table[$state][$TERROR]) ? $this->table[$state][$TERROR] : false;
  47128. $recovering = 3;
  47129. }
  47130. if (\is_array($action[0]) && \count($action) > 1) {
  47131. throw new ParsingException('Parse Error: multiple actions possible at state: ' . $state . ', token: ' . $symbol);
  47132. }
  47133. switch ($action[0]) {
  47134. case 1:
  47135. $this->stack[] = $symbol;
  47136. $this->vstack[] = $this->lexer->yytext;
  47137. $this->lstack[] = $this->lexer->yylloc;
  47138. $this->stack[] = $action[1];
  47139. $symbol = null;
  47140. if (!$preErrorSymbol) {
  47141. $yyleng = $this->lexer->yyleng;
  47142. $yytext = $this->lexer->yytext;
  47143. $yylineno = $this->lexer->yylineno;
  47144. $yyloc = $this->lexer->yylloc;
  47145. if ($recovering > 0) {
  47146. $recovering--;
  47147. }
  47148. } else {
  47149. $symbol = $preErrorSymbol;
  47150. $preErrorSymbol = null;
  47151. }
  47152. break;
  47153. case 2:
  47154. $len = $this->productions_[$action[1]][1];
  47155. $yyval->token = $this->vstack[\count($this->vstack) - $len];
  47156. $yyval->store = array(
  47157. 'first_line' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_line'],
  47158. 'last_line' => $this->lstack[\count($this->lstack) - 1]['last_line'],
  47159. 'first_column' => $this->lstack[\count($this->lstack) - ($len ?: 1)]['first_column'],
  47160. 'last_column' => $this->lstack[\count($this->lstack) - 1]['last_column'],
  47161. );
  47162. $r = $this->performAction($yyval, $yytext, $yyleng, $yylineno, $action[1], $this->vstack);
  47163. if (!$r instanceof Undefined) {
  47164. return $r;
  47165. }
  47166. if ($len) {
  47167. $this->popStack($len);
  47168. }
  47169. $this->stack[] = $this->productions_[$action[1]][0];
  47170. $this->vstack[] = $yyval->token;
  47171. $this->lstack[] = $yyval->store;
  47172. $newState = $this->table[$this->stack[\count($this->stack)-2]][$this->stack[\count($this->stack)-1]];
  47173. $this->stack[] = $newState;
  47174. break;
  47175. case 3:
  47176. return true;
  47177. }
  47178. }
  47179. }
  47180. protected function parseError($str, $hash)
  47181. {
  47182. throw new ParsingException($str, $hash);
  47183. }
  47184. private function performAction(stdClass $yyval, $yytext, $yyleng, $yylineno, $yystate, &$tokens)
  47185. {
  47186. $len = \count($tokens) - 1;
  47187. switch ($yystate) {
  47188. case 1:
  47189. $yytext = preg_replace_callback('{(?:\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4})}', array($this, 'stringInterpolation'), $yytext);
  47190. $yyval->token = $yytext;
  47191. break;
  47192. case 2:
  47193. if (strpos($yytext, 'e') !== false || strpos($yytext, 'E') !== false) {
  47194. $yyval->token = \floatval($yytext);
  47195. } else {
  47196. $yyval->token = strpos($yytext, '.') === false ? \intval($yytext) : \floatval($yytext);
  47197. }
  47198. break;
  47199. case 3:
  47200. $yyval->token = null;
  47201. break;
  47202. case 4:
  47203. $yyval->token = true;
  47204. break;
  47205. case 5:
  47206. $yyval->token = false;
  47207. break;
  47208. case 6:
  47209. return $yyval->token = $tokens[$len-1];
  47210. case 13:
  47211. if ($this->flags & self::PARSE_TO_ASSOC) {
  47212. $yyval->token = array();
  47213. } else {
  47214. $yyval->token = new stdClass;
  47215. }
  47216. break;
  47217. case 14:
  47218. $yyval->token = $tokens[$len-1];
  47219. break;
  47220. case 15:
  47221. $yyval->token = array($tokens[$len-2], $tokens[$len]);
  47222. break;
  47223. case 16:
  47224. if (PHP_VERSION_ID < 70100) {
  47225. $property = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  47226. } else {
  47227. $property = $tokens[$len][0];
  47228. }
  47229. if ($this->flags & self::PARSE_TO_ASSOC) {
  47230. $yyval->token = array();
  47231. $yyval->token[$property] = $tokens[$len][1];
  47232. } else {
  47233. $yyval->token = new stdClass;
  47234. $yyval->token->$property = $tokens[$len][1];
  47235. }
  47236. break;
  47237. case 17:
  47238. if ($this->flags & self::PARSE_TO_ASSOC) {
  47239. $yyval->token =& $tokens[$len-2];
  47240. $key = $tokens[$len][0];
  47241. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2][$key])) {
  47242. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  47243. $errStr .= $this->lexer->showPosition() . "\n";
  47244. $errStr .= "Duplicate key: ".$tokens[$len][0];
  47245. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  47246. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2][$key])) {
  47247. $duplicateCount = 1;
  47248. do {
  47249. $duplicateKey = $key . '.' . $duplicateCount++;
  47250. } while (isset($tokens[$len-2][$duplicateKey]));
  47251. $key = $duplicateKey;
  47252. }
  47253. $tokens[$len-2][$key] = $tokens[$len][1];
  47254. } else {
  47255. $yyval->token = $tokens[$len-2];
  47256. if (PHP_VERSION_ID < 70100) {
  47257. $key = $tokens[$len][0] === '' ? '_empty_' : $tokens[$len][0];
  47258. } else {
  47259. $key = $tokens[$len][0];
  47260. }
  47261. if (($this->flags & self::DETECT_KEY_CONFLICTS) && isset($tokens[$len-2]->{$key})) {
  47262. $errStr = 'Parse error on line ' . ($yylineno+1) . ":\n";
  47263. $errStr .= $this->lexer->showPosition() . "\n";
  47264. $errStr .= "Duplicate key: ".$tokens[$len][0];
  47265. throw new DuplicateKeyException($errStr, $tokens[$len][0], array('line' => $yylineno+1));
  47266. } elseif (($this->flags & self::ALLOW_DUPLICATE_KEYS) && isset($tokens[$len-2]->{$key})) {
  47267. $duplicateCount = 1;
  47268. do {
  47269. $duplicateKey = $key . '.' . $duplicateCount++;
  47270. } while (isset($tokens[$len-2]->$duplicateKey));
  47271. $key = $duplicateKey;
  47272. }
  47273. $tokens[$len-2]->$key = $tokens[$len][1];
  47274. }
  47275. break;
  47276. case 18:
  47277. $yyval->token = array();
  47278. break;
  47279. case 19:
  47280. $yyval->token = $tokens[$len-1];
  47281. break;
  47282. case 20:
  47283. $yyval->token = array($tokens[$len]);
  47284. break;
  47285. case 21:
  47286. $tokens[$len-2][] = $tokens[$len];
  47287. $yyval->token = $tokens[$len-2];
  47288. break;
  47289. }
  47290. return new Undefined();
  47291. }
  47292. private function stringInterpolation($match)
  47293. {
  47294. switch ($match[0]) {
  47295. case '\\\\':
  47296. return '\\';
  47297. case '\"':
  47298. return '"';
  47299. case '\b':
  47300. return \chr(8);
  47301. case '\f':
  47302. return \chr(12);
  47303. case '\n':
  47304. return "\n";
  47305. case '\r':
  47306. return "\r";
  47307. case '\t':
  47308. return "\t";
  47309. case '\/':
  47310. return "/";
  47311. default:
  47312. return html_entity_decode('&#x'.ltrim(substr($match[0], 2), '0').';', ENT_QUOTES, 'UTF-8');
  47313. }
  47314. }
  47315. private function popStack($n)
  47316. {
  47317. $this->stack = \array_slice($this->stack, 0, - (2 * $n));
  47318. $this->vstack = \array_slice($this->vstack, 0, - $n);
  47319. $this->lstack = \array_slice($this->lstack, 0, - $n);
  47320. }
  47321. private function lex()
  47322. {
  47323. $token = $this->lexer->lex() ?: 1;
  47324. if (!is_numeric($token)) {
  47325. $token = isset($this->symbols[$token]) ? $this->symbols[$token] : $token;
  47326. }
  47327. return $token;
  47328. }
  47329. private function failOnBOM($input)
  47330. {
  47331. $bom = "\xEF\xBB\xBF";
  47332. if (substr($input, 0, 3) === $bom) {
  47333. $this->parseError("BOM detected, make sure your input does not include a Unicode Byte-Order-Mark", array());
  47334. }
  47335. }
  47336. }
  47337. <?php
  47338. namespace Seld\JsonLint;
  47339. class Lexer
  47340. {
  47341. private $EOF = 1;
  47342. private $rules = array(
  47343. 0 => '/\G\s+/',
  47344. 1 => '/\G-?([0-9]|[1-9][0-9]+)(\.[0-9]+)?([eE][+-]?[0-9]+)?\b/',
  47345. 2 => '{\G"(?>\\\\["bfnrt/\\\\]|\\\\u[a-fA-F0-9]{4}|[^\0-\x1f\\\\"]++)*+"}',
  47346. 3 => '/\G\{/',
  47347. 4 => '/\G\}/',
  47348. 5 => '/\G\[/',
  47349. 6 => '/\G\]/',
  47350. 7 => '/\G,/',
  47351. 8 => '/\G:/',
  47352. 9 => '/\Gtrue\b/',
  47353. 10 => '/\Gfalse\b/',
  47354. 11 => '/\Gnull\b/',
  47355. 12 => '/\G$/',
  47356. 13 => '/\G./',
  47357. );
  47358. private $conditions = array(
  47359. "INITIAL" => array(
  47360. "rules" => array(0,1,2,3,4,5,6,7,8,9,10,11,12,13),
  47361. "inclusive" => true,
  47362. ),
  47363. );
  47364. private $conditionStack;
  47365. private $input;
  47366. private $more;
  47367. private $done;
  47368. private $offset;
  47369. public $match;
  47370. public $yylineno;
  47371. public $yyleng;
  47372. public $yytext;
  47373. public $yylloc;
  47374. public function lex()
  47375. {
  47376. $r = $this->next();
  47377. if (!$r instanceof Undefined) {
  47378. return $r;
  47379. }
  47380. return $this->lex();
  47381. }
  47382. public function setInput($input)
  47383. {
  47384. $this->input = $input;
  47385. $this->more = false;
  47386. $this->done = false;
  47387. $this->offset = 0;
  47388. $this->yylineno = $this->yyleng = 0;
  47389. $this->yytext = $this->match = '';
  47390. $this->conditionStack = array('INITIAL');
  47391. $this->yylloc = array('first_line' => 1, 'first_column' => 0, 'last_line' => 1, 'last_column' => 0);
  47392. return $this;
  47393. }
  47394. public function showPosition()
  47395. {
  47396. $pre = str_replace("\n", '', $this->getPastInput());
  47397. $c = str_repeat('-', max(0, \strlen($pre) - 1));
  47398. return $pre . str_replace("\n", '', $this->getUpcomingInput()) . "\n" . $c . "^";
  47399. }
  47400. public function getPastInput()
  47401. {
  47402. $pastLength = $this->offset - \strlen($this->match);
  47403. return ($pastLength > 20 ? '...' : '') . substr($this->input, max(0, $pastLength - 20), min(20, $pastLength));
  47404. }
  47405. public function getUpcomingInput()
  47406. {
  47407. $next = $this->match;
  47408. if (\strlen($next) < 20) {
  47409. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  47410. }
  47411. return substr($next, 0, 20) . (\strlen($next) > 20 ? '...' : '');
  47412. }
  47413. public function getFullUpcomingInput()
  47414. {
  47415. $next = $this->match;
  47416. if (substr($next, 0, 1) === '"' && substr_count($next, '"') === 1) {
  47417. $len = \strlen($this->input);
  47418. $strEnd = min(strpos($this->input, '"', $this->offset + 1) ?: $len, strpos($this->input, "\n", $this->offset + 1) ?: $len);
  47419. $next .= substr($this->input, $this->offset, $strEnd - $this->offset);
  47420. } elseif (\strlen($next) < 20) {
  47421. $next .= substr($this->input, $this->offset, 20 - \strlen($next));
  47422. }
  47423. return $next;
  47424. }
  47425. protected function parseError($str, $hash)
  47426. {
  47427. throw new \Exception($str);
  47428. }
  47429. private function next()
  47430. {
  47431. if ($this->done) {
  47432. return $this->EOF;
  47433. }
  47434. if ($this->offset === \strlen($this->input)) {
  47435. $this->done = true;
  47436. }
  47437. $token = null;
  47438. $match = null;
  47439. $col = null;
  47440. $lines = null;
  47441. if (!$this->more) {
  47442. $this->yytext = '';
  47443. $this->match = '';
  47444. }
  47445. $rules = $this->getCurrentRules();
  47446. $rulesLen = \count($rules);
  47447. for ($i=0; $i < $rulesLen; $i++) {
  47448. if (preg_match($this->rules[$rules[$i]], $this->input, $match, 0, $this->offset)) {
  47449. preg_match_all('/\n.*/', $match[0], $lines);
  47450. $lines = $lines[0];
  47451. if ($lines) {
  47452. $this->yylineno += \count($lines);
  47453. }
  47454. $this->yylloc = array(
  47455. 'first_line' => $this->yylloc['last_line'],
  47456. 'last_line' => $this->yylineno+1,
  47457. 'first_column' => $this->yylloc['last_column'],
  47458. 'last_column' => $lines ? \strlen($lines[\count($lines) - 1]) - 1 : $this->yylloc['last_column'] + \strlen($match[0]),
  47459. );
  47460. $this->yytext .= $match[0];
  47461. $this->match .= $match[0];
  47462. $this->yyleng = \strlen($this->yytext);
  47463. $this->more = false;
  47464. $this->offset += \strlen($match[0]);
  47465. $token = $this->performAction($rules[$i], $this->conditionStack[\count($this->conditionStack)-1]);
  47466. if ($token) {
  47467. return $token;
  47468. }
  47469. return new Undefined();
  47470. }
  47471. }
  47472. if ($this->offset === \strlen($this->input)) {
  47473. return $this->EOF;
  47474. }
  47475. $this->parseError(
  47476. 'Lexical error on line ' . ($this->yylineno+1) . ". Unrecognized text.\n" . $this->showPosition(),
  47477. array(
  47478. 'text' => "",
  47479. 'token' => null,
  47480. 'line' => $this->yylineno,
  47481. )
  47482. );
  47483. }
  47484. private function getCurrentRules()
  47485. {
  47486. return $this->conditions[$this->conditionStack[\count($this->conditionStack)-1]]['rules'];
  47487. }
  47488. private function performAction($avoiding_name_collisions, $YY_START)
  47489. {
  47490. switch ($avoiding_name_collisions) {
  47491. case 0:
  47492. break;
  47493. case 1:
  47494. return 6;
  47495. case 2:
  47496. $this->yytext = substr($this->yytext, 1, $this->yyleng-2);
  47497. return 4;
  47498. case 3:
  47499. return 17;
  47500. case 4:
  47501. return 18;
  47502. case 5:
  47503. return 23;
  47504. case 6:
  47505. return 24;
  47506. case 7:
  47507. return 22;
  47508. case 8:
  47509. return 21;
  47510. case 9:
  47511. return 10;
  47512. case 10:
  47513. return 11;
  47514. case 11:
  47515. return 8;
  47516. case 12:
  47517. return 14;
  47518. case 13:
  47519. return 'INVALID';
  47520. }
  47521. }
  47522. }
  47523. <?php
  47524. namespace Seld\JsonLint;
  47525. class ParsingException extends \Exception
  47526. {
  47527. protected $details;
  47528. public function __construct($message, $details = array())
  47529. {
  47530. $this->details = $details;
  47531. parent::__construct($message);
  47532. }
  47533. public function getDetails()
  47534. {
  47535. return $this->details;
  47536. }
  47537. }
  47538. <?php
  47539. namespace Seld\JsonLint;
  47540. class Undefined
  47541. {
  47542. }
  47543. Copyright (c) 2015 Jordi Boggiano
  47544. Permission is hereby granted, free of charge, to any person obtaining a copy
  47545. of this software and associated documentation files (the "Software"), to deal
  47546. in the Software without restriction, including without limitation the rights
  47547. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  47548. copies of the Software, and to permit persons to whom the Software is furnished
  47549. to do so, subject to the following conditions:
  47550. The above copyright notice and this permission notice shall be included in all
  47551. copies or substantial portions of the Software.
  47552. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47553. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  47554. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47555. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  47556. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  47557. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  47558. THE SOFTWARE.
  47559. <?php
  47560. namespace Seld\PharUtils;
  47561. class Linter
  47562. {
  47563. public static function lint($path)
  47564. {
  47565. $php = defined('PHP_BINARY') ? PHP_BINARY : 'php';
  47566. if ($isWindows = defined('PHP_WINDOWS_VERSION_BUILD')) {
  47567. $tmpFile = @tempnam(sys_get_temp_dir(), '');
  47568. if (!$tmpFile || !is_writable($tmpFile)) {
  47569. throw new \RuntimeException('Unable to create temp file');
  47570. }
  47571. $php = self::escapeWindowsPath($php);
  47572. $tmpFile = self::escapeWindowsPath($tmpFile);
  47573. if (PHP_VERSION_ID >= 80000) {
  47574. $format = '%s -l %s';
  47575. } else {
  47576. $format = '"%s -l %s"';
  47577. }
  47578. $command = sprintf($format, $php, $tmpFile);
  47579. } else {
  47580. $command = "'".$php."' -l";
  47581. }
  47582. $descriptorspec = array(
  47583. 0 => array('pipe', 'r'),
  47584. 1 => array('pipe', 'w'),
  47585. 2 => array('pipe', 'w')
  47586. );
  47587. foreach (new \RecursiveIteratorIterator(new \Phar($path)) as $file) {
  47588. if ($file->isDir()) {
  47589. continue;
  47590. }
  47591. if (substr($file, -4) === '.php') {
  47592. $filename = (string) $file;
  47593. if ($isWindows) {
  47594. file_put_contents($tmpFile, file_get_contents($filename));
  47595. }
  47596. $process = proc_open($command, $descriptorspec, $pipes);
  47597. if (is_resource($process)) {
  47598. if (!$isWindows) {
  47599. fwrite($pipes[0], file_get_contents($filename));
  47600. }
  47601. fclose($pipes[0]);
  47602. $stdout = stream_get_contents($pipes[1]);
  47603. fclose($pipes[1]);
  47604. $stderr = stream_get_contents($pipes[2]);
  47605. fclose($pipes[2]);
  47606. $exitCode = proc_close($process);
  47607. if ($exitCode !== 0) {
  47608. if ($isWindows) {
  47609. $stderr = str_replace($tmpFile, $filename, $stderr);
  47610. }
  47611. throw new \UnexpectedValueException('Failed linting '.$file.': '.$stderr);
  47612. }
  47613. } else {
  47614. throw new \RuntimeException('Could not start linter process');
  47615. }
  47616. }
  47617. }
  47618. if ($isWindows) {
  47619. @unlink($tmpFile);
  47620. }
  47621. }
  47622. private static function escapeWindowsPath($path)
  47623. {
  47624. if (strpbrk($path, " ()") !== false) {
  47625. $path = '"'.$path.'"';
  47626. }
  47627. return $path;
  47628. }
  47629. }
  47630. <?php
  47631. namespace Seld\PharUtils;
  47632. class Timestamps
  47633. {
  47634. private $contents;
  47635. public function __construct($file)
  47636. {
  47637. $this->contents = file_get_contents($file);
  47638. }
  47639. public function updateTimestamps($timestamp = null)
  47640. {
  47641. if ($timestamp instanceof \DateTime) {
  47642. $timestamp = $timestamp->getTimestamp();
  47643. } elseif (is_string($timestamp)) {
  47644. $timestamp = strtotime($timestamp);
  47645. } elseif (!is_int($timestamp)) {
  47646. $timestamp = strtotime('1984-12-24T00:00:00Z');
  47647. }
  47648. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  47649. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  47650. }
  47651. $pos = $match[0][1] + strlen($match[0][0]);
  47652. $stubEnd = $pos + $this->readUint($pos, 4);
  47653. $pos += 4;
  47654. $numFiles = $this->readUint($pos, 4);
  47655. $pos += 4;
  47656. $pos += 2;
  47657. $pos += 4;
  47658. $aliasLength = $this->readUint($pos, 4);
  47659. $pos += 4 + $aliasLength;
  47660. $metadataLength = $this->readUint($pos, 4);
  47661. $pos += 4 + $metadataLength;
  47662. while ($pos < $stubEnd) {
  47663. $filenameLength = $this->readUint($pos, 4);
  47664. $pos += 4 + $filenameLength;
  47665. $pos += 4;
  47666. $this->contents = substr_replace($this->contents, pack('L', $timestamp), $pos, 4);
  47667. $pos += 4*4;
  47668. $metadataLength = $this->readUint($pos, 4);
  47669. $pos += 4 + $metadataLength;
  47670. $numFiles--;
  47671. }
  47672. if ($numFiles !== 0) {
  47673. throw new \LogicException('All files were not processed, something must have gone wrong');
  47674. }
  47675. }
  47676. public function save($path, $signatureAlgo)
  47677. {
  47678. $pos = $this->determineSignatureBegin();
  47679. $algos = array(
  47680. \Phar::MD5 => 'md5',
  47681. \Phar::SHA1 => 'sha1',
  47682. \Phar::SHA256 => 'sha256',
  47683. \Phar::SHA512 => 'sha512',
  47684. );
  47685. if (!isset($algos[$signatureAlgo])) {
  47686. throw new \UnexpectedValueException('Invalid hash algorithm given: '.$signatureAlgo.' expected one of Phar::MD5, Phar::SHA1, Phar::SHA256 or Phar::SHA512');
  47687. }
  47688. $algo = $algos[$signatureAlgo];
  47689. $signature = hash($algo, substr($this->contents, 0, $pos), true)
  47690. . pack('L', $signatureAlgo)
  47691. . 'GBMB';
  47692. $this->contents = substr($this->contents, 0, $pos) . $signature;
  47693. return file_put_contents($path, $this->contents);
  47694. }
  47695. private function readUint($pos, $bytes)
  47696. {
  47697. $res = unpack('V', substr($this->contents, $pos, $bytes));
  47698. return $res[1];
  47699. }
  47700. private function determineSignatureBegin()
  47701. {
  47702. if (!preg_match('{__HALT_COMPILER\(\);(?: +\?>)?\r?\n}', $this->contents, $match, PREG_OFFSET_CAPTURE)) {
  47703. throw new \RuntimeException('Could not detect the stub\'s end in the phar');
  47704. }
  47705. $pos = $match[0][1] + strlen($match[0][0]);
  47706. $manifestEnd = $pos + 4 + $this->readUint($pos, 4);
  47707. $pos += 4;
  47708. $numFiles = $this->readUint($pos, 4);
  47709. $pos += 4;
  47710. $pos += 2;
  47711. $pos += 4;
  47712. $aliasLength = $this->readUint($pos, 4);
  47713. $pos += 4 + $aliasLength;
  47714. $metadataLength = $this->readUint($pos, 4);
  47715. $pos += 4 + $metadataLength;
  47716. $compressedSizes = 0;
  47717. while (($numFiles > 0) && ($pos < $manifestEnd - 24)) {
  47718. $filenameLength = $this->readUint($pos, 4);
  47719. $pos += 4 + $filenameLength;
  47720. $pos += 2*4;
  47721. $compressedSizes += $this->readUint($pos, 4);
  47722. $pos += 3*4;
  47723. $metadataLength = $this->readUint($pos, 4);
  47724. $pos += 4 + $metadataLength;
  47725. $numFiles--;
  47726. }
  47727. if ($numFiles !== 0) {
  47728. throw new \LogicException('All files were not processed, something must have gone wrong');
  47729. }
  47730. return $manifestEnd + $compressedSizes;
  47731. }
  47732. }
  47733. <?php
  47734. namespace Symfony\Component\Console;
  47735. use Symfony\Component\Console\Command\Command;
  47736. use Symfony\Component\Console\Command\HelpCommand;
  47737. use Symfony\Component\Console\Command\ListCommand;
  47738. use Symfony\Component\Console\Descriptor\TextDescriptor;
  47739. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  47740. use Symfony\Component\Console\Event\ConsoleCommandEvent;
  47741. use Symfony\Component\Console\Event\ConsoleExceptionEvent;
  47742. use Symfony\Component\Console\Event\ConsoleTerminateEvent;
  47743. use Symfony\Component\Console\Exception\CommandNotFoundException;
  47744. use Symfony\Component\Console\Exception\ExceptionInterface;
  47745. use Symfony\Component\Console\Exception\LogicException;
  47746. use Symfony\Component\Console\Formatter\OutputFormatter;
  47747. use Symfony\Component\Console\Helper\DebugFormatterHelper;
  47748. use Symfony\Component\Console\Helper\DialogHelper;
  47749. use Symfony\Component\Console\Helper\FormatterHelper;
  47750. use Symfony\Component\Console\Helper\Helper;
  47751. use Symfony\Component\Console\Helper\HelperSet;
  47752. use Symfony\Component\Console\Helper\ProcessHelper;
  47753. use Symfony\Component\Console\Helper\ProgressHelper;
  47754. use Symfony\Component\Console\Helper\QuestionHelper;
  47755. use Symfony\Component\Console\Helper\TableHelper;
  47756. use Symfony\Component\Console\Input\ArgvInput;
  47757. use Symfony\Component\Console\Input\ArrayInput;
  47758. use Symfony\Component\Console\Input\InputArgument;
  47759. use Symfony\Component\Console\Input\InputAwareInterface;
  47760. use Symfony\Component\Console\Input\InputDefinition;
  47761. use Symfony\Component\Console\Input\InputInterface;
  47762. use Symfony\Component\Console\Input\InputOption;
  47763. use Symfony\Component\Console\Output\BufferedOutput;
  47764. use Symfony\Component\Console\Output\ConsoleOutput;
  47765. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  47766. use Symfony\Component\Console\Output\OutputInterface;
  47767. use Symfony\Component\Debug\Exception\FatalThrowableError;
  47768. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  47769. class Application
  47770. {
  47771. private $commands = array();
  47772. private $wantHelps = false;
  47773. private $runningCommand;
  47774. private $name;
  47775. private $version;
  47776. private $catchExceptions = true;
  47777. private $autoExit = true;
  47778. private $definition;
  47779. private $helperSet;
  47780. private $dispatcher;
  47781. private $terminalDimensions;
  47782. private $defaultCommand;
  47783. private $initialized;
  47784. public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
  47785. {
  47786. $this->name = $name;
  47787. $this->version = $version;
  47788. $this->defaultCommand = 'list';
  47789. }
  47790. public function setDispatcher(EventDispatcherInterface $dispatcher)
  47791. {
  47792. $this->dispatcher = $dispatcher;
  47793. }
  47794. public function run(InputInterface $input = null, OutputInterface $output = null)
  47795. {
  47796. if (null === $input) {
  47797. $input = new ArgvInput();
  47798. }
  47799. if (null === $output) {
  47800. $output = new ConsoleOutput();
  47801. }
  47802. $this->configureIO($input, $output);
  47803. try {
  47804. $e = null;
  47805. $exitCode = $this->doRun($input, $output);
  47806. } catch (\Exception $e) {
  47807. }
  47808. if (null !== $e) {
  47809. if (!$this->catchExceptions) {
  47810. throw $e;
  47811. }
  47812. if ($output instanceof ConsoleOutputInterface) {
  47813. $this->renderException($e, $output->getErrorOutput());
  47814. } else {
  47815. $this->renderException($e, $output);
  47816. }
  47817. $exitCode = $this->getExitCodeForThrowable($e);
  47818. }
  47819. if ($this->autoExit) {
  47820. if ($exitCode > 255) {
  47821. $exitCode = 255;
  47822. }
  47823. exit($exitCode);
  47824. }
  47825. return $exitCode;
  47826. }
  47827. public function doRun(InputInterface $input, OutputInterface $output)
  47828. {
  47829. if (true === $input->hasParameterOption(array('--version', '-V'))) {
  47830. $output->writeln($this->getLongVersion());
  47831. return 0;
  47832. }
  47833. $name = $this->getCommandName($input);
  47834. if (true === $input->hasParameterOption(array('--help', '-h'))) {
  47835. if (!$name) {
  47836. $name = 'help';
  47837. $input = new ArrayInput(array('command' => 'help'));
  47838. } else {
  47839. $this->wantHelps = true;
  47840. }
  47841. }
  47842. if (!$name) {
  47843. $name = $this->defaultCommand;
  47844. $definition = $this->getDefinition();
  47845. $definition->setArguments(array_merge(
  47846. $definition->getArguments(),
  47847. array(
  47848. 'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
  47849. )
  47850. ));
  47851. }
  47852. $this->runningCommand = null;
  47853. $command = $this->find($name);
  47854. $this->runningCommand = $command;
  47855. $exitCode = $this->doRunCommand($command, $input, $output);
  47856. $this->runningCommand = null;
  47857. return $exitCode;
  47858. }
  47859. public function setHelperSet(HelperSet $helperSet)
  47860. {
  47861. $this->helperSet = $helperSet;
  47862. }
  47863. public function getHelperSet()
  47864. {
  47865. if (!$this->helperSet) {
  47866. $this->helperSet = $this->getDefaultHelperSet();
  47867. }
  47868. return $this->helperSet;
  47869. }
  47870. public function setDefinition(InputDefinition $definition)
  47871. {
  47872. $this->definition = $definition;
  47873. }
  47874. public function getDefinition()
  47875. {
  47876. if (!$this->definition) {
  47877. $this->definition = $this->getDefaultInputDefinition();
  47878. }
  47879. return $this->definition;
  47880. }
  47881. public function getHelp()
  47882. {
  47883. return $this->getLongVersion();
  47884. }
  47885. public function setCatchExceptions($boolean)
  47886. {
  47887. $this->catchExceptions = (bool) $boolean;
  47888. }
  47889. public function setAutoExit($boolean)
  47890. {
  47891. $this->autoExit = (bool) $boolean;
  47892. }
  47893. public function getName()
  47894. {
  47895. return $this->name;
  47896. }
  47897. public function setName($name)
  47898. {
  47899. $this->name = $name;
  47900. }
  47901. public function getVersion()
  47902. {
  47903. return $this->version;
  47904. }
  47905. public function setVersion($version)
  47906. {
  47907. $this->version = $version;
  47908. }
  47909. public function getLongVersion()
  47910. {
  47911. if ('UNKNOWN' !== $this->getName()) {
  47912. if ('UNKNOWN' !== $this->getVersion()) {
  47913. return sprintf('<info>%s</info> version <comment>%s</comment>', $this->getName(), $this->getVersion());
  47914. }
  47915. return sprintf('<info>%s</info>', $this->getName());
  47916. }
  47917. return '<info>Console Tool</info>';
  47918. }
  47919. public function register($name)
  47920. {
  47921. return $this->add(new Command($name));
  47922. }
  47923. public function addCommands(array $commands)
  47924. {
  47925. foreach ($commands as $command) {
  47926. $this->add($command);
  47927. }
  47928. }
  47929. public function add(Command $command)
  47930. {
  47931. $this->init();
  47932. $command->setApplication($this);
  47933. if (!$command->isEnabled()) {
  47934. $command->setApplication(null);
  47935. return;
  47936. }
  47937. if (null === $command->getDefinition()) {
  47938. throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command)));
  47939. }
  47940. $this->commands[$command->getName()] = $command;
  47941. foreach ($command->getAliases() as $alias) {
  47942. $this->commands[$alias] = $command;
  47943. }
  47944. return $command;
  47945. }
  47946. public function get($name)
  47947. {
  47948. $this->init();
  47949. if (!isset($this->commands[$name])) {
  47950. throw new CommandNotFoundException(sprintf('The command "%s" does not exist.', $name));
  47951. }
  47952. $command = $this->commands[$name];
  47953. if ($this->wantHelps) {
  47954. $this->wantHelps = false;
  47955. $helpCommand = $this->get('help');
  47956. $helpCommand->setCommand($command);
  47957. return $helpCommand;
  47958. }
  47959. return $command;
  47960. }
  47961. public function has($name)
  47962. {
  47963. $this->init();
  47964. return isset($this->commands[$name]);
  47965. }
  47966. public function getNamespaces()
  47967. {
  47968. $namespaces = array();
  47969. foreach ($this->all() as $command) {
  47970. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName()));
  47971. foreach ($command->getAliases() as $alias) {
  47972. $namespaces = array_merge($namespaces, $this->extractAllNamespaces($alias));
  47973. }
  47974. }
  47975. return array_values(array_unique(array_filter($namespaces)));
  47976. }
  47977. public function findNamespace($namespace)
  47978. {
  47979. $allNamespaces = $this->getNamespaces();
  47980. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $namespace);
  47981. $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces);
  47982. if (empty($namespaces)) {
  47983. $message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
  47984. if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
  47985. if (1 == \count($alternatives)) {
  47986. $message .= "\n\nDid you mean this?\n ";
  47987. } else {
  47988. $message .= "\n\nDid you mean one of these?\n ";
  47989. }
  47990. $message .= implode("\n ", $alternatives);
  47991. }
  47992. throw new CommandNotFoundException($message, $alternatives);
  47993. }
  47994. $exact = \in_array($namespace, $namespaces, true);
  47995. if (\count($namespaces) > 1 && !$exact) {
  47996. throw new CommandNotFoundException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
  47997. }
  47998. return $exact ? $namespace : reset($namespaces);
  47999. }
  48000. public function find($name)
  48001. {
  48002. $this->init();
  48003. $aliases = array();
  48004. $allCommands = array_keys($this->commands);
  48005. $expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
  48006. $commands = preg_grep('{^'.$expr.'}', $allCommands);
  48007. if (empty($commands) || \count(preg_grep('{^'.$expr.'$}', $commands)) < 1) {
  48008. if (false !== $pos = strrpos($name, ':')) {
  48009. $this->findNamespace(substr($name, 0, $pos));
  48010. }
  48011. $message = sprintf('Command "%s" is not defined.', $name);
  48012. if ($alternatives = $this->findAlternatives($name, $allCommands)) {
  48013. if (1 == \count($alternatives)) {
  48014. $message .= "\n\nDid you mean this?\n ";
  48015. } else {
  48016. $message .= "\n\nDid you mean one of these?\n ";
  48017. }
  48018. $message .= implode("\n ", $alternatives);
  48019. }
  48020. throw new CommandNotFoundException($message, $alternatives);
  48021. }
  48022. if (\count($commands) > 1) {
  48023. $commandList = $this->commands;
  48024. $commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
  48025. $commandName = $commandList[$nameOrAlias]->getName();
  48026. $aliases[$nameOrAlias] = $commandName;
  48027. return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
  48028. });
  48029. }
  48030. $exact = \in_array($name, $commands, true) || isset($aliases[$name]);
  48031. if (!$exact && \count($commands) > 1) {
  48032. $suggestions = $this->getAbbreviationSuggestions(array_values($commands));
  48033. throw new CommandNotFoundException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions), array_values($commands));
  48034. }
  48035. return $this->get($exact ? $name : reset($commands));
  48036. }
  48037. public function all($namespace = null)
  48038. {
  48039. $this->init();
  48040. if (null === $namespace) {
  48041. return $this->commands;
  48042. }
  48043. $commands = array();
  48044. foreach ($this->commands as $name => $command) {
  48045. if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
  48046. $commands[$name] = $command;
  48047. }
  48048. }
  48049. return $commands;
  48050. }
  48051. public static function getAbbreviations($names)
  48052. {
  48053. $abbrevs = array();
  48054. foreach ($names as $name) {
  48055. for ($len = \strlen($name); $len > 0; --$len) {
  48056. $abbrev = substr($name, 0, $len);
  48057. $abbrevs[$abbrev][] = $name;
  48058. }
  48059. }
  48060. return $abbrevs;
  48061. }
  48062. public function asText($namespace = null, $raw = false)
  48063. {
  48064. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48065. $descriptor = new TextDescriptor();
  48066. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, !$raw);
  48067. $descriptor->describe($output, $this, array('namespace' => $namespace, 'raw_output' => true));
  48068. return $output->fetch();
  48069. }
  48070. public function asXml($namespace = null, $asDom = false)
  48071. {
  48072. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48073. $descriptor = new XmlDescriptor();
  48074. if ($asDom) {
  48075. return $descriptor->getApplicationDocument($this, $namespace);
  48076. }
  48077. $output = new BufferedOutput();
  48078. $descriptor->describe($output, $this, array('namespace' => $namespace));
  48079. return $output->fetch();
  48080. }
  48081. public function renderException($e, $output)
  48082. {
  48083. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  48084. do {
  48085. $title = sprintf(' [%s] ', \get_class($e));
  48086. $len = Helper::strlen($title);
  48087. $width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
  48088. if (\defined('HHVM_VERSION') && $width > 1 << 31) {
  48089. $width = 1 << 31;
  48090. }
  48091. $lines = array();
  48092. foreach (preg_split('/\r?\n/', trim($e->getMessage())) as $line) {
  48093. foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
  48094. $lineLength = Helper::strlen($line) + 4;
  48095. $lines[] = array($line, $lineLength);
  48096. $len = max($lineLength, $len);
  48097. }
  48098. }
  48099. $messages = array();
  48100. $messages[] = $emptyLine = sprintf('<error>%s</error>', str_repeat(' ', $len));
  48101. $messages[] = sprintf('<error>%s%s</error>', $title, str_repeat(' ', max(0, $len - Helper::strlen($title))));
  48102. foreach ($lines as $line) {
  48103. $messages[] = sprintf('<error> %s %s</error>', OutputFormatter::escape($line[0]), str_repeat(' ', $len - $line[1]));
  48104. }
  48105. $messages[] = $emptyLine;
  48106. $messages[] = '';
  48107. $output->writeln($messages, OutputInterface::VERBOSITY_QUIET);
  48108. if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
  48109. $output->writeln('<comment>Exception trace:</comment>', OutputInterface::VERBOSITY_QUIET);
  48110. $trace = $e->getTrace();
  48111. array_unshift($trace, array(
  48112. 'function' => '',
  48113. 'file' => null !== $e->getFile() ? $e->getFile() : 'n/a',
  48114. 'line' => null !== $e->getLine() ? $e->getLine() : 'n/a',
  48115. 'args' => array(),
  48116. ));
  48117. for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
  48118. $class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
  48119. $type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
  48120. $function = $trace[$i]['function'];
  48121. $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : 'n/a';
  48122. $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : 'n/a';
  48123. $output->writeln(sprintf(' %s%s%s() at <info>%s:%s</info>', $class, $type, $function, $file, $line), OutputInterface::VERBOSITY_QUIET);
  48124. }
  48125. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  48126. }
  48127. } while ($e = $e->getPrevious());
  48128. if (null !== $this->runningCommand) {
  48129. $output->writeln(sprintf('<info>%s</info>', sprintf($this->runningCommand->getSynopsis(), $this->getName())), OutputInterface::VERBOSITY_QUIET);
  48130. $output->writeln('', OutputInterface::VERBOSITY_QUIET);
  48131. }
  48132. }
  48133. protected function getTerminalWidth()
  48134. {
  48135. $dimensions = $this->getTerminalDimensions();
  48136. return $dimensions[0];
  48137. }
  48138. protected function getTerminalHeight()
  48139. {
  48140. $dimensions = $this->getTerminalDimensions();
  48141. return $dimensions[1];
  48142. }
  48143. public function getTerminalDimensions()
  48144. {
  48145. if ($this->terminalDimensions) {
  48146. return $this->terminalDimensions;
  48147. }
  48148. if ('\\' === \DIRECTORY_SEPARATOR) {
  48149. if (preg_match('/^(\d+)x\d+ \(\d+x(\d+)\)$/', trim(getenv('ANSICON')), $matches)) {
  48150. return array((int) $matches[1], (int) $matches[2]);
  48151. }
  48152. if (preg_match('/^(\d+)x(\d+)$/', $this->getConsoleMode(), $matches)) {
  48153. return array((int) $matches[1], (int) $matches[2]);
  48154. }
  48155. }
  48156. if ($sttyString = $this->getSttyColumns()) {
  48157. if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
  48158. return array((int) $matches[2], (int) $matches[1]);
  48159. }
  48160. if (preg_match('/;.(\d+).rows;.(\d+).columns/i', $sttyString, $matches)) {
  48161. return array((int) $matches[2], (int) $matches[1]);
  48162. }
  48163. }
  48164. return array(null, null);
  48165. }
  48166. public function setTerminalDimensions($width, $height)
  48167. {
  48168. $this->terminalDimensions = array($width, $height);
  48169. return $this;
  48170. }
  48171. protected function configureIO(InputInterface $input, OutputInterface $output)
  48172. {
  48173. if (true === $input->hasParameterOption(array('--ansi'))) {
  48174. $output->setDecorated(true);
  48175. } elseif (true === $input->hasParameterOption(array('--no-ansi'))) {
  48176. $output->setDecorated(false);
  48177. }
  48178. if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
  48179. $input->setInteractive(false);
  48180. } elseif (\function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
  48181. $inputStream = $this->getHelperSet()->get('question')->getInputStream();
  48182. if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
  48183. $input->setInteractive(false);
  48184. }
  48185. }
  48186. if (true === $input->hasParameterOption(array('--quiet', '-q'))) {
  48187. $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
  48188. $input->setInteractive(false);
  48189. } else {
  48190. if ($input->hasParameterOption('-vvv') || $input->hasParameterOption('--verbose=3') || 3 === $input->getParameterOption('--verbose')) {
  48191. $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
  48192. } elseif ($input->hasParameterOption('-vv') || $input->hasParameterOption('--verbose=2') || 2 === $input->getParameterOption('--verbose')) {
  48193. $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
  48194. } elseif ($input->hasParameterOption('-v') || $input->hasParameterOption('--verbose=1') || $input->hasParameterOption('--verbose') || $input->getParameterOption('--verbose')) {
  48195. $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
  48196. }
  48197. }
  48198. }
  48199. protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output)
  48200. {
  48201. foreach ($command->getHelperSet() as $helper) {
  48202. if ($helper instanceof InputAwareInterface) {
  48203. $helper->setInput($input);
  48204. }
  48205. }
  48206. if (null === $this->dispatcher) {
  48207. return $command->run($input, $output);
  48208. }
  48209. try {
  48210. $command->mergeApplicationDefinition();
  48211. $input->bind($command->getDefinition());
  48212. } catch (ExceptionInterface $e) {
  48213. }
  48214. $event = new ConsoleCommandEvent($command, $input, $output);
  48215. $e = null;
  48216. try {
  48217. $this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
  48218. if ($event->commandShouldRun()) {
  48219. $exitCode = $command->run($input, $output);
  48220. } else {
  48221. $exitCode = ConsoleCommandEvent::RETURN_CODE_DISABLED;
  48222. }
  48223. } catch (\Exception $e) {
  48224. } catch (\Throwable $e) {
  48225. }
  48226. if (null !== $e) {
  48227. $x = $e instanceof \Exception ? $e : new FatalThrowableError($e);
  48228. $event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());
  48229. $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);
  48230. if ($x !== $event->getException()) {
  48231. $e = $event->getException();
  48232. }
  48233. $exitCode = $this->getExitCodeForThrowable($e);
  48234. }
  48235. $event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
  48236. $this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
  48237. if (null !== $e) {
  48238. throw $e;
  48239. }
  48240. return $event->getExitCode();
  48241. }
  48242. protected function getCommandName(InputInterface $input)
  48243. {
  48244. return $input->getFirstArgument();
  48245. }
  48246. protected function getDefaultInputDefinition()
  48247. {
  48248. return new InputDefinition(array(
  48249. new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
  48250. new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
  48251. new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
  48252. 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'),
  48253. new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
  48254. new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
  48255. new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
  48256. new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
  48257. ));
  48258. }
  48259. protected function getDefaultCommands()
  48260. {
  48261. return array(new HelpCommand(), new ListCommand());
  48262. }
  48263. protected function getDefaultHelperSet()
  48264. {
  48265. return new HelperSet(array(
  48266. new FormatterHelper(),
  48267. new DialogHelper(false),
  48268. new ProgressHelper(false),
  48269. new TableHelper(false),
  48270. new DebugFormatterHelper(),
  48271. new ProcessHelper(),
  48272. new QuestionHelper(),
  48273. ));
  48274. }
  48275. private function getSttyColumns()
  48276. {
  48277. if (!\function_exists('proc_open')) {
  48278. return;
  48279. }
  48280. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  48281. $process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  48282. if (\is_resource($process)) {
  48283. $info = stream_get_contents($pipes[1]);
  48284. fclose($pipes[1]);
  48285. fclose($pipes[2]);
  48286. proc_close($process);
  48287. return $info;
  48288. }
  48289. }
  48290. private function getConsoleMode()
  48291. {
  48292. if (!\function_exists('proc_open')) {
  48293. return;
  48294. }
  48295. $descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
  48296. $process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
  48297. if (\is_resource($process)) {
  48298. $info = stream_get_contents($pipes[1]);
  48299. fclose($pipes[1]);
  48300. fclose($pipes[2]);
  48301. proc_close($process);
  48302. if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
  48303. return $matches[2].'x'.$matches[1];
  48304. }
  48305. }
  48306. }
  48307. private function getAbbreviationSuggestions($abbrevs)
  48308. {
  48309. return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], \count($abbrevs) > 2 ? sprintf(' and %d more', \count($abbrevs) - 2) : '');
  48310. }
  48311. public function extractNamespace($name, $limit = null)
  48312. {
  48313. $parts = explode(':', $name);
  48314. array_pop($parts);
  48315. return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
  48316. }
  48317. private function findAlternatives($name, $collection)
  48318. {
  48319. $threshold = 1e3;
  48320. $alternatives = array();
  48321. $collectionParts = array();
  48322. foreach ($collection as $item) {
  48323. $collectionParts[$item] = explode(':', $item);
  48324. }
  48325. foreach (explode(':', $name) as $i => $subname) {
  48326. foreach ($collectionParts as $collectionName => $parts) {
  48327. $exists = isset($alternatives[$collectionName]);
  48328. if (!isset($parts[$i]) && $exists) {
  48329. $alternatives[$collectionName] += $threshold;
  48330. continue;
  48331. } elseif (!isset($parts[$i])) {
  48332. continue;
  48333. }
  48334. $lev = levenshtein($subname, $parts[$i]);
  48335. if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
  48336. $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
  48337. } elseif ($exists) {
  48338. $alternatives[$collectionName] += $threshold;
  48339. }
  48340. }
  48341. }
  48342. foreach ($collection as $item) {
  48343. $lev = levenshtein($name, $item);
  48344. if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
  48345. $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
  48346. }
  48347. }
  48348. $alternatives = array_filter($alternatives, function ($lev) use ($threshold) { return $lev < 2 * $threshold; });
  48349. asort($alternatives);
  48350. return array_keys($alternatives);
  48351. }
  48352. public function setDefaultCommand($commandName)
  48353. {
  48354. $this->defaultCommand = $commandName;
  48355. }
  48356. private function splitStringByWidth($string, $width)
  48357. {
  48358. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  48359. return str_split($string, $width);
  48360. }
  48361. $utf8String = mb_convert_encoding($string, 'utf8', $encoding);
  48362. $lines = array();
  48363. $line = '';
  48364. foreach (preg_split('//u', $utf8String) as $char) {
  48365. if (mb_strwidth($line.$char, 'utf8') <= $width) {
  48366. $line .= $char;
  48367. continue;
  48368. }
  48369. $lines[] = str_pad($line, $width);
  48370. $line = $char;
  48371. }
  48372. $lines[] = \count($lines) ? str_pad($line, $width) : $line;
  48373. mb_convert_variables($encoding, 'utf8', $lines);
  48374. return $lines;
  48375. }
  48376. private function extractAllNamespaces($name)
  48377. {
  48378. $parts = explode(':', $name, -1);
  48379. $namespaces = array();
  48380. foreach ($parts as $part) {
  48381. if (\count($namespaces)) {
  48382. $namespaces[] = end($namespaces).':'.$part;
  48383. } else {
  48384. $namespaces[] = $part;
  48385. }
  48386. }
  48387. return $namespaces;
  48388. }
  48389. private function init()
  48390. {
  48391. if ($this->initialized) {
  48392. return;
  48393. }
  48394. $this->initialized = true;
  48395. foreach ($this->getDefaultCommands() as $command) {
  48396. $this->add($command);
  48397. }
  48398. }
  48399. private function getExitCodeForThrowable($throwable)
  48400. {
  48401. $exitCode = $throwable->getCode();
  48402. if (is_numeric($exitCode)) {
  48403. $exitCode = (int) $exitCode;
  48404. if (0 === $exitCode) {
  48405. $exitCode = 1;
  48406. }
  48407. } else {
  48408. $exitCode = 1;
  48409. }
  48410. return $exitCode;
  48411. }
  48412. }
  48413. <?php
  48414. namespace Symfony\Component\Console\Command;
  48415. use Symfony\Component\Console\Application;
  48416. use Symfony\Component\Console\Descriptor\TextDescriptor;
  48417. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  48418. use Symfony\Component\Console\Exception\ExceptionInterface;
  48419. use Symfony\Component\Console\Exception\InvalidArgumentException;
  48420. use Symfony\Component\Console\Exception\LogicException;
  48421. use Symfony\Component\Console\Helper\HelperSet;
  48422. use Symfony\Component\Console\Input\InputArgument;
  48423. use Symfony\Component\Console\Input\InputDefinition;
  48424. use Symfony\Component\Console\Input\InputInterface;
  48425. use Symfony\Component\Console\Input\InputOption;
  48426. use Symfony\Component\Console\Output\BufferedOutput;
  48427. use Symfony\Component\Console\Output\OutputInterface;
  48428. class Command
  48429. {
  48430. private $application;
  48431. private $name;
  48432. private $processTitle;
  48433. private $aliases = array();
  48434. private $definition;
  48435. private $help;
  48436. private $description;
  48437. private $ignoreValidationErrors = false;
  48438. private $applicationDefinitionMerged = false;
  48439. private $applicationDefinitionMergedWithArgs = false;
  48440. private $code;
  48441. private $synopsis = array();
  48442. private $usages = array();
  48443. private $helperSet;
  48444. public function __construct($name = null)
  48445. {
  48446. $this->definition = new InputDefinition();
  48447. if (null !== $name) {
  48448. $this->setName($name);
  48449. }
  48450. $this->configure();
  48451. if (!$this->name) {
  48452. throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this)));
  48453. }
  48454. }
  48455. public function ignoreValidationErrors()
  48456. {
  48457. $this->ignoreValidationErrors = true;
  48458. }
  48459. public function setApplication(Application $application = null)
  48460. {
  48461. $this->application = $application;
  48462. if ($application) {
  48463. $this->setHelperSet($application->getHelperSet());
  48464. } else {
  48465. $this->helperSet = null;
  48466. }
  48467. }
  48468. public function setHelperSet(HelperSet $helperSet)
  48469. {
  48470. $this->helperSet = $helperSet;
  48471. }
  48472. public function getHelperSet()
  48473. {
  48474. return $this->helperSet;
  48475. }
  48476. public function getApplication()
  48477. {
  48478. return $this->application;
  48479. }
  48480. public function isEnabled()
  48481. {
  48482. return true;
  48483. }
  48484. protected function configure()
  48485. {
  48486. }
  48487. protected function execute(InputInterface $input, OutputInterface $output)
  48488. {
  48489. throw new LogicException('You must override the execute() method in the concrete command class.');
  48490. }
  48491. protected function interact(InputInterface $input, OutputInterface $output)
  48492. {
  48493. }
  48494. protected function initialize(InputInterface $input, OutputInterface $output)
  48495. {
  48496. }
  48497. public function run(InputInterface $input, OutputInterface $output)
  48498. {
  48499. $this->getSynopsis(true);
  48500. $this->getSynopsis(false);
  48501. $this->mergeApplicationDefinition();
  48502. try {
  48503. $input->bind($this->definition);
  48504. } catch (ExceptionInterface $e) {
  48505. if (!$this->ignoreValidationErrors) {
  48506. throw $e;
  48507. }
  48508. }
  48509. $this->initialize($input, $output);
  48510. if (null !== $this->processTitle) {
  48511. if (\function_exists('cli_set_process_title')) {
  48512. if (!@cli_set_process_title($this->processTitle)) {
  48513. if ('Darwin' === PHP_OS) {
  48514. $output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
  48515. } else {
  48516. cli_set_process_title($this->processTitle);
  48517. }
  48518. }
  48519. } elseif (\function_exists('setproctitle')) {
  48520. setproctitle($this->processTitle);
  48521. } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
  48522. $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
  48523. }
  48524. }
  48525. if ($input->isInteractive()) {
  48526. $this->interact($input, $output);
  48527. }
  48528. if ($input->hasArgument('command') && null === $input->getArgument('command')) {
  48529. $input->setArgument('command', $this->getName());
  48530. }
  48531. $input->validate();
  48532. if ($this->code) {
  48533. $statusCode = \call_user_func($this->code, $input, $output);
  48534. } else {
  48535. $statusCode = $this->execute($input, $output);
  48536. }
  48537. return is_numeric($statusCode) ? (int) $statusCode : 0;
  48538. }
  48539. public function setCode($code)
  48540. {
  48541. if (!\is_callable($code)) {
  48542. throw new InvalidArgumentException('Invalid callable provided to Command::setCode.');
  48543. }
  48544. if (\PHP_VERSION_ID >= 50400 && $code instanceof \Closure) {
  48545. $r = new \ReflectionFunction($code);
  48546. if (null === $r->getClosureThis()) {
  48547. if (\PHP_VERSION_ID < 70000) {
  48548. $code = @\Closure::bind($code, $this);
  48549. } else {
  48550. $code = \Closure::bind($code, $this);
  48551. }
  48552. }
  48553. }
  48554. $this->code = $code;
  48555. return $this;
  48556. }
  48557. public function mergeApplicationDefinition($mergeArgs = true)
  48558. {
  48559. if (null === $this->application || (true === $this->applicationDefinitionMerged && ($this->applicationDefinitionMergedWithArgs || !$mergeArgs))) {
  48560. return;
  48561. }
  48562. $this->definition->addOptions($this->application->getDefinition()->getOptions());
  48563. $this->applicationDefinitionMerged = true;
  48564. if ($mergeArgs) {
  48565. $currentArguments = $this->definition->getArguments();
  48566. $this->definition->setArguments($this->application->getDefinition()->getArguments());
  48567. $this->definition->addArguments($currentArguments);
  48568. $this->applicationDefinitionMergedWithArgs = true;
  48569. }
  48570. }
  48571. public function setDefinition($definition)
  48572. {
  48573. if ($definition instanceof InputDefinition) {
  48574. $this->definition = $definition;
  48575. } else {
  48576. $this->definition->setDefinition($definition);
  48577. }
  48578. $this->applicationDefinitionMerged = false;
  48579. return $this;
  48580. }
  48581. public function getDefinition()
  48582. {
  48583. return $this->definition;
  48584. }
  48585. public function getNativeDefinition()
  48586. {
  48587. return $this->getDefinition();
  48588. }
  48589. public function addArgument($name, $mode = null, $description = '', $default = null)
  48590. {
  48591. $this->definition->addArgument(new InputArgument($name, $mode, $description, $default));
  48592. return $this;
  48593. }
  48594. public function addOption($name, $shortcut = null, $mode = null, $description = '', $default = null)
  48595. {
  48596. $this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
  48597. return $this;
  48598. }
  48599. public function setName($name)
  48600. {
  48601. $this->validateName($name);
  48602. $this->name = $name;
  48603. return $this;
  48604. }
  48605. public function setProcessTitle($title)
  48606. {
  48607. $this->processTitle = $title;
  48608. return $this;
  48609. }
  48610. public function getName()
  48611. {
  48612. return $this->name;
  48613. }
  48614. public function setDescription($description)
  48615. {
  48616. $this->description = $description;
  48617. return $this;
  48618. }
  48619. public function getDescription()
  48620. {
  48621. return $this->description;
  48622. }
  48623. public function setHelp($help)
  48624. {
  48625. $this->help = $help;
  48626. return $this;
  48627. }
  48628. public function getHelp()
  48629. {
  48630. return $this->help;
  48631. }
  48632. public function getProcessedHelp()
  48633. {
  48634. $name = $this->name;
  48635. $placeholders = array(
  48636. '%command.name%',
  48637. '%command.full_name%',
  48638. );
  48639. $replacements = array(
  48640. $name,
  48641. $_SERVER['PHP_SELF'].' '.$name,
  48642. );
  48643. return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription());
  48644. }
  48645. public function setAliases($aliases)
  48646. {
  48647. if (!\is_array($aliases) && !$aliases instanceof \Traversable) {
  48648. throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable');
  48649. }
  48650. foreach ($aliases as $alias) {
  48651. $this->validateName($alias);
  48652. }
  48653. $this->aliases = $aliases;
  48654. return $this;
  48655. }
  48656. public function getAliases()
  48657. {
  48658. return $this->aliases;
  48659. }
  48660. public function getSynopsis($short = false)
  48661. {
  48662. $key = $short ? 'short' : 'long';
  48663. if (!isset($this->synopsis[$key])) {
  48664. $this->synopsis[$key] = trim(sprintf('%s %s', $this->name, $this->definition->getSynopsis($short)));
  48665. }
  48666. return $this->synopsis[$key];
  48667. }
  48668. public function addUsage($usage)
  48669. {
  48670. if (0 !== strpos($usage, $this->name)) {
  48671. $usage = sprintf('%s %s', $this->name, $usage);
  48672. }
  48673. $this->usages[] = $usage;
  48674. return $this;
  48675. }
  48676. public function getUsages()
  48677. {
  48678. return $this->usages;
  48679. }
  48680. public function getHelper($name)
  48681. {
  48682. if (null === $this->helperSet) {
  48683. 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));
  48684. }
  48685. return $this->helperSet->get($name);
  48686. }
  48687. public function asText()
  48688. {
  48689. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48690. $descriptor = new TextDescriptor();
  48691. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  48692. $descriptor->describe($output, $this, array('raw_output' => true));
  48693. return $output->fetch();
  48694. }
  48695. public function asXml($asDom = false)
  48696. {
  48697. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  48698. $descriptor = new XmlDescriptor();
  48699. if ($asDom) {
  48700. return $descriptor->getCommandDocument($this);
  48701. }
  48702. $output = new BufferedOutput();
  48703. $descriptor->describe($output, $this);
  48704. return $output->fetch();
  48705. }
  48706. private function validateName($name)
  48707. {
  48708. if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) {
  48709. throw new InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name));
  48710. }
  48711. }
  48712. }
  48713. <?php
  48714. namespace Symfony\Component\Console\Command;
  48715. use Symfony\Component\Console\Helper\DescriptorHelper;
  48716. use Symfony\Component\Console\Input\InputArgument;
  48717. use Symfony\Component\Console\Input\InputInterface;
  48718. use Symfony\Component\Console\Input\InputOption;
  48719. use Symfony\Component\Console\Output\OutputInterface;
  48720. class HelpCommand extends Command
  48721. {
  48722. private $command;
  48723. protected function configure()
  48724. {
  48725. $this->ignoreValidationErrors();
  48726. $this
  48727. ->setName('help')
  48728. ->setDefinition(array(
  48729. new InputArgument('command_name', InputArgument::OPTIONAL, 'The command name', 'help'),
  48730. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output help as XML'),
  48731. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  48732. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
  48733. ))
  48734. ->setDescription('Displays help for a command')
  48735. ->setHelp(<<<'EOF'
  48736. The <info>%command.name%</info> command displays help for a given command:
  48737. <info>php %command.full_name% list</info>
  48738. You can also output the help in other formats by using the <comment>--format</comment> option:
  48739. <info>php %command.full_name% --format=xml list</info>
  48740. To display the list of available commands, please use the <info>list</info> command.
  48741. EOF
  48742. )
  48743. ;
  48744. }
  48745. public function setCommand(Command $command)
  48746. {
  48747. $this->command = $command;
  48748. }
  48749. protected function execute(InputInterface $input, OutputInterface $output)
  48750. {
  48751. if (null === $this->command) {
  48752. $this->command = $this->getApplication()->find($input->getArgument('command_name'));
  48753. }
  48754. if ($input->getOption('xml')) {
  48755. @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);
  48756. $input->setOption('format', 'xml');
  48757. }
  48758. $helper = new DescriptorHelper();
  48759. $helper->describe($output, $this->command, array(
  48760. 'format' => $input->getOption('format'),
  48761. 'raw_text' => $input->getOption('raw'),
  48762. ));
  48763. $this->command = null;
  48764. }
  48765. }
  48766. <?php
  48767. namespace Symfony\Component\Console\Command;
  48768. use Symfony\Component\Console\Helper\DescriptorHelper;
  48769. use Symfony\Component\Console\Input\InputArgument;
  48770. use Symfony\Component\Console\Input\InputDefinition;
  48771. use Symfony\Component\Console\Input\InputInterface;
  48772. use Symfony\Component\Console\Input\InputOption;
  48773. use Symfony\Component\Console\Output\OutputInterface;
  48774. class ListCommand extends Command
  48775. {
  48776. protected function configure()
  48777. {
  48778. $this
  48779. ->setName('list')
  48780. ->setDefinition($this->createDefinition())
  48781. ->setDescription('Lists commands')
  48782. ->setHelp(<<<'EOF'
  48783. The <info>%command.name%</info> command lists all commands:
  48784. <info>php %command.full_name%</info>
  48785. You can also display the commands for a specific namespace:
  48786. <info>php %command.full_name% test</info>
  48787. You can also output the information in other formats by using the <comment>--format</comment> option:
  48788. <info>php %command.full_name% --format=xml</info>
  48789. It's also possible to get raw list of commands (useful for embedding command runner):
  48790. <info>php %command.full_name% --raw</info>
  48791. EOF
  48792. )
  48793. ;
  48794. }
  48795. public function getNativeDefinition()
  48796. {
  48797. return $this->createDefinition();
  48798. }
  48799. protected function execute(InputInterface $input, OutputInterface $output)
  48800. {
  48801. if ($input->getOption('xml')) {
  48802. @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);
  48803. $input->setOption('format', 'xml');
  48804. }
  48805. $helper = new DescriptorHelper();
  48806. $helper->describe($output, $this->getApplication(), array(
  48807. 'format' => $input->getOption('format'),
  48808. 'raw_text' => $input->getOption('raw'),
  48809. 'namespace' => $input->getArgument('namespace'),
  48810. ));
  48811. }
  48812. private function createDefinition()
  48813. {
  48814. return new InputDefinition(array(
  48815. new InputArgument('namespace', InputArgument::OPTIONAL, 'The namespace name'),
  48816. new InputOption('xml', null, InputOption::VALUE_NONE, 'To output list as XML'),
  48817. new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command list'),
  48818. new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
  48819. ));
  48820. }
  48821. }
  48822. <?php
  48823. namespace Symfony\Component\Console;
  48824. final class ConsoleEvents
  48825. {
  48826. const COMMAND = 'console.command';
  48827. const TERMINATE = 'console.terminate';
  48828. const EXCEPTION = 'console.exception';
  48829. }
  48830. <?php
  48831. namespace Symfony\Component\Console\Descriptor;
  48832. use Symfony\Component\Console\Application;
  48833. use Symfony\Component\Console\Command\Command;
  48834. use Symfony\Component\Console\Exception\CommandNotFoundException;
  48835. class ApplicationDescription
  48836. {
  48837. const GLOBAL_NAMESPACE = '_global';
  48838. private $application;
  48839. private $namespace;
  48840. private $namespaces;
  48841. private $commands;
  48842. private $aliases;
  48843. public function __construct(Application $application, $namespace = null)
  48844. {
  48845. $this->application = $application;
  48846. $this->namespace = $namespace;
  48847. }
  48848. public function getNamespaces()
  48849. {
  48850. if (null === $this->namespaces) {
  48851. $this->inspectApplication();
  48852. }
  48853. return $this->namespaces;
  48854. }
  48855. public function getCommands()
  48856. {
  48857. if (null === $this->commands) {
  48858. $this->inspectApplication();
  48859. }
  48860. return $this->commands;
  48861. }
  48862. public function getCommand($name)
  48863. {
  48864. if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) {
  48865. throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name));
  48866. }
  48867. return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name];
  48868. }
  48869. private function inspectApplication()
  48870. {
  48871. $this->commands = array();
  48872. $this->namespaces = array();
  48873. $all = $this->application->all($this->namespace ? $this->application->findNamespace($this->namespace) : null);
  48874. foreach ($this->sortCommands($all) as $namespace => $commands) {
  48875. $names = array();
  48876. foreach ($commands as $name => $command) {
  48877. if (!$command->getName()) {
  48878. continue;
  48879. }
  48880. if ($command->getName() === $name) {
  48881. $this->commands[$name] = $command;
  48882. } else {
  48883. $this->aliases[$name] = $command;
  48884. }
  48885. $names[] = $name;
  48886. }
  48887. $this->namespaces[$namespace] = array('id' => $namespace, 'commands' => $names);
  48888. }
  48889. }
  48890. private function sortCommands(array $commands)
  48891. {
  48892. $namespacedCommands = array();
  48893. $globalCommands = array();
  48894. foreach ($commands as $name => $command) {
  48895. $key = $this->application->extractNamespace($name, 1);
  48896. if (!$key) {
  48897. $globalCommands['_global'][$name] = $command;
  48898. } else {
  48899. $namespacedCommands[$key][$name] = $command;
  48900. }
  48901. }
  48902. ksort($namespacedCommands);
  48903. $namespacedCommands = array_merge($globalCommands, $namespacedCommands);
  48904. foreach ($namespacedCommands as &$commandsSet) {
  48905. ksort($commandsSet);
  48906. }
  48907. unset($commandsSet);
  48908. return $namespacedCommands;
  48909. }
  48910. }
  48911. <?php
  48912. namespace Symfony\Component\Console\Descriptor;
  48913. use Symfony\Component\Console\Application;
  48914. use Symfony\Component\Console\Command\Command;
  48915. use Symfony\Component\Console\Exception\InvalidArgumentException;
  48916. use Symfony\Component\Console\Input\InputArgument;
  48917. use Symfony\Component\Console\Input\InputDefinition;
  48918. use Symfony\Component\Console\Input\InputOption;
  48919. use Symfony\Component\Console\Output\OutputInterface;
  48920. abstract class Descriptor implements DescriptorInterface
  48921. {
  48922. private $output;
  48923. public function describe(OutputInterface $output, $object, array $options = array())
  48924. {
  48925. $this->output = $output;
  48926. switch (true) {
  48927. case $object instanceof InputArgument:
  48928. $this->describeInputArgument($object, $options);
  48929. break;
  48930. case $object instanceof InputOption:
  48931. $this->describeInputOption($object, $options);
  48932. break;
  48933. case $object instanceof InputDefinition:
  48934. $this->describeInputDefinition($object, $options);
  48935. break;
  48936. case $object instanceof Command:
  48937. $this->describeCommand($object, $options);
  48938. break;
  48939. case $object instanceof Application:
  48940. $this->describeApplication($object, $options);
  48941. break;
  48942. default:
  48943. throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
  48944. }
  48945. }
  48946. protected function write($content, $decorated = false)
  48947. {
  48948. $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  48949. }
  48950. abstract protected function describeInputArgument(InputArgument $argument, array $options = array());
  48951. abstract protected function describeInputOption(InputOption $option, array $options = array());
  48952. abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array());
  48953. abstract protected function describeCommand(Command $command, array $options = array());
  48954. abstract protected function describeApplication(Application $application, array $options = array());
  48955. }
  48956. <?php
  48957. namespace Symfony\Component\Console\Descriptor;
  48958. use Symfony\Component\Console\Output\OutputInterface;
  48959. interface DescriptorInterface
  48960. {
  48961. public function describe(OutputInterface $output, $object, array $options = array());
  48962. }
  48963. <?php
  48964. namespace Symfony\Component\Console\Descriptor;
  48965. use Symfony\Component\Console\Application;
  48966. use Symfony\Component\Console\Command\Command;
  48967. use Symfony\Component\Console\Input\InputArgument;
  48968. use Symfony\Component\Console\Input\InputDefinition;
  48969. use Symfony\Component\Console\Input\InputOption;
  48970. class JsonDescriptor extends Descriptor
  48971. {
  48972. protected function describeInputArgument(InputArgument $argument, array $options = array())
  48973. {
  48974. $this->writeData($this->getInputArgumentData($argument), $options);
  48975. }
  48976. protected function describeInputOption(InputOption $option, array $options = array())
  48977. {
  48978. $this->writeData($this->getInputOptionData($option), $options);
  48979. }
  48980. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  48981. {
  48982. $this->writeData($this->getInputDefinitionData($definition), $options);
  48983. }
  48984. protected function describeCommand(Command $command, array $options = array())
  48985. {
  48986. $this->writeData($this->getCommandData($command), $options);
  48987. }
  48988. protected function describeApplication(Application $application, array $options = array())
  48989. {
  48990. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  48991. $description = new ApplicationDescription($application, $describedNamespace);
  48992. $commands = array();
  48993. foreach ($description->getCommands() as $command) {
  48994. $commands[] = $this->getCommandData($command);
  48995. }
  48996. $data = $describedNamespace
  48997. ? array('commands' => $commands, 'namespace' => $describedNamespace)
  48998. : array('commands' => $commands, 'namespaces' => array_values($description->getNamespaces()));
  48999. $this->writeData($data, $options);
  49000. }
  49001. private function writeData(array $data, array $options)
  49002. {
  49003. $this->write(json_encode($data, isset($options['json_encoding']) ? $options['json_encoding'] : 0));
  49004. }
  49005. private function getInputArgumentData(InputArgument $argument)
  49006. {
  49007. return array(
  49008. 'name' => $argument->getName(),
  49009. 'is_required' => $argument->isRequired(),
  49010. 'is_array' => $argument->isArray(),
  49011. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
  49012. 'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
  49013. );
  49014. }
  49015. private function getInputOptionData(InputOption $option)
  49016. {
  49017. return array(
  49018. 'name' => '--'.$option->getName(),
  49019. 'shortcut' => $option->getShortcut() ? '-'.str_replace('|', '|-', $option->getShortcut()) : '',
  49020. 'accept_value' => $option->acceptValue(),
  49021. 'is_value_required' => $option->isValueRequired(),
  49022. 'is_multiple' => $option->isArray(),
  49023. 'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
  49024. 'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
  49025. );
  49026. }
  49027. private function getInputDefinitionData(InputDefinition $definition)
  49028. {
  49029. $inputArguments = array();
  49030. foreach ($definition->getArguments() as $name => $argument) {
  49031. $inputArguments[$name] = $this->getInputArgumentData($argument);
  49032. }
  49033. $inputOptions = array();
  49034. foreach ($definition->getOptions() as $name => $option) {
  49035. $inputOptions[$name] = $this->getInputOptionData($option);
  49036. }
  49037. return array('arguments' => $inputArguments, 'options' => $inputOptions);
  49038. }
  49039. private function getCommandData(Command $command)
  49040. {
  49041. $command->getSynopsis();
  49042. $command->mergeApplicationDefinition(false);
  49043. return array(
  49044. 'name' => $command->getName(),
  49045. 'usage' => array_merge(array($command->getSynopsis()), $command->getUsages(), $command->getAliases()),
  49046. 'description' => $command->getDescription(),
  49047. 'help' => $command->getProcessedHelp(),
  49048. 'definition' => $this->getInputDefinitionData($command->getNativeDefinition()),
  49049. );
  49050. }
  49051. }
  49052. <?php
  49053. namespace Symfony\Component\Console\Descriptor;
  49054. use Symfony\Component\Console\Application;
  49055. use Symfony\Component\Console\Command\Command;
  49056. use Symfony\Component\Console\Helper\Helper;
  49057. use Symfony\Component\Console\Input\InputArgument;
  49058. use Symfony\Component\Console\Input\InputDefinition;
  49059. use Symfony\Component\Console\Input\InputOption;
  49060. class MarkdownDescriptor extends Descriptor
  49061. {
  49062. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49063. {
  49064. $this->write(
  49065. '**'.$argument->getName().':**'."\n\n"
  49066. .'* Name: '.($argument->getName() ?: '<none>')."\n"
  49067. .'* Is required: '.($argument->isRequired() ? 'yes' : 'no')."\n"
  49068. .'* Is array: '.($argument->isArray() ? 'yes' : 'no')."\n"
  49069. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $argument->getDescription() ?: '<none>')."\n"
  49070. .'* Default: `'.str_replace("\n", '', var_export($argument->getDefault(), true)).'`'
  49071. );
  49072. }
  49073. protected function describeInputOption(InputOption $option, array $options = array())
  49074. {
  49075. $this->write(
  49076. '**'.$option->getName().':**'."\n\n"
  49077. .'* Name: `--'.$option->getName().'`'."\n"
  49078. .'* Shortcut: '.($option->getShortcut() ? '`-'.str_replace('|', '|-', $option->getShortcut()).'`' : '<none>')."\n"
  49079. .'* Accept value: '.($option->acceptValue() ? 'yes' : 'no')."\n"
  49080. .'* Is value required: '.($option->isValueRequired() ? 'yes' : 'no')."\n"
  49081. .'* Is multiple: '.($option->isArray() ? 'yes' : 'no')."\n"
  49082. .'* Description: '.preg_replace('/\s*[\r\n]\s*/', "\n ", $option->getDescription() ?: '<none>')."\n"
  49083. .'* Default: `'.str_replace("\n", '', var_export($option->getDefault(), true)).'`'
  49084. );
  49085. }
  49086. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49087. {
  49088. if ($showArguments = \count($definition->getArguments()) > 0) {
  49089. $this->write('### Arguments:');
  49090. foreach ($definition->getArguments() as $argument) {
  49091. $this->write("\n\n");
  49092. $this->write($this->describeInputArgument($argument));
  49093. }
  49094. }
  49095. if (\count($definition->getOptions()) > 0) {
  49096. if ($showArguments) {
  49097. $this->write("\n\n");
  49098. }
  49099. $this->write('### Options:');
  49100. foreach ($definition->getOptions() as $option) {
  49101. $this->write("\n\n");
  49102. $this->write($this->describeInputOption($option));
  49103. }
  49104. }
  49105. }
  49106. protected function describeCommand(Command $command, array $options = array())
  49107. {
  49108. $command->getSynopsis();
  49109. $command->mergeApplicationDefinition(false);
  49110. $this->write(
  49111. $command->getName()."\n"
  49112. .str_repeat('-', Helper::strlen($command->getName()))."\n\n"
  49113. .'* Description: '.($command->getDescription() ?: '<none>')."\n"
  49114. .'* Usage:'."\n\n"
  49115. .array_reduce(array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()), function ($carry, $usage) {
  49116. return $carry.' * `'.$usage.'`'."\n";
  49117. })
  49118. );
  49119. if ($help = $command->getProcessedHelp()) {
  49120. $this->write("\n");
  49121. $this->write($help);
  49122. }
  49123. if ($command->getNativeDefinition()) {
  49124. $this->write("\n\n");
  49125. $this->describeInputDefinition($command->getNativeDefinition());
  49126. }
  49127. }
  49128. protected function describeApplication(Application $application, array $options = array())
  49129. {
  49130. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  49131. $description = new ApplicationDescription($application, $describedNamespace);
  49132. $this->write($application->getName()."\n".str_repeat('=', Helper::strlen($application->getName())));
  49133. foreach ($description->getNamespaces() as $namespace) {
  49134. if (ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  49135. $this->write("\n\n");
  49136. $this->write('**'.$namespace['id'].':**');
  49137. }
  49138. $this->write("\n\n");
  49139. $this->write(implode("\n", array_map(function ($commandName) {
  49140. return '* '.$commandName;
  49141. }, $namespace['commands'])));
  49142. }
  49143. foreach ($description->getCommands() as $command) {
  49144. $this->write("\n\n");
  49145. $this->write($this->describeCommand($command));
  49146. }
  49147. }
  49148. }
  49149. <?php
  49150. namespace Symfony\Component\Console\Descriptor;
  49151. use Symfony\Component\Console\Application;
  49152. use Symfony\Component\Console\Command\Command;
  49153. use Symfony\Component\Console\Formatter\OutputFormatter;
  49154. use Symfony\Component\Console\Helper\Helper;
  49155. use Symfony\Component\Console\Input\InputArgument;
  49156. use Symfony\Component\Console\Input\InputDefinition;
  49157. use Symfony\Component\Console\Input\InputOption;
  49158. class TextDescriptor extends Descriptor
  49159. {
  49160. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49161. {
  49162. if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
  49163. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
  49164. } else {
  49165. $default = '';
  49166. }
  49167. $totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName());
  49168. $spacingWidth = $totalWidth - \strlen($argument->getName());
  49169. $this->writeText(sprintf(' <info>%s</info> %s%s%s',
  49170. $argument->getName(),
  49171. str_repeat(' ', $spacingWidth),
  49172. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $argument->getDescription()),
  49173. $default
  49174. ), $options);
  49175. }
  49176. protected function describeInputOption(InputOption $option, array $options = array())
  49177. {
  49178. if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
  49179. $default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
  49180. } else {
  49181. $default = '';
  49182. }
  49183. $value = '';
  49184. if ($option->acceptValue()) {
  49185. $value = '='.strtoupper($option->getName());
  49186. if ($option->isValueOptional()) {
  49187. $value = '['.$value.']';
  49188. }
  49189. }
  49190. $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option));
  49191. $synopsis = sprintf('%s%s',
  49192. $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ',
  49193. sprintf('--%s%s', $option->getName(), $value)
  49194. );
  49195. $spacingWidth = $totalWidth - Helper::strlen($synopsis);
  49196. $this->writeText(sprintf(' <info>%s</info> %s%s%s%s',
  49197. $synopsis,
  49198. str_repeat(' ', $spacingWidth),
  49199. preg_replace('/\s*[\r\n]\s*/', "\n".str_repeat(' ', $totalWidth + 4), $option->getDescription()),
  49200. $default,
  49201. $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''
  49202. ), $options);
  49203. }
  49204. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49205. {
  49206. $totalWidth = $this->calculateTotalWidthForOptions($definition->getOptions());
  49207. foreach ($definition->getArguments() as $argument) {
  49208. $totalWidth = max($totalWidth, Helper::strlen($argument->getName()));
  49209. }
  49210. if ($definition->getArguments()) {
  49211. $this->writeText('<comment>Arguments:</comment>', $options);
  49212. $this->writeText("\n");
  49213. foreach ($definition->getArguments() as $argument) {
  49214. $this->describeInputArgument($argument, array_merge($options, array('total_width' => $totalWidth)));
  49215. $this->writeText("\n");
  49216. }
  49217. }
  49218. if ($definition->getArguments() && $definition->getOptions()) {
  49219. $this->writeText("\n");
  49220. }
  49221. if ($definition->getOptions()) {
  49222. $laterOptions = array();
  49223. $this->writeText('<comment>Options:</comment>', $options);
  49224. foreach ($definition->getOptions() as $option) {
  49225. if (\strlen($option->getShortcut()) > 1) {
  49226. $laterOptions[] = $option;
  49227. continue;
  49228. }
  49229. $this->writeText("\n");
  49230. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  49231. }
  49232. foreach ($laterOptions as $option) {
  49233. $this->writeText("\n");
  49234. $this->describeInputOption($option, array_merge($options, array('total_width' => $totalWidth)));
  49235. }
  49236. }
  49237. }
  49238. protected function describeCommand(Command $command, array $options = array())
  49239. {
  49240. $command->getSynopsis(true);
  49241. $command->getSynopsis(false);
  49242. $command->mergeApplicationDefinition(false);
  49243. $this->writeText('<comment>Usage:</comment>', $options);
  49244. foreach (array_merge(array($command->getSynopsis(true)), $command->getAliases(), $command->getUsages()) as $usage) {
  49245. $this->writeText("\n");
  49246. $this->writeText(' '.OutputFormatter::escape($usage), $options);
  49247. }
  49248. $this->writeText("\n");
  49249. $definition = $command->getNativeDefinition();
  49250. if ($definition->getOptions() || $definition->getArguments()) {
  49251. $this->writeText("\n");
  49252. $this->describeInputDefinition($definition, $options);
  49253. $this->writeText("\n");
  49254. }
  49255. if ($help = $command->getProcessedHelp()) {
  49256. $this->writeText("\n");
  49257. $this->writeText('<comment>Help:</comment>', $options);
  49258. $this->writeText("\n");
  49259. $this->writeText(' '.str_replace("\n", "\n ", $help), $options);
  49260. $this->writeText("\n");
  49261. }
  49262. }
  49263. protected function describeApplication(Application $application, array $options = array())
  49264. {
  49265. $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null;
  49266. $description = new ApplicationDescription($application, $describedNamespace);
  49267. if (isset($options['raw_text']) && $options['raw_text']) {
  49268. $width = $this->getColumnWidth($description->getCommands());
  49269. foreach ($description->getCommands() as $command) {
  49270. $this->writeText(sprintf("%-{$width}s %s", $command->getName(), $command->getDescription()), $options);
  49271. $this->writeText("\n");
  49272. }
  49273. } else {
  49274. if ('' != $help = $application->getHelp()) {
  49275. $this->writeText("$help\n\n", $options);
  49276. }
  49277. $this->writeText("<comment>Usage:</comment>\n", $options);
  49278. $this->writeText(" command [options] [arguments]\n\n", $options);
  49279. $this->describeInputDefinition(new InputDefinition($application->getDefinition()->getOptions()), $options);
  49280. $this->writeText("\n");
  49281. $this->writeText("\n");
  49282. $width = $this->getColumnWidth($description->getCommands());
  49283. if ($describedNamespace) {
  49284. $this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);
  49285. } else {
  49286. $this->writeText('<comment>Available commands:</comment>', $options);
  49287. }
  49288. foreach ($description->getNamespaces() as $namespace) {
  49289. if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) {
  49290. $this->writeText("\n");
  49291. $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options);
  49292. }
  49293. foreach ($namespace['commands'] as $name) {
  49294. $this->writeText("\n");
  49295. $spacingWidth = $width - Helper::strlen($name);
  49296. $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $description->getCommand($name)->getDescription()), $options);
  49297. }
  49298. }
  49299. $this->writeText("\n");
  49300. }
  49301. }
  49302. private function writeText($content, array $options = array())
  49303. {
  49304. $this->write(
  49305. isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content,
  49306. isset($options['raw_output']) ? !$options['raw_output'] : true
  49307. );
  49308. }
  49309. private function formatDefaultValue($default)
  49310. {
  49311. if (INF === $default) {
  49312. return 'INF';
  49313. }
  49314. if (\is_string($default)) {
  49315. $default = OutputFormatter::escape($default);
  49316. } elseif (\is_array($default)) {
  49317. foreach ($default as $key => $value) {
  49318. if (\is_string($value)) {
  49319. $default[$key] = OutputFormatter::escape($value);
  49320. }
  49321. }
  49322. }
  49323. if (\PHP_VERSION_ID < 50400) {
  49324. return str_replace(array('\/', '\\\\'), array('/', '\\'), json_encode($default));
  49325. }
  49326. return str_replace('\\\\', '\\', json_encode($default, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
  49327. }
  49328. private function getColumnWidth(array $commands)
  49329. {
  49330. $widths = array();
  49331. foreach ($commands as $command) {
  49332. $widths[] = Helper::strlen($command->getName());
  49333. foreach ($command->getAliases() as $alias) {
  49334. $widths[] = Helper::strlen($alias);
  49335. }
  49336. }
  49337. return max($widths) + 2;
  49338. }
  49339. private function calculateTotalWidthForOptions(array $options)
  49340. {
  49341. $totalWidth = 0;
  49342. foreach ($options as $option) {
  49343. $nameLength = 1 + max(\strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
  49344. if ($option->acceptValue()) {
  49345. $valueLength = 1 + Helper::strlen($option->getName());
  49346. $valueLength += $option->isValueOptional() ? 2 : 0;
  49347. $nameLength += $valueLength;
  49348. }
  49349. $totalWidth = max($totalWidth, $nameLength);
  49350. }
  49351. return $totalWidth;
  49352. }
  49353. }
  49354. <?php
  49355. namespace Symfony\Component\Console\Descriptor;
  49356. use Symfony\Component\Console\Application;
  49357. use Symfony\Component\Console\Command\Command;
  49358. use Symfony\Component\Console\Input\InputArgument;
  49359. use Symfony\Component\Console\Input\InputDefinition;
  49360. use Symfony\Component\Console\Input\InputOption;
  49361. class XmlDescriptor extends Descriptor
  49362. {
  49363. public function getInputDefinitionDocument(InputDefinition $definition)
  49364. {
  49365. $dom = new \DOMDocument('1.0', 'UTF-8');
  49366. $dom->appendChild($definitionXML = $dom->createElement('definition'));
  49367. $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
  49368. foreach ($definition->getArguments() as $argument) {
  49369. $this->appendDocument($argumentsXML, $this->getInputArgumentDocument($argument));
  49370. }
  49371. $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
  49372. foreach ($definition->getOptions() as $option) {
  49373. $this->appendDocument($optionsXML, $this->getInputOptionDocument($option));
  49374. }
  49375. return $dom;
  49376. }
  49377. public function getCommandDocument(Command $command)
  49378. {
  49379. $dom = new \DOMDocument('1.0', 'UTF-8');
  49380. $dom->appendChild($commandXML = $dom->createElement('command'));
  49381. $command->getSynopsis();
  49382. $command->mergeApplicationDefinition(false);
  49383. $commandXML->setAttribute('id', $command->getName());
  49384. $commandXML->setAttribute('name', $command->getName());
  49385. $commandXML->appendChild($usagesXML = $dom->createElement('usages'));
  49386. foreach (array_merge(array($command->getSynopsis()), $command->getAliases(), $command->getUsages()) as $usage) {
  49387. $usagesXML->appendChild($dom->createElement('usage', $usage));
  49388. }
  49389. $commandXML->appendChild($descriptionXML = $dom->createElement('description'));
  49390. $descriptionXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getDescription())));
  49391. $commandXML->appendChild($helpXML = $dom->createElement('help'));
  49392. $helpXML->appendChild($dom->createTextNode(str_replace("\n", "\n ", $command->getProcessedHelp())));
  49393. $definitionXML = $this->getInputDefinitionDocument($command->getNativeDefinition());
  49394. $this->appendDocument($commandXML, $definitionXML->getElementsByTagName('definition')->item(0));
  49395. return $dom;
  49396. }
  49397. public function getApplicationDocument(Application $application, $namespace = null)
  49398. {
  49399. $dom = new \DOMDocument('1.0', 'UTF-8');
  49400. $dom->appendChild($rootXml = $dom->createElement('symfony'));
  49401. if ('UNKNOWN' !== $application->getName()) {
  49402. $rootXml->setAttribute('name', $application->getName());
  49403. if ('UNKNOWN' !== $application->getVersion()) {
  49404. $rootXml->setAttribute('version', $application->getVersion());
  49405. }
  49406. }
  49407. $rootXml->appendChild($commandsXML = $dom->createElement('commands'));
  49408. $description = new ApplicationDescription($application, $namespace);
  49409. if ($namespace) {
  49410. $commandsXML->setAttribute('namespace', $namespace);
  49411. }
  49412. foreach ($description->getCommands() as $command) {
  49413. $this->appendDocument($commandsXML, $this->getCommandDocument($command));
  49414. }
  49415. if (!$namespace) {
  49416. $rootXml->appendChild($namespacesXML = $dom->createElement('namespaces'));
  49417. foreach ($description->getNamespaces() as $namespaceDescription) {
  49418. $namespacesXML->appendChild($namespaceArrayXML = $dom->createElement('namespace'));
  49419. $namespaceArrayXML->setAttribute('id', $namespaceDescription['id']);
  49420. foreach ($namespaceDescription['commands'] as $name) {
  49421. $namespaceArrayXML->appendChild($commandXML = $dom->createElement('command'));
  49422. $commandXML->appendChild($dom->createTextNode($name));
  49423. }
  49424. }
  49425. }
  49426. return $dom;
  49427. }
  49428. protected function describeInputArgument(InputArgument $argument, array $options = array())
  49429. {
  49430. $this->writeDocument($this->getInputArgumentDocument($argument));
  49431. }
  49432. protected function describeInputOption(InputOption $option, array $options = array())
  49433. {
  49434. $this->writeDocument($this->getInputOptionDocument($option));
  49435. }
  49436. protected function describeInputDefinition(InputDefinition $definition, array $options = array())
  49437. {
  49438. $this->writeDocument($this->getInputDefinitionDocument($definition));
  49439. }
  49440. protected function describeCommand(Command $command, array $options = array())
  49441. {
  49442. $this->writeDocument($this->getCommandDocument($command));
  49443. }
  49444. protected function describeApplication(Application $application, array $options = array())
  49445. {
  49446. $this->writeDocument($this->getApplicationDocument($application, isset($options['namespace']) ? $options['namespace'] : null));
  49447. }
  49448. private function appendDocument(\DOMNode $parentNode, \DOMNode $importedParent)
  49449. {
  49450. foreach ($importedParent->childNodes as $childNode) {
  49451. $parentNode->appendChild($parentNode->ownerDocument->importNode($childNode, true));
  49452. }
  49453. }
  49454. private function writeDocument(\DOMDocument $dom)
  49455. {
  49456. $dom->formatOutput = true;
  49457. $this->write($dom->saveXML());
  49458. }
  49459. private function getInputArgumentDocument(InputArgument $argument)
  49460. {
  49461. $dom = new \DOMDocument('1.0', 'UTF-8');
  49462. $dom->appendChild($objectXML = $dom->createElement('argument'));
  49463. $objectXML->setAttribute('name', $argument->getName());
  49464. $objectXML->setAttribute('is_required', $argument->isRequired() ? 1 : 0);
  49465. $objectXML->setAttribute('is_array', $argument->isArray() ? 1 : 0);
  49466. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  49467. $descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
  49468. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  49469. $defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
  49470. foreach ($defaults as $default) {
  49471. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  49472. $defaultXML->appendChild($dom->createTextNode($default));
  49473. }
  49474. return $dom;
  49475. }
  49476. private function getInputOptionDocument(InputOption $option)
  49477. {
  49478. $dom = new \DOMDocument('1.0', 'UTF-8');
  49479. $dom->appendChild($objectXML = $dom->createElement('option'));
  49480. $objectXML->setAttribute('name', '--'.$option->getName());
  49481. $pos = strpos($option->getShortcut(), '|');
  49482. if (false !== $pos) {
  49483. $objectXML->setAttribute('shortcut', '-'.substr($option->getShortcut(), 0, $pos));
  49484. $objectXML->setAttribute('shortcuts', '-'.str_replace('|', '|-', $option->getShortcut()));
  49485. } else {
  49486. $objectXML->setAttribute('shortcut', $option->getShortcut() ? '-'.$option->getShortcut() : '');
  49487. }
  49488. $objectXML->setAttribute('accept_value', $option->acceptValue() ? 1 : 0);
  49489. $objectXML->setAttribute('is_value_required', $option->isValueRequired() ? 1 : 0);
  49490. $objectXML->setAttribute('is_multiple', $option->isArray() ? 1 : 0);
  49491. $objectXML->appendChild($descriptionXML = $dom->createElement('description'));
  49492. $descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
  49493. if ($option->acceptValue()) {
  49494. $defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
  49495. $objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
  49496. if (!empty($defaults)) {
  49497. foreach ($defaults as $default) {
  49498. $defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
  49499. $defaultXML->appendChild($dom->createTextNode($default));
  49500. }
  49501. }
  49502. }
  49503. return $dom;
  49504. }
  49505. }
  49506. <?php
  49507. namespace Symfony\Component\Console\Event;
  49508. class ConsoleCommandEvent extends ConsoleEvent
  49509. {
  49510. const RETURN_CODE_DISABLED = 113;
  49511. private $commandShouldRun = true;
  49512. public function disableCommand()
  49513. {
  49514. return $this->commandShouldRun = false;
  49515. }
  49516. public function enableCommand()
  49517. {
  49518. return $this->commandShouldRun = true;
  49519. }
  49520. public function commandShouldRun()
  49521. {
  49522. return $this->commandShouldRun;
  49523. }
  49524. }
  49525. <?php
  49526. namespace Symfony\Component\Console\Event;
  49527. use Symfony\Component\Console\Command\Command;
  49528. use Symfony\Component\Console\Input\InputInterface;
  49529. use Symfony\Component\Console\Output\OutputInterface;
  49530. use Symfony\Component\EventDispatcher\Event;
  49531. class ConsoleEvent extends Event
  49532. {
  49533. protected $command;
  49534. private $input;
  49535. private $output;
  49536. public function __construct(Command $command, InputInterface $input, OutputInterface $output)
  49537. {
  49538. $this->command = $command;
  49539. $this->input = $input;
  49540. $this->output = $output;
  49541. }
  49542. public function getCommand()
  49543. {
  49544. return $this->command;
  49545. }
  49546. public function getInput()
  49547. {
  49548. return $this->input;
  49549. }
  49550. public function getOutput()
  49551. {
  49552. return $this->output;
  49553. }
  49554. }
  49555. <?php
  49556. namespace Symfony\Component\Console\Event;
  49557. use Symfony\Component\Console\Command\Command;
  49558. use Symfony\Component\Console\Input\InputInterface;
  49559. use Symfony\Component\Console\Output\OutputInterface;
  49560. class ConsoleExceptionEvent extends ConsoleEvent
  49561. {
  49562. private $exception;
  49563. private $exitCode;
  49564. public function __construct(Command $command, InputInterface $input, OutputInterface $output, \Exception $exception, $exitCode)
  49565. {
  49566. parent::__construct($command, $input, $output);
  49567. $this->setException($exception);
  49568. $this->exitCode = (int) $exitCode;
  49569. }
  49570. public function getException()
  49571. {
  49572. return $this->exception;
  49573. }
  49574. public function setException(\Exception $exception)
  49575. {
  49576. $this->exception = $exception;
  49577. }
  49578. public function getExitCode()
  49579. {
  49580. return $this->exitCode;
  49581. }
  49582. }
  49583. <?php
  49584. namespace Symfony\Component\Console\Event;
  49585. use Symfony\Component\Console\Command\Command;
  49586. use Symfony\Component\Console\Input\InputInterface;
  49587. use Symfony\Component\Console\Output\OutputInterface;
  49588. class ConsoleTerminateEvent extends ConsoleEvent
  49589. {
  49590. private $exitCode;
  49591. public function __construct(Command $command, InputInterface $input, OutputInterface $output, $exitCode)
  49592. {
  49593. parent::__construct($command, $input, $output);
  49594. $this->setExitCode($exitCode);
  49595. }
  49596. public function setExitCode($exitCode)
  49597. {
  49598. $this->exitCode = (int) $exitCode;
  49599. }
  49600. public function getExitCode()
  49601. {
  49602. return $this->exitCode;
  49603. }
  49604. }
  49605. <?php
  49606. namespace Symfony\Component\Console\Exception;
  49607. class CommandNotFoundException extends \InvalidArgumentException implements ExceptionInterface
  49608. {
  49609. private $alternatives;
  49610. public function __construct($message, array $alternatives = array(), $code = 0, \Exception $previous = null)
  49611. {
  49612. parent::__construct($message, $code, $previous);
  49613. $this->alternatives = $alternatives;
  49614. }
  49615. public function getAlternatives()
  49616. {
  49617. return $this->alternatives;
  49618. }
  49619. }
  49620. <?php
  49621. namespace Symfony\Component\Console\Exception;
  49622. interface ExceptionInterface
  49623. {
  49624. }
  49625. <?php
  49626. namespace Symfony\Component\Console\Exception;
  49627. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  49628. {
  49629. }
  49630. <?php
  49631. namespace Symfony\Component\Console\Exception;
  49632. class InvalidOptionException extends \InvalidArgumentException implements ExceptionInterface
  49633. {
  49634. }
  49635. <?php
  49636. namespace Symfony\Component\Console\Exception;
  49637. class LogicException extends \LogicException implements ExceptionInterface
  49638. {
  49639. }
  49640. <?php
  49641. namespace Symfony\Component\Console\Exception;
  49642. class RuntimeException extends \RuntimeException implements ExceptionInterface
  49643. {
  49644. }
  49645. <?php
  49646. namespace Symfony\Component\Console\Formatter;
  49647. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49648. class OutputFormatter implements OutputFormatterInterface
  49649. {
  49650. private $decorated;
  49651. private $styles = array();
  49652. private $styleStack;
  49653. public static function escape($text)
  49654. {
  49655. $text = preg_replace('/([^\\\\]?)</', '$1\\<', $text);
  49656. return self::escapeTrailingBackslash($text);
  49657. }
  49658. public static function escapeTrailingBackslash($text)
  49659. {
  49660. if ('\\' === substr($text, -1)) {
  49661. $len = \strlen($text);
  49662. $text = rtrim($text, '\\');
  49663. $text = str_replace("\0", '', $text);
  49664. $text .= str_repeat("\0", $len - \strlen($text));
  49665. }
  49666. return $text;
  49667. }
  49668. public function __construct($decorated = false, array $styles = array())
  49669. {
  49670. $this->decorated = (bool) $decorated;
  49671. $this->setStyle('error', new OutputFormatterStyle('white', 'red'));
  49672. $this->setStyle('info', new OutputFormatterStyle('green'));
  49673. $this->setStyle('comment', new OutputFormatterStyle('yellow'));
  49674. $this->setStyle('question', new OutputFormatterStyle('black', 'cyan'));
  49675. foreach ($styles as $name => $style) {
  49676. $this->setStyle($name, $style);
  49677. }
  49678. $this->styleStack = new OutputFormatterStyleStack();
  49679. }
  49680. public function setDecorated($decorated)
  49681. {
  49682. $this->decorated = (bool) $decorated;
  49683. }
  49684. public function isDecorated()
  49685. {
  49686. return $this->decorated;
  49687. }
  49688. public function setStyle($name, OutputFormatterStyleInterface $style)
  49689. {
  49690. $this->styles[strtolower($name)] = $style;
  49691. }
  49692. public function hasStyle($name)
  49693. {
  49694. return isset($this->styles[strtolower($name)]);
  49695. }
  49696. public function getStyle($name)
  49697. {
  49698. if (!$this->hasStyle($name)) {
  49699. throw new InvalidArgumentException(sprintf('Undefined style: %s', $name));
  49700. }
  49701. return $this->styles[strtolower($name)];
  49702. }
  49703. public function format($message)
  49704. {
  49705. $message = (string) $message;
  49706. $offset = 0;
  49707. $output = '';
  49708. $tagRegex = '[a-z][a-z0-9_=;-]*+';
  49709. preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE);
  49710. foreach ($matches[0] as $i => $match) {
  49711. $pos = $match[1];
  49712. $text = $match[0];
  49713. if (0 != $pos && '\\' == $message[$pos - 1]) {
  49714. continue;
  49715. }
  49716. $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
  49717. $offset = $pos + \strlen($text);
  49718. if ($open = '/' != $text[1]) {
  49719. $tag = $matches[1][$i][0];
  49720. } else {
  49721. $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : '';
  49722. }
  49723. if (!$open && !$tag) {
  49724. $this->styleStack->pop();
  49725. } elseif (false === $style = $this->createStyleFromString(strtolower($tag))) {
  49726. $output .= $this->applyCurrentStyle($text);
  49727. } elseif ($open) {
  49728. $this->styleStack->push($style);
  49729. } else {
  49730. $this->styleStack->pop($style);
  49731. }
  49732. }
  49733. $output .= $this->applyCurrentStyle(substr($message, $offset));
  49734. if (false !== strpos($output, "\0")) {
  49735. return strtr($output, array("\0" => '\\', '\\<' => '<'));
  49736. }
  49737. return str_replace('\\<', '<', $output);
  49738. }
  49739. public function getStyleStack()
  49740. {
  49741. return $this->styleStack;
  49742. }
  49743. private function createStyleFromString($string)
  49744. {
  49745. if (isset($this->styles[$string])) {
  49746. return $this->styles[$string];
  49747. }
  49748. if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {
  49749. return false;
  49750. }
  49751. $style = new OutputFormatterStyle();
  49752. foreach ($matches as $match) {
  49753. array_shift($match);
  49754. if ('fg' == $match[0]) {
  49755. $style->setForeground($match[1]);
  49756. } elseif ('bg' == $match[0]) {
  49757. $style->setBackground($match[1]);
  49758. } else {
  49759. try {
  49760. $style->setOption($match[1]);
  49761. } catch (\InvalidArgumentException $e) {
  49762. return false;
  49763. }
  49764. }
  49765. }
  49766. return $style;
  49767. }
  49768. private function applyCurrentStyle($text)
  49769. {
  49770. return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
  49771. }
  49772. }
  49773. <?php
  49774. namespace Symfony\Component\Console\Formatter;
  49775. interface OutputFormatterInterface
  49776. {
  49777. public function setDecorated($decorated);
  49778. public function isDecorated();
  49779. public function setStyle($name, OutputFormatterStyleInterface $style);
  49780. public function hasStyle($name);
  49781. public function getStyle($name);
  49782. public function format($message);
  49783. }
  49784. <?php
  49785. namespace Symfony\Component\Console\Formatter;
  49786. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49787. class OutputFormatterStyle implements OutputFormatterStyleInterface
  49788. {
  49789. private static $availableForegroundColors = array(
  49790. 'black' => array('set' => 30, 'unset' => 39),
  49791. 'red' => array('set' => 31, 'unset' => 39),
  49792. 'green' => array('set' => 32, 'unset' => 39),
  49793. 'yellow' => array('set' => 33, 'unset' => 39),
  49794. 'blue' => array('set' => 34, 'unset' => 39),
  49795. 'magenta' => array('set' => 35, 'unset' => 39),
  49796. 'cyan' => array('set' => 36, 'unset' => 39),
  49797. 'white' => array('set' => 37, 'unset' => 39),
  49798. 'default' => array('set' => 39, 'unset' => 39),
  49799. );
  49800. private static $availableBackgroundColors = array(
  49801. 'black' => array('set' => 40, 'unset' => 49),
  49802. 'red' => array('set' => 41, 'unset' => 49),
  49803. 'green' => array('set' => 42, 'unset' => 49),
  49804. 'yellow' => array('set' => 43, 'unset' => 49),
  49805. 'blue' => array('set' => 44, 'unset' => 49),
  49806. 'magenta' => array('set' => 45, 'unset' => 49),
  49807. 'cyan' => array('set' => 46, 'unset' => 49),
  49808. 'white' => array('set' => 47, 'unset' => 49),
  49809. 'default' => array('set' => 49, 'unset' => 49),
  49810. );
  49811. private static $availableOptions = array(
  49812. 'bold' => array('set' => 1, 'unset' => 22),
  49813. 'underscore' => array('set' => 4, 'unset' => 24),
  49814. 'blink' => array('set' => 5, 'unset' => 25),
  49815. 'reverse' => array('set' => 7, 'unset' => 27),
  49816. 'conceal' => array('set' => 8, 'unset' => 28),
  49817. );
  49818. private $foreground;
  49819. private $background;
  49820. private $options = array();
  49821. public function __construct($foreground = null, $background = null, array $options = array())
  49822. {
  49823. if (null !== $foreground) {
  49824. $this->setForeground($foreground);
  49825. }
  49826. if (null !== $background) {
  49827. $this->setBackground($background);
  49828. }
  49829. if (\count($options)) {
  49830. $this->setOptions($options);
  49831. }
  49832. }
  49833. public function setForeground($color = null)
  49834. {
  49835. if (null === $color) {
  49836. $this->foreground = null;
  49837. return;
  49838. }
  49839. if (!isset(static::$availableForegroundColors[$color])) {
  49840. throw new InvalidArgumentException(sprintf('Invalid foreground color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableForegroundColors))));
  49841. }
  49842. $this->foreground = static::$availableForegroundColors[$color];
  49843. }
  49844. public function setBackground($color = null)
  49845. {
  49846. if (null === $color) {
  49847. $this->background = null;
  49848. return;
  49849. }
  49850. if (!isset(static::$availableBackgroundColors[$color])) {
  49851. throw new InvalidArgumentException(sprintf('Invalid background color specified: "%s". Expected one of (%s)', $color, implode(', ', array_keys(static::$availableBackgroundColors))));
  49852. }
  49853. $this->background = static::$availableBackgroundColors[$color];
  49854. }
  49855. public function setOption($option)
  49856. {
  49857. if (!isset(static::$availableOptions[$option])) {
  49858. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  49859. }
  49860. if (!\in_array(static::$availableOptions[$option], $this->options)) {
  49861. $this->options[] = static::$availableOptions[$option];
  49862. }
  49863. }
  49864. public function unsetOption($option)
  49865. {
  49866. if (!isset(static::$availableOptions[$option])) {
  49867. throw new InvalidArgumentException(sprintf('Invalid option specified: "%s". Expected one of (%s)', $option, implode(', ', array_keys(static::$availableOptions))));
  49868. }
  49869. $pos = array_search(static::$availableOptions[$option], $this->options);
  49870. if (false !== $pos) {
  49871. unset($this->options[$pos]);
  49872. }
  49873. }
  49874. public function setOptions(array $options)
  49875. {
  49876. $this->options = array();
  49877. foreach ($options as $option) {
  49878. $this->setOption($option);
  49879. }
  49880. }
  49881. public function apply($text)
  49882. {
  49883. $setCodes = array();
  49884. $unsetCodes = array();
  49885. if (null !== $this->foreground) {
  49886. $setCodes[] = $this->foreground['set'];
  49887. $unsetCodes[] = $this->foreground['unset'];
  49888. }
  49889. if (null !== $this->background) {
  49890. $setCodes[] = $this->background['set'];
  49891. $unsetCodes[] = $this->background['unset'];
  49892. }
  49893. if (\count($this->options)) {
  49894. foreach ($this->options as $option) {
  49895. $setCodes[] = $option['set'];
  49896. $unsetCodes[] = $option['unset'];
  49897. }
  49898. }
  49899. if (0 === \count($setCodes)) {
  49900. return $text;
  49901. }
  49902. return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes));
  49903. }
  49904. }
  49905. <?php
  49906. namespace Symfony\Component\Console\Formatter;
  49907. interface OutputFormatterStyleInterface
  49908. {
  49909. public function setForeground($color = null);
  49910. public function setBackground($color = null);
  49911. public function setOption($option);
  49912. public function unsetOption($option);
  49913. public function setOptions(array $options);
  49914. public function apply($text);
  49915. }
  49916. <?php
  49917. namespace Symfony\Component\Console\Formatter;
  49918. use Symfony\Component\Console\Exception\InvalidArgumentException;
  49919. class OutputFormatterStyleStack
  49920. {
  49921. private $styles;
  49922. private $emptyStyle;
  49923. public function __construct(OutputFormatterStyleInterface $emptyStyle = null)
  49924. {
  49925. $this->emptyStyle = $emptyStyle ?: new OutputFormatterStyle();
  49926. $this->reset();
  49927. }
  49928. public function reset()
  49929. {
  49930. $this->styles = array();
  49931. }
  49932. public function push(OutputFormatterStyleInterface $style)
  49933. {
  49934. $this->styles[] = $style;
  49935. }
  49936. public function pop(OutputFormatterStyleInterface $style = null)
  49937. {
  49938. if (empty($this->styles)) {
  49939. return $this->emptyStyle;
  49940. }
  49941. if (null === $style) {
  49942. return array_pop($this->styles);
  49943. }
  49944. foreach (array_reverse($this->styles, true) as $index => $stackedStyle) {
  49945. if ($style->apply('') === $stackedStyle->apply('')) {
  49946. $this->styles = \array_slice($this->styles, 0, $index);
  49947. return $stackedStyle;
  49948. }
  49949. }
  49950. throw new InvalidArgumentException('Incorrectly nested style tag found.');
  49951. }
  49952. public function getCurrent()
  49953. {
  49954. if (empty($this->styles)) {
  49955. return $this->emptyStyle;
  49956. }
  49957. return $this->styles[\count($this->styles) - 1];
  49958. }
  49959. public function setEmptyStyle(OutputFormatterStyleInterface $emptyStyle)
  49960. {
  49961. $this->emptyStyle = $emptyStyle;
  49962. return $this;
  49963. }
  49964. public function getEmptyStyle()
  49965. {
  49966. return $this->emptyStyle;
  49967. }
  49968. }
  49969. <?php
  49970. namespace Symfony\Component\Console\Helper;
  49971. class DebugFormatterHelper extends Helper
  49972. {
  49973. private $colors = array('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default');
  49974. private $started = array();
  49975. private $count = -1;
  49976. public function start($id, $message, $prefix = 'RUN')
  49977. {
  49978. $this->started[$id] = array('border' => ++$this->count % \count($this->colors));
  49979. return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
  49980. }
  49981. public function progress($id, $buffer, $error = false, $prefix = 'OUT', $errorPrefix = 'ERR')
  49982. {
  49983. $message = '';
  49984. if ($error) {
  49985. if (isset($this->started[$id]['out'])) {
  49986. $message .= "\n";
  49987. unset($this->started[$id]['out']);
  49988. }
  49989. if (!isset($this->started[$id]['err'])) {
  49990. $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
  49991. $this->started[$id]['err'] = true;
  49992. }
  49993. $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
  49994. } else {
  49995. if (isset($this->started[$id]['err'])) {
  49996. $message .= "\n";
  49997. unset($this->started[$id]['err']);
  49998. }
  49999. if (!isset($this->started[$id]['out'])) {
  50000. $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
  50001. $this->started[$id]['out'] = true;
  50002. }
  50003. $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
  50004. }
  50005. return $message;
  50006. }
  50007. public function stop($id, $message, $successful, $prefix = 'RES')
  50008. {
  50009. $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
  50010. if ($successful) {
  50011. return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  50012. }
  50013. $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
  50014. unset($this->started[$id]['out'], $this->started[$id]['err']);
  50015. return $message;
  50016. }
  50017. private function getBorder($id)
  50018. {
  50019. return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
  50020. }
  50021. public function getName()
  50022. {
  50023. return 'debug_formatter';
  50024. }
  50025. }
  50026. <?php
  50027. namespace Symfony\Component\Console\Helper;
  50028. use Symfony\Component\Console\Descriptor\DescriptorInterface;
  50029. use Symfony\Component\Console\Descriptor\JsonDescriptor;
  50030. use Symfony\Component\Console\Descriptor\MarkdownDescriptor;
  50031. use Symfony\Component\Console\Descriptor\TextDescriptor;
  50032. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  50033. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50034. use Symfony\Component\Console\Output\OutputInterface;
  50035. class DescriptorHelper extends Helper
  50036. {
  50037. private $descriptors = array();
  50038. public function __construct()
  50039. {
  50040. $this
  50041. ->register('txt', new TextDescriptor())
  50042. ->register('xml', new XmlDescriptor())
  50043. ->register('json', new JsonDescriptor())
  50044. ->register('md', new MarkdownDescriptor())
  50045. ;
  50046. }
  50047. public function describe(OutputInterface $output, $object, array $options = array())
  50048. {
  50049. $options = array_merge(array(
  50050. 'raw_text' => false,
  50051. 'format' => 'txt',
  50052. ), $options);
  50053. if (!isset($this->descriptors[$options['format']])) {
  50054. throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format']));
  50055. }
  50056. $descriptor = $this->descriptors[$options['format']];
  50057. $descriptor->describe($output, $object, $options);
  50058. }
  50059. public function register($format, DescriptorInterface $descriptor)
  50060. {
  50061. $this->descriptors[$format] = $descriptor;
  50062. return $this;
  50063. }
  50064. public function getName()
  50065. {
  50066. return 'descriptor';
  50067. }
  50068. }
  50069. <?php
  50070. namespace Symfony\Component\Console\Helper;
  50071. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50072. use Symfony\Component\Console\Exception\RuntimeException;
  50073. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  50074. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50075. use Symfony\Component\Console\Output\OutputInterface;
  50076. class DialogHelper extends InputAwareHelper
  50077. {
  50078. private $inputStream;
  50079. private static $shell;
  50080. private static $stty;
  50081. public function __construct($triggerDeprecationError = true)
  50082. {
  50083. if ($triggerDeprecationError) {
  50084. @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);
  50085. }
  50086. }
  50087. public function select(OutputInterface $output, $question, $choices, $default = null, $attempts = false, $errorMessage = 'Value "%s" is invalid', $multiselect = false)
  50088. {
  50089. if ($output instanceof ConsoleOutputInterface) {
  50090. $output = $output->getErrorOutput();
  50091. }
  50092. $width = max(array_map('strlen', array_keys($choices)));
  50093. $messages = (array) $question;
  50094. foreach ($choices as $key => $value) {
  50095. $messages[] = sprintf(" [<info>%-{$width}s</info>] %s", $key, $value);
  50096. }
  50097. $output->writeln($messages);
  50098. $result = $this->askAndValidate($output, '> ', function ($picked) use ($choices, $errorMessage, $multiselect) {
  50099. $selectedChoices = str_replace(' ', '', $picked);
  50100. if ($multiselect) {
  50101. if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
  50102. throw new InvalidArgumentException(sprintf($errorMessage, $picked));
  50103. }
  50104. $selectedChoices = explode(',', $selectedChoices);
  50105. } else {
  50106. $selectedChoices = array($picked);
  50107. }
  50108. $multiselectChoices = array();
  50109. foreach ($selectedChoices as $value) {
  50110. if (empty($choices[$value])) {
  50111. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  50112. }
  50113. $multiselectChoices[] = $value;
  50114. }
  50115. if ($multiselect) {
  50116. return $multiselectChoices;
  50117. }
  50118. return $picked;
  50119. }, $attempts, $default);
  50120. return $result;
  50121. }
  50122. public function ask(OutputInterface $output, $question, $default = null, array $autocomplete = null)
  50123. {
  50124. if ($this->input && !$this->input->isInteractive()) {
  50125. return $default;
  50126. }
  50127. if ($output instanceof ConsoleOutputInterface) {
  50128. $output = $output->getErrorOutput();
  50129. }
  50130. $output->write($question);
  50131. $inputStream = $this->inputStream ?: STDIN;
  50132. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  50133. $ret = fgets($inputStream, 4096);
  50134. if (false === $ret) {
  50135. throw new RuntimeException('Aborted');
  50136. }
  50137. $ret = trim($ret);
  50138. } else {
  50139. $ret = '';
  50140. $i = 0;
  50141. $ofs = -1;
  50142. $matches = $autocomplete;
  50143. $numMatches = \count($matches);
  50144. $sttyMode = shell_exec('stty -g');
  50145. shell_exec('stty -icanon -echo');
  50146. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  50147. while (!feof($inputStream)) {
  50148. $c = fread($inputStream, 1);
  50149. if ("\177" === $c) {
  50150. if (0 === $numMatches && 0 !== $i) {
  50151. --$i;
  50152. $output->write("\033[1D");
  50153. }
  50154. if (0 === $i) {
  50155. $ofs = -1;
  50156. $matches = $autocomplete;
  50157. $numMatches = \count($matches);
  50158. } else {
  50159. $numMatches = 0;
  50160. }
  50161. $ret = substr($ret, 0, $i);
  50162. } elseif ("\033" === $c) {
  50163. $c .= fread($inputStream, 2);
  50164. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  50165. if ('A' === $c[2] && -1 === $ofs) {
  50166. $ofs = 0;
  50167. }
  50168. if (0 === $numMatches) {
  50169. continue;
  50170. }
  50171. $ofs += ('A' === $c[2]) ? -1 : 1;
  50172. $ofs = ($numMatches + $ofs) % $numMatches;
  50173. }
  50174. } elseif (\ord($c) < 32) {
  50175. if ("\t" === $c || "\n" === $c) {
  50176. if ($numMatches > 0 && -1 !== $ofs) {
  50177. $ret = $matches[$ofs];
  50178. $output->write(substr($ret, $i));
  50179. $i = \strlen($ret);
  50180. }
  50181. if ("\n" === $c) {
  50182. $output->write($c);
  50183. break;
  50184. }
  50185. $numMatches = 0;
  50186. }
  50187. continue;
  50188. } else {
  50189. $output->write($c);
  50190. $ret .= $c;
  50191. ++$i;
  50192. $numMatches = 0;
  50193. $ofs = 0;
  50194. foreach ($autocomplete as $value) {
  50195. if (0 === strpos($value, $ret) && $i !== \strlen($value)) {
  50196. $matches[$numMatches++] = $value;
  50197. }
  50198. }
  50199. }
  50200. $output->write("\033[K");
  50201. if ($numMatches > 0 && -1 !== $ofs) {
  50202. $output->write("\0337");
  50203. $output->write('<hl>'.substr($matches[$ofs], $i).'</hl>');
  50204. $output->write("\0338");
  50205. }
  50206. }
  50207. shell_exec(sprintf('stty %s', $sttyMode));
  50208. }
  50209. return \strlen($ret) > 0 ? $ret : $default;
  50210. }
  50211. public function askConfirmation(OutputInterface $output, $question, $default = true)
  50212. {
  50213. $answer = 'z';
  50214. while ($answer && !\in_array(strtolower($answer[0]), array('y', 'n'))) {
  50215. $answer = $this->ask($output, $question);
  50216. }
  50217. if (false === $default) {
  50218. return $answer && 'y' == strtolower($answer[0]);
  50219. }
  50220. return !$answer || 'y' == strtolower($answer[0]);
  50221. }
  50222. public function askHiddenResponse(OutputInterface $output, $question, $fallback = true)
  50223. {
  50224. if ($output instanceof ConsoleOutputInterface) {
  50225. $output = $output->getErrorOutput();
  50226. }
  50227. if ('\\' === \DIRECTORY_SEPARATOR) {
  50228. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  50229. if ('phar:' === substr(__FILE__, 0, 5)) {
  50230. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  50231. copy($exe, $tmpExe);
  50232. $exe = $tmpExe;
  50233. }
  50234. $output->write($question);
  50235. $value = rtrim(shell_exec($exe));
  50236. $output->writeln('');
  50237. if (isset($tmpExe)) {
  50238. unlink($tmpExe);
  50239. }
  50240. return $value;
  50241. }
  50242. if ($this->hasSttyAvailable()) {
  50243. $output->write($question);
  50244. $sttyMode = shell_exec('stty -g');
  50245. shell_exec('stty -echo');
  50246. $value = fgets($this->inputStream ?: STDIN, 4096);
  50247. shell_exec(sprintf('stty %s', $sttyMode));
  50248. if (false === $value) {
  50249. throw new RuntimeException('Aborted');
  50250. }
  50251. $value = trim($value);
  50252. $output->writeln('');
  50253. return $value;
  50254. }
  50255. if (false !== $shell = $this->getShell()) {
  50256. $output->write($question);
  50257. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  50258. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  50259. $value = rtrim(shell_exec($command));
  50260. $output->writeln('');
  50261. return $value;
  50262. }
  50263. if ($fallback) {
  50264. return $this->ask($output, $question);
  50265. }
  50266. throw new RuntimeException('Unable to hide the response');
  50267. }
  50268. public function askAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $default = null, array $autocomplete = null)
  50269. {
  50270. $that = $this;
  50271. $interviewer = function () use ($output, $question, $default, $autocomplete, $that) {
  50272. return $that->ask($output, $question, $default, $autocomplete);
  50273. };
  50274. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  50275. }
  50276. public function askHiddenResponseAndValidate(OutputInterface $output, $question, $validator, $attempts = false, $fallback = true)
  50277. {
  50278. $that = $this;
  50279. $interviewer = function () use ($output, $question, $fallback, $that) {
  50280. return $that->askHiddenResponse($output, $question, $fallback);
  50281. };
  50282. return $this->validateAttempts($interviewer, $output, $validator, $attempts);
  50283. }
  50284. public function setInputStream($stream)
  50285. {
  50286. $this->inputStream = $stream;
  50287. }
  50288. public function getInputStream()
  50289. {
  50290. return $this->inputStream;
  50291. }
  50292. public function getName()
  50293. {
  50294. return 'dialog';
  50295. }
  50296. private function getShell()
  50297. {
  50298. if (null !== self::$shell) {
  50299. return self::$shell;
  50300. }
  50301. self::$shell = false;
  50302. if (file_exists('/usr/bin/env')) {
  50303. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  50304. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  50305. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  50306. self::$shell = $sh;
  50307. break;
  50308. }
  50309. }
  50310. }
  50311. return self::$shell;
  50312. }
  50313. private function hasSttyAvailable()
  50314. {
  50315. if (null !== self::$stty) {
  50316. return self::$stty;
  50317. }
  50318. exec('stty 2>&1', $output, $exitcode);
  50319. return self::$stty = 0 === $exitcode;
  50320. }
  50321. private function validateAttempts($interviewer, OutputInterface $output, $validator, $attempts)
  50322. {
  50323. if ($output instanceof ConsoleOutputInterface) {
  50324. $output = $output->getErrorOutput();
  50325. }
  50326. $e = null;
  50327. while (false === $attempts || $attempts--) {
  50328. if (null !== $e) {
  50329. $output->writeln($this->getHelperSet()->get('formatter')->formatBlock($e->getMessage(), 'error'));
  50330. }
  50331. try {
  50332. return \call_user_func($validator, $interviewer());
  50333. } catch (\Exception $e) {
  50334. }
  50335. }
  50336. throw $e;
  50337. }
  50338. }
  50339. <?php
  50340. namespace Symfony\Component\Console\Helper;
  50341. use Symfony\Component\Console\Formatter\OutputFormatter;
  50342. class FormatterHelper extends Helper
  50343. {
  50344. public function formatSection($section, $message, $style = 'info')
  50345. {
  50346. return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
  50347. }
  50348. public function formatBlock($messages, $style, $large = false)
  50349. {
  50350. if (!\is_array($messages)) {
  50351. $messages = array($messages);
  50352. }
  50353. $len = 0;
  50354. $lines = array();
  50355. foreach ($messages as $message) {
  50356. $message = OutputFormatter::escape($message);
  50357. $lines[] = sprintf($large ? ' %s ' : ' %s ', $message);
  50358. $len = max($this->strlen($message) + ($large ? 4 : 2), $len);
  50359. }
  50360. $messages = $large ? array(str_repeat(' ', $len)) : array();
  50361. for ($i = 0; isset($lines[$i]); ++$i) {
  50362. $messages[] = $lines[$i].str_repeat(' ', $len - $this->strlen($lines[$i]));
  50363. }
  50364. if ($large) {
  50365. $messages[] = str_repeat(' ', $len);
  50366. }
  50367. for ($i = 0; isset($messages[$i]); ++$i) {
  50368. $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
  50369. }
  50370. return implode("\n", $messages);
  50371. }
  50372. public function getName()
  50373. {
  50374. return 'formatter';
  50375. }
  50376. }
  50377. <?php
  50378. namespace Symfony\Component\Console\Helper;
  50379. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  50380. abstract class Helper implements HelperInterface
  50381. {
  50382. protected $helperSet = null;
  50383. public function setHelperSet(HelperSet $helperSet = null)
  50384. {
  50385. $this->helperSet = $helperSet;
  50386. }
  50387. public function getHelperSet()
  50388. {
  50389. return $this->helperSet;
  50390. }
  50391. public static function strlen($string)
  50392. {
  50393. if (false === $encoding = mb_detect_encoding($string, null, true)) {
  50394. return \strlen($string);
  50395. }
  50396. return mb_strwidth($string, $encoding);
  50397. }
  50398. public static function formatTime($secs)
  50399. {
  50400. static $timeFormats = array(
  50401. array(0, '< 1 sec'),
  50402. array(1, '1 sec'),
  50403. array(2, 'secs', 1),
  50404. array(60, '1 min'),
  50405. array(120, 'mins', 60),
  50406. array(3600, '1 hr'),
  50407. array(7200, 'hrs', 3600),
  50408. array(86400, '1 day'),
  50409. array(172800, 'days', 86400),
  50410. );
  50411. foreach ($timeFormats as $index => $format) {
  50412. if ($secs >= $format[0]) {
  50413. if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
  50414. || $index == \count($timeFormats) - 1
  50415. ) {
  50416. if (2 == \count($format)) {
  50417. return $format[1];
  50418. }
  50419. return floor($secs / $format[2]).' '.$format[1];
  50420. }
  50421. }
  50422. }
  50423. }
  50424. public static function formatMemory($memory)
  50425. {
  50426. if ($memory >= 1024 * 1024 * 1024) {
  50427. return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
  50428. }
  50429. if ($memory >= 1024 * 1024) {
  50430. return sprintf('%.1f MiB', $memory / 1024 / 1024);
  50431. }
  50432. if ($memory >= 1024) {
  50433. return sprintf('%d KiB', $memory / 1024);
  50434. }
  50435. return sprintf('%d B', $memory);
  50436. }
  50437. public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, $string)
  50438. {
  50439. return self::strlen(self::removeDecoration($formatter, $string));
  50440. }
  50441. public static function removeDecoration(OutputFormatterInterface $formatter, $string)
  50442. {
  50443. $isDecorated = $formatter->isDecorated();
  50444. $formatter->setDecorated(false);
  50445. $string = $formatter->format($string);
  50446. $string = preg_replace("/\033\[[^m]*m/", '', $string);
  50447. $formatter->setDecorated($isDecorated);
  50448. return $string;
  50449. }
  50450. }
  50451. <?php
  50452. namespace Symfony\Component\Console\Helper;
  50453. interface HelperInterface
  50454. {
  50455. public function setHelperSet(HelperSet $helperSet = null);
  50456. public function getHelperSet();
  50457. public function getName();
  50458. }
  50459. <?php
  50460. namespace Symfony\Component\Console\Helper;
  50461. use Symfony\Component\Console\Command\Command;
  50462. use Symfony\Component\Console\Exception\InvalidArgumentException;
  50463. class HelperSet implements \IteratorAggregate
  50464. {
  50465. private $helpers = array();
  50466. private $command;
  50467. public function __construct(array $helpers = array())
  50468. {
  50469. foreach ($helpers as $alias => $helper) {
  50470. $this->set($helper, \is_int($alias) ? null : $alias);
  50471. }
  50472. }
  50473. public function set(HelperInterface $helper, $alias = null)
  50474. {
  50475. $this->helpers[$helper->getName()] = $helper;
  50476. if (null !== $alias) {
  50477. $this->helpers[$alias] = $helper;
  50478. }
  50479. $helper->setHelperSet($this);
  50480. }
  50481. public function has($name)
  50482. {
  50483. return isset($this->helpers[$name]);
  50484. }
  50485. public function get($name)
  50486. {
  50487. if (!$this->has($name)) {
  50488. throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
  50489. }
  50490. if ('dialog' === $name && $this->helpers[$name] instanceof DialogHelper) {
  50491. @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);
  50492. } elseif ('progress' === $name && $this->helpers[$name] instanceof ProgressHelper) {
  50493. @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);
  50494. } elseif ('table' === $name && $this->helpers[$name] instanceof TableHelper) {
  50495. @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);
  50496. }
  50497. return $this->helpers[$name];
  50498. }
  50499. public function setCommand(Command $command = null)
  50500. {
  50501. $this->command = $command;
  50502. }
  50503. public function getCommand()
  50504. {
  50505. return $this->command;
  50506. }
  50507. public function getIterator()
  50508. {
  50509. return new \ArrayIterator($this->helpers);
  50510. }
  50511. }
  50512. <?php
  50513. namespace Symfony\Component\Console\Helper;
  50514. use Symfony\Component\Console\Input\InputAwareInterface;
  50515. use Symfony\Component\Console\Input\InputInterface;
  50516. abstract class InputAwareHelper extends Helper implements InputAwareInterface
  50517. {
  50518. protected $input;
  50519. public function setInput(InputInterface $input)
  50520. {
  50521. $this->input = $input;
  50522. }
  50523. }
  50524. <?php
  50525. namespace Symfony\Component\Console\Helper;
  50526. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50527. use Symfony\Component\Console\Output\OutputInterface;
  50528. use Symfony\Component\Process\Exception\ProcessFailedException;
  50529. use Symfony\Component\Process\Process;
  50530. use Symfony\Component\Process\ProcessBuilder;
  50531. class ProcessHelper extends Helper
  50532. {
  50533. public function run(OutputInterface $output, $cmd, $error = null, $callback = null, $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE)
  50534. {
  50535. if ($output instanceof ConsoleOutputInterface) {
  50536. $output = $output->getErrorOutput();
  50537. }
  50538. $formatter = $this->getHelperSet()->get('debug_formatter');
  50539. if (\is_array($cmd)) {
  50540. $process = ProcessBuilder::create($cmd)->getProcess();
  50541. } elseif ($cmd instanceof Process) {
  50542. $process = $cmd;
  50543. } else {
  50544. $process = new Process($cmd);
  50545. }
  50546. if ($verbosity <= $output->getVerbosity()) {
  50547. $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine())));
  50548. }
  50549. if ($output->isDebug()) {
  50550. $callback = $this->wrapCallback($output, $process, $callback);
  50551. }
  50552. $process->run($callback);
  50553. if ($verbosity <= $output->getVerbosity()) {
  50554. $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode());
  50555. $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful()));
  50556. }
  50557. if (!$process->isSuccessful() && null !== $error) {
  50558. $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error)));
  50559. }
  50560. return $process;
  50561. }
  50562. public function mustRun(OutputInterface $output, $cmd, $error = null, $callback = null)
  50563. {
  50564. $process = $this->run($output, $cmd, $error, $callback);
  50565. if (!$process->isSuccessful()) {
  50566. throw new ProcessFailedException($process);
  50567. }
  50568. return $process;
  50569. }
  50570. public function wrapCallback(OutputInterface $output, Process $process, $callback = null)
  50571. {
  50572. if ($output instanceof ConsoleOutputInterface) {
  50573. $output = $output->getErrorOutput();
  50574. }
  50575. $formatter = $this->getHelperSet()->get('debug_formatter');
  50576. $that = $this;
  50577. return function ($type, $buffer) use ($output, $process, $callback, $formatter, $that) {
  50578. $output->write($formatter->progress(spl_object_hash($process), $that->escapeString($buffer), Process::ERR === $type));
  50579. if (null !== $callback) {
  50580. \call_user_func($callback, $type, $buffer);
  50581. }
  50582. };
  50583. }
  50584. public function escapeString($str)
  50585. {
  50586. return str_replace('<', '\\<', $str);
  50587. }
  50588. public function getName()
  50589. {
  50590. return 'process';
  50591. }
  50592. }
  50593. <?php
  50594. namespace Symfony\Component\Console\Helper;
  50595. use Symfony\Component\Console\Exception\LogicException;
  50596. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50597. use Symfony\Component\Console\Output\OutputInterface;
  50598. class ProgressBar
  50599. {
  50600. private $barWidth = 28;
  50601. private $barChar;
  50602. private $emptyBarChar = '-';
  50603. private $progressChar = '>';
  50604. private $format;
  50605. private $internalFormat;
  50606. private $redrawFreq = 1;
  50607. private $output;
  50608. private $step = 0;
  50609. private $max;
  50610. private $startTime;
  50611. private $stepWidth;
  50612. private $percent = 0.0;
  50613. private $formatLineCount;
  50614. private $messages = array();
  50615. private $overwrite = true;
  50616. private $firstRun = true;
  50617. private static $formatters;
  50618. private static $formats;
  50619. public function __construct(OutputInterface $output, $max = 0)
  50620. {
  50621. if ($output instanceof ConsoleOutputInterface) {
  50622. $output = $output->getErrorOutput();
  50623. }
  50624. $this->output = $output;
  50625. $this->setMaxSteps($max);
  50626. if (!$this->output->isDecorated()) {
  50627. $this->overwrite = false;
  50628. $this->setRedrawFrequency($max / 10);
  50629. }
  50630. $this->startTime = time();
  50631. }
  50632. public static function setPlaceholderFormatterDefinition($name, $callable)
  50633. {
  50634. if (!self::$formatters) {
  50635. self::$formatters = self::initPlaceholderFormatters();
  50636. }
  50637. self::$formatters[$name] = $callable;
  50638. }
  50639. public static function getPlaceholderFormatterDefinition($name)
  50640. {
  50641. if (!self::$formatters) {
  50642. self::$formatters = self::initPlaceholderFormatters();
  50643. }
  50644. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  50645. }
  50646. public static function setFormatDefinition($name, $format)
  50647. {
  50648. if (!self::$formats) {
  50649. self::$formats = self::initFormats();
  50650. }
  50651. self::$formats[$name] = $format;
  50652. }
  50653. public static function getFormatDefinition($name)
  50654. {
  50655. if (!self::$formats) {
  50656. self::$formats = self::initFormats();
  50657. }
  50658. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  50659. }
  50660. public function setMessage($message, $name = 'message')
  50661. {
  50662. $this->messages[$name] = $message;
  50663. }
  50664. public function getMessage($name = 'message')
  50665. {
  50666. return $this->messages[$name];
  50667. }
  50668. public function getStartTime()
  50669. {
  50670. return $this->startTime;
  50671. }
  50672. public function getMaxSteps()
  50673. {
  50674. return $this->max;
  50675. }
  50676. public function getStep()
  50677. {
  50678. @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);
  50679. return $this->getProgress();
  50680. }
  50681. public function getProgress()
  50682. {
  50683. return $this->step;
  50684. }
  50685. public function getStepWidth()
  50686. {
  50687. return $this->stepWidth;
  50688. }
  50689. public function getProgressPercent()
  50690. {
  50691. return $this->percent;
  50692. }
  50693. public function setBarWidth($size)
  50694. {
  50695. $this->barWidth = (int) $size;
  50696. }
  50697. public function getBarWidth()
  50698. {
  50699. return $this->barWidth;
  50700. }
  50701. public function setBarCharacter($char)
  50702. {
  50703. $this->barChar = $char;
  50704. }
  50705. public function getBarCharacter()
  50706. {
  50707. if (null === $this->barChar) {
  50708. return $this->max ? '=' : $this->emptyBarChar;
  50709. }
  50710. return $this->barChar;
  50711. }
  50712. public function setEmptyBarCharacter($char)
  50713. {
  50714. $this->emptyBarChar = $char;
  50715. }
  50716. public function getEmptyBarCharacter()
  50717. {
  50718. return $this->emptyBarChar;
  50719. }
  50720. public function setProgressCharacter($char)
  50721. {
  50722. $this->progressChar = $char;
  50723. }
  50724. public function getProgressCharacter()
  50725. {
  50726. return $this->progressChar;
  50727. }
  50728. public function setFormat($format)
  50729. {
  50730. $this->format = null;
  50731. $this->internalFormat = $format;
  50732. }
  50733. public function setRedrawFrequency($freq)
  50734. {
  50735. $this->redrawFreq = max((int) $freq, 1);
  50736. }
  50737. public function start($max = null)
  50738. {
  50739. $this->startTime = time();
  50740. $this->step = 0;
  50741. $this->percent = 0.0;
  50742. if (null !== $max) {
  50743. $this->setMaxSteps($max);
  50744. }
  50745. $this->display();
  50746. }
  50747. public function advance($step = 1)
  50748. {
  50749. $this->setProgress($this->step + $step);
  50750. }
  50751. public function setCurrent($step)
  50752. {
  50753. @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);
  50754. $this->setProgress($step);
  50755. }
  50756. public function setOverwrite($overwrite)
  50757. {
  50758. $this->overwrite = (bool) $overwrite;
  50759. }
  50760. public function setProgress($step)
  50761. {
  50762. $step = (int) $step;
  50763. if ($step < $this->step) {
  50764. throw new LogicException('You can\'t regress the progress bar.');
  50765. }
  50766. if ($this->max && $step > $this->max) {
  50767. $this->max = $step;
  50768. }
  50769. $prevPeriod = (int) ($this->step / $this->redrawFreq);
  50770. $currPeriod = (int) ($step / $this->redrawFreq);
  50771. $this->step = $step;
  50772. $this->percent = $this->max ? (float) $this->step / $this->max : 0;
  50773. if ($prevPeriod !== $currPeriod || $this->max === $step) {
  50774. $this->display();
  50775. }
  50776. }
  50777. public function finish()
  50778. {
  50779. if (!$this->max) {
  50780. $this->max = $this->step;
  50781. }
  50782. if ($this->step === $this->max && !$this->overwrite) {
  50783. return;
  50784. }
  50785. $this->setProgress($this->max);
  50786. }
  50787. public function display()
  50788. {
  50789. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  50790. return;
  50791. }
  50792. if (null === $this->format) {
  50793. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  50794. }
  50795. $self = $this;
  50796. $output = $this->output;
  50797. $messages = $this->messages;
  50798. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self, $output, $messages) {
  50799. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  50800. $text = \call_user_func($formatter, $self, $output);
  50801. } elseif (isset($messages[$matches[1]])) {
  50802. $text = $messages[$matches[1]];
  50803. } else {
  50804. return $matches[0];
  50805. }
  50806. if (isset($matches[2])) {
  50807. $text = sprintf('%'.$matches[2], $text);
  50808. }
  50809. return $text;
  50810. }, $this->format));
  50811. }
  50812. public function clear()
  50813. {
  50814. if (!$this->overwrite) {
  50815. return;
  50816. }
  50817. if (null === $this->format) {
  50818. $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
  50819. }
  50820. $this->overwrite('');
  50821. }
  50822. private function setRealFormat($format)
  50823. {
  50824. if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
  50825. $this->format = self::getFormatDefinition($format.'_nomax');
  50826. } elseif (null !== self::getFormatDefinition($format)) {
  50827. $this->format = self::getFormatDefinition($format);
  50828. } else {
  50829. $this->format = $format;
  50830. }
  50831. $this->formatLineCount = substr_count($this->format, "\n");
  50832. }
  50833. private function setMaxSteps($max)
  50834. {
  50835. $this->max = max(0, (int) $max);
  50836. $this->stepWidth = $this->max ? Helper::strlen($this->max) : 4;
  50837. }
  50838. private function overwrite($message)
  50839. {
  50840. if ($this->overwrite) {
  50841. if (!$this->firstRun) {
  50842. $this->output->write("\x0D");
  50843. $this->output->write("\x1B[2K");
  50844. if ($this->formatLineCount > 0) {
  50845. $this->output->write(str_repeat("\x1B[1A\x1B[2K", $this->formatLineCount));
  50846. }
  50847. }
  50848. } elseif ($this->step > 0) {
  50849. $this->output->writeln('');
  50850. }
  50851. $this->firstRun = false;
  50852. $this->output->write($message);
  50853. }
  50854. private function determineBestFormat()
  50855. {
  50856. switch ($this->output->getVerbosity()) {
  50857. case OutputInterface::VERBOSITY_VERBOSE:
  50858. return $this->max ? 'verbose' : 'verbose_nomax';
  50859. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  50860. return $this->max ? 'very_verbose' : 'very_verbose_nomax';
  50861. case OutputInterface::VERBOSITY_DEBUG:
  50862. return $this->max ? 'debug' : 'debug_nomax';
  50863. default:
  50864. return $this->max ? 'normal' : 'normal_nomax';
  50865. }
  50866. }
  50867. private static function initPlaceholderFormatters()
  50868. {
  50869. return array(
  50870. 'bar' => function (ProgressBar $bar, OutputInterface $output) {
  50871. $completeBars = floor($bar->getMaxSteps() > 0 ? $bar->getProgressPercent() * $bar->getBarWidth() : $bar->getProgress() % $bar->getBarWidth());
  50872. $display = str_repeat($bar->getBarCharacter(), $completeBars);
  50873. if ($completeBars < $bar->getBarWidth()) {
  50874. $emptyBars = $bar->getBarWidth() - $completeBars - Helper::strlenWithoutDecoration($output->getFormatter(), $bar->getProgressCharacter());
  50875. $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
  50876. }
  50877. return $display;
  50878. },
  50879. 'elapsed' => function (ProgressBar $bar) {
  50880. return Helper::formatTime(time() - $bar->getStartTime());
  50881. },
  50882. 'remaining' => function (ProgressBar $bar) {
  50883. if (!$bar->getMaxSteps()) {
  50884. throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
  50885. }
  50886. if (!$bar->getProgress()) {
  50887. $remaining = 0;
  50888. } else {
  50889. $remaining = round((time() - $bar->getStartTime()) / $bar->getProgress() * ($bar->getMaxSteps() - $bar->getProgress()));
  50890. }
  50891. return Helper::formatTime($remaining);
  50892. },
  50893. 'estimated' => function (ProgressBar $bar) {
  50894. if (!$bar->getMaxSteps()) {
  50895. throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
  50896. }
  50897. if (!$bar->getProgress()) {
  50898. $estimated = 0;
  50899. } else {
  50900. $estimated = round((time() - $bar->getStartTime()) / $bar->getProgress() * $bar->getMaxSteps());
  50901. }
  50902. return Helper::formatTime($estimated);
  50903. },
  50904. 'memory' => function (ProgressBar $bar) {
  50905. return Helper::formatMemory(memory_get_usage(true));
  50906. },
  50907. 'current' => function (ProgressBar $bar) {
  50908. return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', STR_PAD_LEFT);
  50909. },
  50910. 'max' => function (ProgressBar $bar) {
  50911. return $bar->getMaxSteps();
  50912. },
  50913. 'percent' => function (ProgressBar $bar) {
  50914. return floor($bar->getProgressPercent() * 100);
  50915. },
  50916. );
  50917. }
  50918. private static function initFormats()
  50919. {
  50920. return array(
  50921. 'normal' => ' %current%/%max% [%bar%] %percent:3s%%',
  50922. 'normal_nomax' => ' %current% [%bar%]',
  50923. 'verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
  50924. 'verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  50925. 'very_verbose' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
  50926. 'very_verbose_nomax' => ' %current% [%bar%] %elapsed:6s%',
  50927. 'debug' => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
  50928. 'debug_nomax' => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
  50929. );
  50930. }
  50931. }
  50932. <?php
  50933. namespace Symfony\Component\Console\Helper;
  50934. use Symfony\Component\Console\Exception\LogicException;
  50935. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  50936. use Symfony\Component\Console\Output\NullOutput;
  50937. use Symfony\Component\Console\Output\OutputInterface;
  50938. class ProgressHelper extends Helper
  50939. {
  50940. const FORMAT_QUIET = ' %percent%%';
  50941. const FORMAT_NORMAL = ' %current%/%max% [%bar%] %percent%%';
  50942. const FORMAT_VERBOSE = ' %current%/%max% [%bar%] %percent%% Elapsed: %elapsed%';
  50943. const FORMAT_QUIET_NOMAX = ' %current%';
  50944. const FORMAT_NORMAL_NOMAX = ' %current% [%bar%]';
  50945. const FORMAT_VERBOSE_NOMAX = ' %current% [%bar%] Elapsed: %elapsed%';
  50946. private $barWidth = 28;
  50947. private $barChar = '=';
  50948. private $emptyBarChar = '-';
  50949. private $progressChar = '>';
  50950. private $format = null;
  50951. private $redrawFreq = 1;
  50952. private $lastMessagesLength;
  50953. private $barCharOriginal;
  50954. private $output;
  50955. private $current;
  50956. private $max;
  50957. private $startTime;
  50958. private $defaultFormatVars = array(
  50959. 'current',
  50960. 'max',
  50961. 'bar',
  50962. 'percent',
  50963. 'elapsed',
  50964. );
  50965. private $formatVars;
  50966. private $widths = array(
  50967. 'current' => 4,
  50968. 'max' => 4,
  50969. 'percent' => 3,
  50970. 'elapsed' => 6,
  50971. );
  50972. private $timeFormats = array(
  50973. array(0, '???'),
  50974. array(2, '1 sec'),
  50975. array(59, 'secs', 1),
  50976. array(60, '1 min'),
  50977. array(3600, 'mins', 60),
  50978. array(5400, '1 hr'),
  50979. array(86400, 'hrs', 3600),
  50980. array(129600, '1 day'),
  50981. array(604800, 'days', 86400),
  50982. );
  50983. public function __construct($triggerDeprecationError = true)
  50984. {
  50985. if ($triggerDeprecationError) {
  50986. @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);
  50987. }
  50988. }
  50989. public function setBarWidth($size)
  50990. {
  50991. $this->barWidth = (int) $size;
  50992. }
  50993. public function setBarCharacter($char)
  50994. {
  50995. $this->barChar = $char;
  50996. }
  50997. public function setEmptyBarCharacter($char)
  50998. {
  50999. $this->emptyBarChar = $char;
  51000. }
  51001. public function setProgressCharacter($char)
  51002. {
  51003. $this->progressChar = $char;
  51004. }
  51005. public function setFormat($format)
  51006. {
  51007. $this->format = $format;
  51008. }
  51009. public function setRedrawFrequency($freq)
  51010. {
  51011. $this->redrawFreq = (int) $freq;
  51012. }
  51013. public function start(OutputInterface $output, $max = null)
  51014. {
  51015. if ($output instanceof ConsoleOutputInterface) {
  51016. $output = $output->getErrorOutput();
  51017. }
  51018. $this->startTime = time();
  51019. $this->current = 0;
  51020. $this->max = (int) $max;
  51021. $this->output = $output->isDecorated() ? $output : new NullOutput();
  51022. $this->lastMessagesLength = 0;
  51023. $this->barCharOriginal = '';
  51024. if (null === $this->format) {
  51025. switch ($output->getVerbosity()) {
  51026. case OutputInterface::VERBOSITY_QUIET:
  51027. $this->format = self::FORMAT_QUIET_NOMAX;
  51028. if ($this->max > 0) {
  51029. $this->format = self::FORMAT_QUIET;
  51030. }
  51031. break;
  51032. case OutputInterface::VERBOSITY_VERBOSE:
  51033. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  51034. case OutputInterface::VERBOSITY_DEBUG:
  51035. $this->format = self::FORMAT_VERBOSE_NOMAX;
  51036. if ($this->max > 0) {
  51037. $this->format = self::FORMAT_VERBOSE;
  51038. }
  51039. break;
  51040. default:
  51041. $this->format = self::FORMAT_NORMAL_NOMAX;
  51042. if ($this->max > 0) {
  51043. $this->format = self::FORMAT_NORMAL;
  51044. }
  51045. break;
  51046. }
  51047. }
  51048. $this->initialize();
  51049. }
  51050. public function advance($step = 1, $redraw = false)
  51051. {
  51052. $this->setCurrent($this->current + $step, $redraw);
  51053. }
  51054. public function setCurrent($current, $redraw = false)
  51055. {
  51056. if (null === $this->startTime) {
  51057. throw new LogicException('You must start the progress bar before calling setCurrent().');
  51058. }
  51059. $current = (int) $current;
  51060. if ($current < $this->current) {
  51061. throw new LogicException('You can\'t regress the progress bar');
  51062. }
  51063. if (0 === $this->current) {
  51064. $redraw = true;
  51065. }
  51066. $prevPeriod = (int) ($this->current / $this->redrawFreq);
  51067. $this->current = $current;
  51068. $currPeriod = (int) ($this->current / $this->redrawFreq);
  51069. if ($redraw || $prevPeriod !== $currPeriod || $this->max === $this->current) {
  51070. $this->display();
  51071. }
  51072. }
  51073. public function display($finish = false)
  51074. {
  51075. if (null === $this->startTime) {
  51076. throw new LogicException('You must start the progress bar before calling display().');
  51077. }
  51078. $message = $this->format;
  51079. foreach ($this->generate($finish) as $name => $value) {
  51080. $message = str_replace("%{$name}%", $value, $message);
  51081. }
  51082. $this->overwrite($this->output, $message);
  51083. }
  51084. public function clear()
  51085. {
  51086. $this->overwrite($this->output, '');
  51087. }
  51088. public function finish()
  51089. {
  51090. if (null === $this->startTime) {
  51091. throw new LogicException('You must start the progress bar before calling finish().');
  51092. }
  51093. if (null !== $this->startTime) {
  51094. if (!$this->max) {
  51095. $this->barChar = $this->barCharOriginal;
  51096. $this->display(true);
  51097. }
  51098. $this->startTime = null;
  51099. $this->output->writeln('');
  51100. $this->output = null;
  51101. }
  51102. }
  51103. private function initialize()
  51104. {
  51105. $this->formatVars = array();
  51106. foreach ($this->defaultFormatVars as $var) {
  51107. if (false !== strpos($this->format, "%{$var}%")) {
  51108. $this->formatVars[$var] = true;
  51109. }
  51110. }
  51111. if ($this->max > 0) {
  51112. $this->widths['max'] = $this->strlen($this->max);
  51113. $this->widths['current'] = $this->widths['max'];
  51114. } else {
  51115. $this->barCharOriginal = $this->barChar;
  51116. $this->barChar = $this->emptyBarChar;
  51117. }
  51118. }
  51119. private function generate($finish = false)
  51120. {
  51121. $vars = array();
  51122. $percent = 0;
  51123. if ($this->max > 0) {
  51124. $percent = (float) $this->current / $this->max;
  51125. }
  51126. if (isset($this->formatVars['bar'])) {
  51127. if ($this->max > 0) {
  51128. $completeBars = floor($percent * $this->barWidth);
  51129. } else {
  51130. if (!$finish) {
  51131. $completeBars = floor($this->current % $this->barWidth);
  51132. } else {
  51133. $completeBars = $this->barWidth;
  51134. }
  51135. }
  51136. $emptyBars = $this->barWidth - $completeBars - $this->strlen($this->progressChar);
  51137. $bar = str_repeat($this->barChar, $completeBars);
  51138. if ($completeBars < $this->barWidth) {
  51139. $bar .= $this->progressChar;
  51140. $bar .= str_repeat($this->emptyBarChar, $emptyBars);
  51141. }
  51142. $vars['bar'] = $bar;
  51143. }
  51144. if (isset($this->formatVars['elapsed'])) {
  51145. $elapsed = time() - $this->startTime;
  51146. $vars['elapsed'] = str_pad($this->humaneTime($elapsed), $this->widths['elapsed'], ' ', STR_PAD_LEFT);
  51147. }
  51148. if (isset($this->formatVars['current'])) {
  51149. $vars['current'] = str_pad($this->current, $this->widths['current'], ' ', STR_PAD_LEFT);
  51150. }
  51151. if (isset($this->formatVars['max'])) {
  51152. $vars['max'] = $this->max;
  51153. }
  51154. if (isset($this->formatVars['percent'])) {
  51155. $vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
  51156. }
  51157. return $vars;
  51158. }
  51159. private function humaneTime($secs)
  51160. {
  51161. $text = '';
  51162. foreach ($this->timeFormats as $format) {
  51163. if ($secs < $format[0]) {
  51164. if (2 == \count($format)) {
  51165. $text = $format[1];
  51166. break;
  51167. } else {
  51168. $text = ceil($secs / $format[2]).' '.$format[1];
  51169. break;
  51170. }
  51171. }
  51172. }
  51173. return $text;
  51174. }
  51175. private function overwrite(OutputInterface $output, $message)
  51176. {
  51177. $length = $this->strlen($message);
  51178. if (null !== $this->lastMessagesLength && $this->lastMessagesLength > $length) {
  51179. $message = str_pad($message, $this->lastMessagesLength, "\x20", STR_PAD_RIGHT);
  51180. }
  51181. $output->write("\x0D");
  51182. $output->write($message);
  51183. $this->lastMessagesLength = $this->strlen($message);
  51184. }
  51185. public function getName()
  51186. {
  51187. return 'progress';
  51188. }
  51189. }
  51190. <?php
  51191. namespace Symfony\Component\Console\Helper;
  51192. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51193. use Symfony\Component\Console\Exception\LogicException;
  51194. use Symfony\Component\Console\Output\OutputInterface;
  51195. class ProgressIndicator
  51196. {
  51197. private $output;
  51198. private $startTime;
  51199. private $format;
  51200. private $message;
  51201. private $indicatorValues;
  51202. private $indicatorCurrent;
  51203. private $indicatorChangeInterval;
  51204. private $indicatorUpdateTime;
  51205. private $started = false;
  51206. private static $formatters;
  51207. private static $formats;
  51208. public function __construct(OutputInterface $output, $format = null, $indicatorChangeInterval = 100, $indicatorValues = null)
  51209. {
  51210. $this->output = $output;
  51211. if (null === $format) {
  51212. $format = $this->determineBestFormat();
  51213. }
  51214. if (null === $indicatorValues) {
  51215. $indicatorValues = array('-', '\\', '|', '/');
  51216. }
  51217. $indicatorValues = array_values($indicatorValues);
  51218. if (2 > \count($indicatorValues)) {
  51219. throw new InvalidArgumentException('Must have at least 2 indicator value characters.');
  51220. }
  51221. $this->format = self::getFormatDefinition($format);
  51222. $this->indicatorChangeInterval = $indicatorChangeInterval;
  51223. $this->indicatorValues = $indicatorValues;
  51224. $this->startTime = time();
  51225. }
  51226. public function setMessage($message)
  51227. {
  51228. $this->message = $message;
  51229. $this->display();
  51230. }
  51231. public function getMessage()
  51232. {
  51233. return $this->message;
  51234. }
  51235. public function getStartTime()
  51236. {
  51237. return $this->startTime;
  51238. }
  51239. public function getCurrentValue()
  51240. {
  51241. return $this->indicatorValues[$this->indicatorCurrent % \count($this->indicatorValues)];
  51242. }
  51243. public function start($message)
  51244. {
  51245. if ($this->started) {
  51246. throw new LogicException('Progress indicator already started.');
  51247. }
  51248. $this->message = $message;
  51249. $this->started = true;
  51250. $this->startTime = time();
  51251. $this->indicatorUpdateTime = $this->getCurrentTimeInMilliseconds() + $this->indicatorChangeInterval;
  51252. $this->indicatorCurrent = 0;
  51253. $this->display();
  51254. }
  51255. public function advance()
  51256. {
  51257. if (!$this->started) {
  51258. throw new LogicException('Progress indicator has not yet been started.');
  51259. }
  51260. if (!$this->output->isDecorated()) {
  51261. return;
  51262. }
  51263. $currentTime = $this->getCurrentTimeInMilliseconds();
  51264. if ($currentTime < $this->indicatorUpdateTime) {
  51265. return;
  51266. }
  51267. $this->indicatorUpdateTime = $currentTime + $this->indicatorChangeInterval;
  51268. ++$this->indicatorCurrent;
  51269. $this->display();
  51270. }
  51271. public function finish($message)
  51272. {
  51273. if (!$this->started) {
  51274. throw new LogicException('Progress indicator has not yet been started.');
  51275. }
  51276. $this->message = $message;
  51277. $this->display();
  51278. $this->output->writeln('');
  51279. $this->started = false;
  51280. }
  51281. public static function getFormatDefinition($name)
  51282. {
  51283. if (!self::$formats) {
  51284. self::$formats = self::initFormats();
  51285. }
  51286. return isset(self::$formats[$name]) ? self::$formats[$name] : null;
  51287. }
  51288. public static function setPlaceholderFormatterDefinition($name, $callable)
  51289. {
  51290. if (!self::$formatters) {
  51291. self::$formatters = self::initPlaceholderFormatters();
  51292. }
  51293. self::$formatters[$name] = $callable;
  51294. }
  51295. public static function getPlaceholderFormatterDefinition($name)
  51296. {
  51297. if (!self::$formatters) {
  51298. self::$formatters = self::initPlaceholderFormatters();
  51299. }
  51300. return isset(self::$formatters[$name]) ? self::$formatters[$name] : null;
  51301. }
  51302. private function display()
  51303. {
  51304. if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
  51305. return;
  51306. }
  51307. $self = $this;
  51308. $this->overwrite(preg_replace_callback("{%([a-z\-_]+)(?:\:([^%]+))?%}i", function ($matches) use ($self) {
  51309. if ($formatter = $self::getPlaceholderFormatterDefinition($matches[1])) {
  51310. return \call_user_func($formatter, $self);
  51311. }
  51312. return $matches[0];
  51313. }, $this->format));
  51314. }
  51315. private function determineBestFormat()
  51316. {
  51317. switch ($this->output->getVerbosity()) {
  51318. case OutputInterface::VERBOSITY_VERBOSE:
  51319. return $this->output->isDecorated() ? 'verbose' : 'verbose_no_ansi';
  51320. case OutputInterface::VERBOSITY_VERY_VERBOSE:
  51321. case OutputInterface::VERBOSITY_DEBUG:
  51322. return $this->output->isDecorated() ? 'very_verbose' : 'very_verbose_no_ansi';
  51323. default:
  51324. return $this->output->isDecorated() ? 'normal' : 'normal_no_ansi';
  51325. }
  51326. }
  51327. private function overwrite($message)
  51328. {
  51329. if ($this->output->isDecorated()) {
  51330. $this->output->write("\x0D\x1B[2K");
  51331. $this->output->write($message);
  51332. } else {
  51333. $this->output->writeln($message);
  51334. }
  51335. }
  51336. private function getCurrentTimeInMilliseconds()
  51337. {
  51338. return round(microtime(true) * 1000);
  51339. }
  51340. private static function initPlaceholderFormatters()
  51341. {
  51342. return array(
  51343. 'indicator' => function (ProgressIndicator $indicator) {
  51344. return $indicator->getCurrentValue();
  51345. },
  51346. 'message' => function (ProgressIndicator $indicator) {
  51347. return $indicator->getMessage();
  51348. },
  51349. 'elapsed' => function (ProgressIndicator $indicator) {
  51350. return Helper::formatTime(time() - $indicator->getStartTime());
  51351. },
  51352. 'memory' => function () {
  51353. return Helper::formatMemory(memory_get_usage(true));
  51354. },
  51355. );
  51356. }
  51357. private static function initFormats()
  51358. {
  51359. return array(
  51360. 'normal' => ' %indicator% %message%',
  51361. 'normal_no_ansi' => ' %message%',
  51362. 'verbose' => ' %indicator% %message% (%elapsed:6s%)',
  51363. 'verbose_no_ansi' => ' %message% (%elapsed:6s%)',
  51364. 'very_verbose' => ' %indicator% %message% (%elapsed:6s%, %memory:6s%)',
  51365. 'very_verbose_no_ansi' => ' %message% (%elapsed:6s%, %memory:6s%)',
  51366. );
  51367. }
  51368. }
  51369. <?php
  51370. namespace Symfony\Component\Console\Helper;
  51371. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51372. use Symfony\Component\Console\Exception\RuntimeException;
  51373. use Symfony\Component\Console\Formatter\OutputFormatter;
  51374. use Symfony\Component\Console\Formatter\OutputFormatterStyle;
  51375. use Symfony\Component\Console\Input\InputInterface;
  51376. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  51377. use Symfony\Component\Console\Output\OutputInterface;
  51378. use Symfony\Component\Console\Question\ChoiceQuestion;
  51379. use Symfony\Component\Console\Question\Question;
  51380. class QuestionHelper extends Helper
  51381. {
  51382. private $inputStream;
  51383. private static $shell;
  51384. private static $stty;
  51385. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  51386. {
  51387. if ($output instanceof ConsoleOutputInterface) {
  51388. $output = $output->getErrorOutput();
  51389. }
  51390. if (!$input->isInteractive()) {
  51391. $default = $question->getDefault();
  51392. if (null !== $default && $question instanceof ChoiceQuestion) {
  51393. $choices = $question->getChoices();
  51394. if (!$question->isMultiselect()) {
  51395. return isset($choices[$default]) ? $choices[$default] : $default;
  51396. }
  51397. $default = explode(',', $default);
  51398. foreach ($default as $k => $v) {
  51399. $v = trim($v);
  51400. $default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
  51401. }
  51402. }
  51403. return $default;
  51404. }
  51405. if (!$question->getValidator()) {
  51406. return $this->doAsk($output, $question);
  51407. }
  51408. $that = $this;
  51409. $interviewer = function () use ($output, $question, $that) {
  51410. return $that->doAsk($output, $question);
  51411. };
  51412. return $this->validateAttempts($interviewer, $output, $question);
  51413. }
  51414. public function setInputStream($stream)
  51415. {
  51416. if (!\is_resource($stream)) {
  51417. throw new InvalidArgumentException('Input stream must be a valid resource.');
  51418. }
  51419. $this->inputStream = $stream;
  51420. }
  51421. public function getInputStream()
  51422. {
  51423. return $this->inputStream;
  51424. }
  51425. public function getName()
  51426. {
  51427. return 'question';
  51428. }
  51429. public function doAsk(OutputInterface $output, Question $question)
  51430. {
  51431. $this->writePrompt($output, $question);
  51432. $inputStream = $this->inputStream ?: STDIN;
  51433. $autocomplete = $question->getAutocompleterValues();
  51434. if (null === $autocomplete || !$this->hasSttyAvailable()) {
  51435. $ret = false;
  51436. if ($question->isHidden()) {
  51437. try {
  51438. $ret = trim($this->getHiddenResponse($output, $inputStream));
  51439. } catch (RuntimeException $e) {
  51440. if (!$question->isHiddenFallback()) {
  51441. throw $e;
  51442. }
  51443. }
  51444. }
  51445. if (false === $ret) {
  51446. $ret = fgets($inputStream, 4096);
  51447. if (false === $ret) {
  51448. throw new RuntimeException('Aborted');
  51449. }
  51450. $ret = trim($ret);
  51451. }
  51452. } else {
  51453. $ret = trim($this->autocomplete($output, $question, $inputStream, \is_array($autocomplete) ? $autocomplete : iterator_to_array($autocomplete, false)));
  51454. }
  51455. $ret = \strlen($ret) > 0 ? $ret : $question->getDefault();
  51456. if ($normalizer = $question->getNormalizer()) {
  51457. return $normalizer($ret);
  51458. }
  51459. return $ret;
  51460. }
  51461. protected function writePrompt(OutputInterface $output, Question $question)
  51462. {
  51463. $message = $question->getQuestion();
  51464. if ($question instanceof ChoiceQuestion) {
  51465. $maxWidth = max(array_map(array($this, 'strlen'), array_keys($question->getChoices())));
  51466. $messages = (array) $question->getQuestion();
  51467. foreach ($question->getChoices() as $key => $value) {
  51468. $width = $maxWidth - $this->strlen($key);
  51469. $messages[] = ' [<info>'.$key.str_repeat(' ', $width).'</info>] '.$value;
  51470. }
  51471. $output->writeln($messages);
  51472. $message = $question->getPrompt();
  51473. }
  51474. $output->write($message);
  51475. }
  51476. protected function writeError(OutputInterface $output, \Exception $error)
  51477. {
  51478. if (null !== $this->getHelperSet() && $this->getHelperSet()->has('formatter')) {
  51479. $message = $this->getHelperSet()->get('formatter')->formatBlock($error->getMessage(), 'error');
  51480. } else {
  51481. $message = '<error>'.$error->getMessage().'</error>';
  51482. }
  51483. $output->writeln($message);
  51484. }
  51485. private function autocomplete(OutputInterface $output, Question $question, $inputStream, array $autocomplete)
  51486. {
  51487. $ret = '';
  51488. $i = 0;
  51489. $ofs = -1;
  51490. $matches = $autocomplete;
  51491. $numMatches = \count($matches);
  51492. $sttyMode = shell_exec('stty -g');
  51493. shell_exec('stty -icanon -echo');
  51494. $output->getFormatter()->setStyle('hl', new OutputFormatterStyle('black', 'white'));
  51495. while (!feof($inputStream)) {
  51496. $c = fread($inputStream, 1);
  51497. if ("\177" === $c) {
  51498. if (0 === $numMatches && 0 !== $i) {
  51499. --$i;
  51500. $output->write("\033[1D");
  51501. }
  51502. if (0 === $i) {
  51503. $ofs = -1;
  51504. $matches = $autocomplete;
  51505. $numMatches = \count($matches);
  51506. } else {
  51507. $numMatches = 0;
  51508. }
  51509. $ret = substr($ret, 0, $i);
  51510. } elseif ("\033" === $c) {
  51511. $c .= fread($inputStream, 2);
  51512. if (isset($c[2]) && ('A' === $c[2] || 'B' === $c[2])) {
  51513. if ('A' === $c[2] && -1 === $ofs) {
  51514. $ofs = 0;
  51515. }
  51516. if (0 === $numMatches) {
  51517. continue;
  51518. }
  51519. $ofs += ('A' === $c[2]) ? -1 : 1;
  51520. $ofs = ($numMatches + $ofs) % $numMatches;
  51521. }
  51522. } elseif (\ord($c) < 32) {
  51523. if ("\t" === $c || "\n" === $c) {
  51524. if ($numMatches > 0 && -1 !== $ofs) {
  51525. $ret = $matches[$ofs];
  51526. $output->write(substr($ret, $i));
  51527. $i = \strlen($ret);
  51528. }
  51529. if ("\n" === $c) {
  51530. $output->write($c);
  51531. break;
  51532. }
  51533. $numMatches = 0;
  51534. }
  51535. continue;
  51536. } else {
  51537. $output->write($c);
  51538. $ret .= $c;
  51539. ++$i;
  51540. $numMatches = 0;
  51541. $ofs = 0;
  51542. foreach ($autocomplete as $value) {
  51543. if (0 === strpos($value, $ret)) {
  51544. $matches[$numMatches++] = $value;
  51545. }
  51546. }
  51547. }
  51548. $output->write("\033[K");
  51549. if ($numMatches > 0 && -1 !== $ofs) {
  51550. $output->write("\0337");
  51551. $output->write('<hl>'.OutputFormatter::escapeTrailingBackslash(substr($matches[$ofs], $i)).'</hl>');
  51552. $output->write("\0338");
  51553. }
  51554. }
  51555. shell_exec(sprintf('stty %s', $sttyMode));
  51556. return $ret;
  51557. }
  51558. private function getHiddenResponse(OutputInterface $output, $inputStream)
  51559. {
  51560. if ('\\' === \DIRECTORY_SEPARATOR) {
  51561. $exe = __DIR__.'/../Resources/bin/hiddeninput.exe';
  51562. if ('phar:' === substr(__FILE__, 0, 5)) {
  51563. $tmpExe = sys_get_temp_dir().'/hiddeninput.exe';
  51564. copy($exe, $tmpExe);
  51565. $exe = $tmpExe;
  51566. }
  51567. $value = rtrim(shell_exec($exe));
  51568. $output->writeln('');
  51569. if (isset($tmpExe)) {
  51570. unlink($tmpExe);
  51571. }
  51572. return $value;
  51573. }
  51574. if ($this->hasSttyAvailable()) {
  51575. $sttyMode = shell_exec('stty -g');
  51576. shell_exec('stty -echo');
  51577. $value = fgets($inputStream, 4096);
  51578. shell_exec(sprintf('stty %s', $sttyMode));
  51579. if (false === $value) {
  51580. throw new RuntimeException('Aborted');
  51581. }
  51582. $value = trim($value);
  51583. $output->writeln('');
  51584. return $value;
  51585. }
  51586. if (false !== $shell = $this->getShell()) {
  51587. $readCmd = 'csh' === $shell ? 'set mypassword = $<' : 'read -r mypassword';
  51588. $command = sprintf("/usr/bin/env %s -c 'stty -echo; %s; stty echo; echo \$mypassword'", $shell, $readCmd);
  51589. $value = rtrim(shell_exec($command));
  51590. $output->writeln('');
  51591. return $value;
  51592. }
  51593. throw new RuntimeException('Unable to hide the response.');
  51594. }
  51595. private function validateAttempts($interviewer, OutputInterface $output, Question $question)
  51596. {
  51597. $error = null;
  51598. $attempts = $question->getMaxAttempts();
  51599. while (null === $attempts || $attempts--) {
  51600. if (null !== $error) {
  51601. $this->writeError($output, $error);
  51602. }
  51603. try {
  51604. return \call_user_func($question->getValidator(), $interviewer());
  51605. } catch (RuntimeException $e) {
  51606. throw $e;
  51607. } catch (\Exception $error) {
  51608. }
  51609. }
  51610. throw $error;
  51611. }
  51612. private function getShell()
  51613. {
  51614. if (null !== self::$shell) {
  51615. return self::$shell;
  51616. }
  51617. self::$shell = false;
  51618. if (file_exists('/usr/bin/env')) {
  51619. $test = "/usr/bin/env %s -c 'echo OK' 2> /dev/null";
  51620. foreach (array('bash', 'zsh', 'ksh', 'csh') as $sh) {
  51621. if ('OK' === rtrim(shell_exec(sprintf($test, $sh)))) {
  51622. self::$shell = $sh;
  51623. break;
  51624. }
  51625. }
  51626. }
  51627. return self::$shell;
  51628. }
  51629. private function hasSttyAvailable()
  51630. {
  51631. if (null !== self::$stty) {
  51632. return self::$stty;
  51633. }
  51634. exec('stty 2>&1', $output, $exitcode);
  51635. return self::$stty = 0 === $exitcode;
  51636. }
  51637. }
  51638. <?php
  51639. namespace Symfony\Component\Console\Helper;
  51640. use Symfony\Component\Console\Exception\LogicException;
  51641. use Symfony\Component\Console\Formatter\OutputFormatter;
  51642. use Symfony\Component\Console\Input\InputInterface;
  51643. use Symfony\Component\Console\Output\OutputInterface;
  51644. use Symfony\Component\Console\Question\ChoiceQuestion;
  51645. use Symfony\Component\Console\Question\ConfirmationQuestion;
  51646. use Symfony\Component\Console\Question\Question;
  51647. use Symfony\Component\Console\Style\SymfonyStyle;
  51648. class SymfonyQuestionHelper extends QuestionHelper
  51649. {
  51650. public function ask(InputInterface $input, OutputInterface $output, Question $question)
  51651. {
  51652. $validator = $question->getValidator();
  51653. $question->setValidator(function ($value) use ($validator) {
  51654. if (null !== $validator) {
  51655. $value = $validator($value);
  51656. } else {
  51657. if (!\is_array($value) && !\is_bool($value) && 0 === \strlen($value)) {
  51658. throw new LogicException('A value is required.');
  51659. }
  51660. }
  51661. return $value;
  51662. });
  51663. return parent::ask($input, $output, $question);
  51664. }
  51665. protected function writePrompt(OutputInterface $output, Question $question)
  51666. {
  51667. $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion());
  51668. $default = $question->getDefault();
  51669. switch (true) {
  51670. case null === $default:
  51671. $text = sprintf(' <info>%s</info>:', $text);
  51672. break;
  51673. case $question instanceof ConfirmationQuestion:
  51674. $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no');
  51675. break;
  51676. case $question instanceof ChoiceQuestion && $question->isMultiselect():
  51677. $choices = $question->getChoices();
  51678. $default = explode(',', $default);
  51679. foreach ($default as $key => $value) {
  51680. $default[$key] = $choices[trim($value)];
  51681. }
  51682. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default)));
  51683. break;
  51684. case $question instanceof ChoiceQuestion:
  51685. $choices = $question->getChoices();
  51686. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(isset($choices[$default]) ? $choices[$default] : $default));
  51687. break;
  51688. default:
  51689. $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default));
  51690. }
  51691. $output->writeln($text);
  51692. if ($question instanceof ChoiceQuestion) {
  51693. $width = max(array_map('strlen', array_keys($question->getChoices())));
  51694. foreach ($question->getChoices() as $key => $value) {
  51695. $output->writeln(sprintf(" [<comment>%-${width}s</comment>] %s", $key, $value));
  51696. }
  51697. }
  51698. $output->write(' > ');
  51699. }
  51700. protected function writeError(OutputInterface $output, \Exception $error)
  51701. {
  51702. if ($output instanceof SymfonyStyle) {
  51703. $output->newLine();
  51704. $output->error($error->getMessage());
  51705. return;
  51706. }
  51707. parent::writeError($output, $error);
  51708. }
  51709. }
  51710. <?php
  51711. namespace Symfony\Component\Console\Helper;
  51712. use Symfony\Component\Console\Exception\InvalidArgumentException;
  51713. use Symfony\Component\Console\Output\OutputInterface;
  51714. class Table
  51715. {
  51716. private $headers = array();
  51717. private $rows = array();
  51718. private $columnWidths = array();
  51719. private $numberOfColumns;
  51720. private $output;
  51721. private $style;
  51722. private $columnStyles = array();
  51723. private static $styles;
  51724. public function __construct(OutputInterface $output)
  51725. {
  51726. $this->output = $output;
  51727. if (!self::$styles) {
  51728. self::$styles = self::initStyles();
  51729. }
  51730. $this->setStyle('default');
  51731. }
  51732. public static function setStyleDefinition($name, TableStyle $style)
  51733. {
  51734. if (!self::$styles) {
  51735. self::$styles = self::initStyles();
  51736. }
  51737. self::$styles[$name] = $style;
  51738. }
  51739. public static function getStyleDefinition($name)
  51740. {
  51741. if (!self::$styles) {
  51742. self::$styles = self::initStyles();
  51743. }
  51744. if (isset(self::$styles[$name])) {
  51745. return self::$styles[$name];
  51746. }
  51747. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  51748. }
  51749. public function setStyle($name)
  51750. {
  51751. $this->style = $this->resolveStyle($name);
  51752. return $this;
  51753. }
  51754. public function getStyle()
  51755. {
  51756. return $this->style;
  51757. }
  51758. public function setColumnStyle($columnIndex, $name)
  51759. {
  51760. $columnIndex = (int) $columnIndex;
  51761. $this->columnStyles[$columnIndex] = $this->resolveStyle($name);
  51762. return $this;
  51763. }
  51764. public function getColumnStyle($columnIndex)
  51765. {
  51766. if (isset($this->columnStyles[$columnIndex])) {
  51767. return $this->columnStyles[$columnIndex];
  51768. }
  51769. return $this->getStyle();
  51770. }
  51771. public function setHeaders(array $headers)
  51772. {
  51773. $headers = array_values($headers);
  51774. if (!empty($headers) && !\is_array($headers[0])) {
  51775. $headers = array($headers);
  51776. }
  51777. $this->headers = $headers;
  51778. return $this;
  51779. }
  51780. public function setRows(array $rows)
  51781. {
  51782. $this->rows = array();
  51783. return $this->addRows($rows);
  51784. }
  51785. public function addRows(array $rows)
  51786. {
  51787. foreach ($rows as $row) {
  51788. $this->addRow($row);
  51789. }
  51790. return $this;
  51791. }
  51792. public function addRow($row)
  51793. {
  51794. if ($row instanceof TableSeparator) {
  51795. $this->rows[] = $row;
  51796. return $this;
  51797. }
  51798. if (!\is_array($row)) {
  51799. throw new InvalidArgumentException('A row must be an array or a TableSeparator instance.');
  51800. }
  51801. $this->rows[] = array_values($row);
  51802. return $this;
  51803. }
  51804. public function setRow($column, array $row)
  51805. {
  51806. $this->rows[$column] = $row;
  51807. return $this;
  51808. }
  51809. public function render()
  51810. {
  51811. $this->calculateNumberOfColumns();
  51812. $rows = $this->buildTableRows($this->rows);
  51813. $headers = $this->buildTableRows($this->headers);
  51814. $this->calculateColumnsWidth(array_merge($headers, $rows));
  51815. $this->renderRowSeparator();
  51816. if (!empty($headers)) {
  51817. foreach ($headers as $header) {
  51818. $this->renderRow($header, $this->style->getCellHeaderFormat());
  51819. $this->renderRowSeparator();
  51820. }
  51821. }
  51822. foreach ($rows as $row) {
  51823. if ($row instanceof TableSeparator) {
  51824. $this->renderRowSeparator();
  51825. } else {
  51826. $this->renderRow($row, $this->style->getCellRowFormat());
  51827. }
  51828. }
  51829. if (!empty($rows)) {
  51830. $this->renderRowSeparator();
  51831. }
  51832. $this->cleanup();
  51833. }
  51834. private function renderRowSeparator()
  51835. {
  51836. if (0 === $count = $this->numberOfColumns) {
  51837. return;
  51838. }
  51839. if (!$this->style->getHorizontalBorderChar() && !$this->style->getCrossingChar()) {
  51840. return;
  51841. }
  51842. $markup = $this->style->getCrossingChar();
  51843. for ($column = 0; $column < $count; ++$column) {
  51844. $markup .= str_repeat($this->style->getHorizontalBorderChar(), $this->columnWidths[$column]).$this->style->getCrossingChar();
  51845. }
  51846. $this->output->writeln(sprintf($this->style->getBorderFormat(), $markup));
  51847. }
  51848. private function renderColumnSeparator()
  51849. {
  51850. return sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar());
  51851. }
  51852. private function renderRow(array $row, $cellFormat)
  51853. {
  51854. if (empty($row)) {
  51855. return;
  51856. }
  51857. $rowContent = $this->renderColumnSeparator();
  51858. foreach ($this->getRowColumns($row) as $column) {
  51859. $rowContent .= $this->renderCell($row, $column, $cellFormat);
  51860. $rowContent .= $this->renderColumnSeparator();
  51861. }
  51862. $this->output->writeln($rowContent);
  51863. }
  51864. private function renderCell(array $row, $column, $cellFormat)
  51865. {
  51866. $cell = isset($row[$column]) ? $row[$column] : '';
  51867. $width = $this->columnWidths[$column];
  51868. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  51869. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $nextColumn) {
  51870. $width += $this->getColumnSeparatorWidth() + $this->columnWidths[$nextColumn];
  51871. }
  51872. }
  51873. if (false !== $encoding = mb_detect_encoding($cell, null, true)) {
  51874. $width += \strlen($cell) - mb_strwidth($cell, $encoding);
  51875. }
  51876. $style = $this->getColumnStyle($column);
  51877. if ($cell instanceof TableSeparator) {
  51878. return sprintf($style->getBorderFormat(), str_repeat($style->getHorizontalBorderChar(), $width));
  51879. }
  51880. $width += Helper::strlen($cell) - Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  51881. $content = sprintf($style->getCellRowContentFormat(), $cell);
  51882. return sprintf($cellFormat, str_pad($content, $width, $style->getPaddingChar(), $style->getPadType()));
  51883. }
  51884. private function calculateNumberOfColumns()
  51885. {
  51886. if (null !== $this->numberOfColumns) {
  51887. return;
  51888. }
  51889. $columns = array(0);
  51890. foreach (array_merge($this->headers, $this->rows) as $row) {
  51891. if ($row instanceof TableSeparator) {
  51892. continue;
  51893. }
  51894. $columns[] = $this->getNumberOfColumns($row);
  51895. }
  51896. $this->numberOfColumns = max($columns);
  51897. }
  51898. private function buildTableRows($rows)
  51899. {
  51900. $unmergedRows = array();
  51901. for ($rowKey = 0; $rowKey < \count($rows); ++$rowKey) {
  51902. $rows = $this->fillNextRows($rows, $rowKey);
  51903. foreach ($rows[$rowKey] as $column => $cell) {
  51904. if (!strstr($cell, "\n")) {
  51905. continue;
  51906. }
  51907. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  51908. foreach ($lines as $lineKey => $line) {
  51909. if ($cell instanceof TableCell) {
  51910. $line = new TableCell($line, array('colspan' => $cell->getColspan()));
  51911. }
  51912. if (0 === $lineKey) {
  51913. $rows[$rowKey][$column] = $line;
  51914. } else {
  51915. $unmergedRows[$rowKey][$lineKey][$column] = $line;
  51916. }
  51917. }
  51918. }
  51919. }
  51920. $tableRows = array();
  51921. foreach ($rows as $rowKey => $row) {
  51922. $tableRows[] = $this->fillCells($row);
  51923. if (isset($unmergedRows[$rowKey])) {
  51924. $tableRows = array_merge($tableRows, $unmergedRows[$rowKey]);
  51925. }
  51926. }
  51927. return $tableRows;
  51928. }
  51929. private function fillNextRows(array $rows, $line)
  51930. {
  51931. $unmergedRows = array();
  51932. foreach ($rows[$line] as $column => $cell) {
  51933. if ($cell instanceof TableCell && $cell->getRowspan() > 1) {
  51934. $nbLines = $cell->getRowspan() - 1;
  51935. $lines = array($cell);
  51936. if (strstr($cell, "\n")) {
  51937. $lines = explode("\n", str_replace("\n", "<fg=default;bg=default>\n</>", $cell));
  51938. $nbLines = \count($lines) > $nbLines ? substr_count($cell, "\n") : $nbLines;
  51939. $rows[$line][$column] = new TableCell($lines[0], array('colspan' => $cell->getColspan()));
  51940. unset($lines[0]);
  51941. }
  51942. $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, array()), $unmergedRows);
  51943. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  51944. $value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : '';
  51945. $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan()));
  51946. if ($nbLines === $unmergedRowKey - $line) {
  51947. break;
  51948. }
  51949. }
  51950. }
  51951. }
  51952. foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) {
  51953. if (isset($rows[$unmergedRowKey]) && \is_array($rows[$unmergedRowKey]) && ($this->getNumberOfColumns($rows[$unmergedRowKey]) + $this->getNumberOfColumns($unmergedRows[$unmergedRowKey]) <= $this->numberOfColumns)) {
  51954. foreach ($unmergedRow as $cellKey => $cell) {
  51955. array_splice($rows[$unmergedRowKey], $cellKey, 0, array($cell));
  51956. }
  51957. } else {
  51958. $row = $this->copyRow($rows, $unmergedRowKey - 1);
  51959. foreach ($unmergedRow as $column => $cell) {
  51960. if (!empty($cell)) {
  51961. $row[$column] = $unmergedRow[$column];
  51962. }
  51963. }
  51964. array_splice($rows, $unmergedRowKey, 0, array($row));
  51965. }
  51966. }
  51967. return $rows;
  51968. }
  51969. private function fillCells($row)
  51970. {
  51971. $newRow = array();
  51972. foreach ($row as $column => $cell) {
  51973. $newRow[] = $cell;
  51974. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  51975. foreach (range($column + 1, $column + $cell->getColspan() - 1) as $position) {
  51976. $newRow[] = '';
  51977. }
  51978. }
  51979. }
  51980. return $newRow ?: $row;
  51981. }
  51982. private function copyRow(array $rows, $line)
  51983. {
  51984. $row = $rows[$line];
  51985. foreach ($row as $cellKey => $cellValue) {
  51986. $row[$cellKey] = '';
  51987. if ($cellValue instanceof TableCell) {
  51988. $row[$cellKey] = new TableCell('', array('colspan' => $cellValue->getColspan()));
  51989. }
  51990. }
  51991. return $row;
  51992. }
  51993. private function getNumberOfColumns(array $row)
  51994. {
  51995. $columns = \count($row);
  51996. foreach ($row as $column) {
  51997. $columns += $column instanceof TableCell ? ($column->getColspan() - 1) : 0;
  51998. }
  51999. return $columns;
  52000. }
  52001. private function getRowColumns(array $row)
  52002. {
  52003. $columns = range(0, $this->numberOfColumns - 1);
  52004. foreach ($row as $cellKey => $cell) {
  52005. if ($cell instanceof TableCell && $cell->getColspan() > 1) {
  52006. $columns = array_diff($columns, range($cellKey + 1, $cellKey + $cell->getColspan() - 1));
  52007. }
  52008. }
  52009. return $columns;
  52010. }
  52011. private function calculateColumnsWidth($rows)
  52012. {
  52013. for ($column = 0; $column < $this->numberOfColumns; ++$column) {
  52014. $lengths = array();
  52015. foreach ($rows as $row) {
  52016. if ($row instanceof TableSeparator) {
  52017. continue;
  52018. }
  52019. foreach ($row as $i => $cell) {
  52020. if ($cell instanceof TableCell) {
  52021. $textContent = Helper::removeDecoration($this->output->getFormatter(), $cell);
  52022. $textLength = Helper::strlen($textContent);
  52023. if ($textLength > 0) {
  52024. $contentColumns = str_split($textContent, ceil($textLength / $cell->getColspan()));
  52025. foreach ($contentColumns as $position => $content) {
  52026. $row[$i + $position] = $content;
  52027. }
  52028. }
  52029. }
  52030. }
  52031. $lengths[] = $this->getCellWidth($row, $column);
  52032. }
  52033. $this->columnWidths[$column] = max($lengths) + Helper::strlen($this->style->getCellRowContentFormat()) - 2;
  52034. }
  52035. }
  52036. private function getColumnSeparatorWidth()
  52037. {
  52038. return Helper::strlen(sprintf($this->style->getBorderFormat(), $this->style->getVerticalBorderChar()));
  52039. }
  52040. private function getCellWidth(array $row, $column)
  52041. {
  52042. if (isset($row[$column])) {
  52043. $cell = $row[$column];
  52044. $cellWidth = Helper::strlenWithoutDecoration($this->output->getFormatter(), $cell);
  52045. return $cellWidth;
  52046. }
  52047. return 0;
  52048. }
  52049. private function cleanup()
  52050. {
  52051. $this->columnWidths = array();
  52052. $this->numberOfColumns = null;
  52053. }
  52054. private static function initStyles()
  52055. {
  52056. $borderless = new TableStyle();
  52057. $borderless
  52058. ->setHorizontalBorderChar('=')
  52059. ->setVerticalBorderChar(' ')
  52060. ->setCrossingChar(' ')
  52061. ;
  52062. $compact = new TableStyle();
  52063. $compact
  52064. ->setHorizontalBorderChar('')
  52065. ->setVerticalBorderChar(' ')
  52066. ->setCrossingChar('')
  52067. ->setCellRowContentFormat('%s')
  52068. ;
  52069. $styleGuide = new TableStyle();
  52070. $styleGuide
  52071. ->setHorizontalBorderChar('-')
  52072. ->setVerticalBorderChar(' ')
  52073. ->setCrossingChar(' ')
  52074. ->setCellHeaderFormat('%s')
  52075. ;
  52076. return array(
  52077. 'default' => new TableStyle(),
  52078. 'borderless' => $borderless,
  52079. 'compact' => $compact,
  52080. 'symfony-style-guide' => $styleGuide,
  52081. );
  52082. }
  52083. private function resolveStyle($name)
  52084. {
  52085. if ($name instanceof TableStyle) {
  52086. return $name;
  52087. }
  52088. if (isset(self::$styles[$name])) {
  52089. return self::$styles[$name];
  52090. }
  52091. throw new InvalidArgumentException(sprintf('Style "%s" is not defined.', $name));
  52092. }
  52093. }
  52094. <?php
  52095. namespace Symfony\Component\Console\Helper;
  52096. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52097. class TableCell
  52098. {
  52099. private $value;
  52100. private $options = array(
  52101. 'rowspan' => 1,
  52102. 'colspan' => 1,
  52103. );
  52104. public function __construct($value = '', array $options = array())
  52105. {
  52106. if (is_numeric($value) && !\is_string($value)) {
  52107. $value = (string) $value;
  52108. }
  52109. $this->value = $value;
  52110. if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
  52111. throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff)));
  52112. }
  52113. $this->options = array_merge($this->options, $options);
  52114. }
  52115. public function __toString()
  52116. {
  52117. return $this->value;
  52118. }
  52119. public function getColspan()
  52120. {
  52121. return (int) $this->options['colspan'];
  52122. }
  52123. public function getRowspan()
  52124. {
  52125. return (int) $this->options['rowspan'];
  52126. }
  52127. }
  52128. <?php
  52129. namespace Symfony\Component\Console\Helper;
  52130. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52131. use Symfony\Component\Console\Output\NullOutput;
  52132. use Symfony\Component\Console\Output\OutputInterface;
  52133. class TableHelper extends Helper
  52134. {
  52135. const LAYOUT_DEFAULT = 0;
  52136. const LAYOUT_BORDERLESS = 1;
  52137. const LAYOUT_COMPACT = 2;
  52138. private $table;
  52139. public function __construct($triggerDeprecationError = true)
  52140. {
  52141. if ($triggerDeprecationError) {
  52142. @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);
  52143. }
  52144. $this->table = new Table(new NullOutput());
  52145. }
  52146. public function setLayout($layout)
  52147. {
  52148. switch ($layout) {
  52149. case self::LAYOUT_BORDERLESS:
  52150. $this->table->setStyle('borderless');
  52151. break;
  52152. case self::LAYOUT_COMPACT:
  52153. $this->table->setStyle('compact');
  52154. break;
  52155. case self::LAYOUT_DEFAULT:
  52156. $this->table->setStyle('default');
  52157. break;
  52158. default:
  52159. throw new InvalidArgumentException(sprintf('Invalid table layout "%s".', $layout));
  52160. }
  52161. return $this;
  52162. }
  52163. public function setHeaders(array $headers)
  52164. {
  52165. $this->table->setHeaders($headers);
  52166. return $this;
  52167. }
  52168. public function setRows(array $rows)
  52169. {
  52170. $this->table->setRows($rows);
  52171. return $this;
  52172. }
  52173. public function addRows(array $rows)
  52174. {
  52175. $this->table->addRows($rows);
  52176. return $this;
  52177. }
  52178. public function addRow(array $row)
  52179. {
  52180. $this->table->addRow($row);
  52181. return $this;
  52182. }
  52183. public function setRow($column, array $row)
  52184. {
  52185. $this->table->setRow($column, $row);
  52186. return $this;
  52187. }
  52188. public function setPaddingChar($paddingChar)
  52189. {
  52190. $this->table->getStyle()->setPaddingChar($paddingChar);
  52191. return $this;
  52192. }
  52193. public function setHorizontalBorderChar($horizontalBorderChar)
  52194. {
  52195. $this->table->getStyle()->setHorizontalBorderChar($horizontalBorderChar);
  52196. return $this;
  52197. }
  52198. public function setVerticalBorderChar($verticalBorderChar)
  52199. {
  52200. $this->table->getStyle()->setVerticalBorderChar($verticalBorderChar);
  52201. return $this;
  52202. }
  52203. public function setCrossingChar($crossingChar)
  52204. {
  52205. $this->table->getStyle()->setCrossingChar($crossingChar);
  52206. return $this;
  52207. }
  52208. public function setCellHeaderFormat($cellHeaderFormat)
  52209. {
  52210. $this->table->getStyle()->setCellHeaderFormat($cellHeaderFormat);
  52211. return $this;
  52212. }
  52213. public function setCellRowFormat($cellRowFormat)
  52214. {
  52215. $this->table->getStyle()->setCellHeaderFormat($cellRowFormat);
  52216. return $this;
  52217. }
  52218. public function setCellRowContentFormat($cellRowContentFormat)
  52219. {
  52220. $this->table->getStyle()->setCellRowContentFormat($cellRowContentFormat);
  52221. return $this;
  52222. }
  52223. public function setBorderFormat($borderFormat)
  52224. {
  52225. $this->table->getStyle()->setBorderFormat($borderFormat);
  52226. return $this;
  52227. }
  52228. public function setPadType($padType)
  52229. {
  52230. $this->table->getStyle()->setPadType($padType);
  52231. return $this;
  52232. }
  52233. public function render(OutputInterface $output)
  52234. {
  52235. $p = new \ReflectionProperty($this->table, 'output');
  52236. $p->setAccessible(true);
  52237. $p->setValue($this->table, $output);
  52238. $this->table->render();
  52239. }
  52240. public function getName()
  52241. {
  52242. return 'table';
  52243. }
  52244. }
  52245. <?php
  52246. namespace Symfony\Component\Console\Helper;
  52247. class TableSeparator extends TableCell
  52248. {
  52249. public function __construct(array $options = array())
  52250. {
  52251. parent::__construct('', $options);
  52252. }
  52253. }
  52254. <?php
  52255. namespace Symfony\Component\Console\Helper;
  52256. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52257. use Symfony\Component\Console\Exception\LogicException;
  52258. class TableStyle
  52259. {
  52260. private $paddingChar = ' ';
  52261. private $horizontalBorderChar = '-';
  52262. private $verticalBorderChar = '|';
  52263. private $crossingChar = '+';
  52264. private $cellHeaderFormat = '<info>%s</info>';
  52265. private $cellRowFormat = '%s';
  52266. private $cellRowContentFormat = ' %s ';
  52267. private $borderFormat = '%s';
  52268. private $padType = STR_PAD_RIGHT;
  52269. public function setPaddingChar($paddingChar)
  52270. {
  52271. if (!$paddingChar) {
  52272. throw new LogicException('The padding char must not be empty');
  52273. }
  52274. $this->paddingChar = $paddingChar;
  52275. return $this;
  52276. }
  52277. public function getPaddingChar()
  52278. {
  52279. return $this->paddingChar;
  52280. }
  52281. public function setHorizontalBorderChar($horizontalBorderChar)
  52282. {
  52283. $this->horizontalBorderChar = $horizontalBorderChar;
  52284. return $this;
  52285. }
  52286. public function getHorizontalBorderChar()
  52287. {
  52288. return $this->horizontalBorderChar;
  52289. }
  52290. public function setVerticalBorderChar($verticalBorderChar)
  52291. {
  52292. $this->verticalBorderChar = $verticalBorderChar;
  52293. return $this;
  52294. }
  52295. public function getVerticalBorderChar()
  52296. {
  52297. return $this->verticalBorderChar;
  52298. }
  52299. public function setCrossingChar($crossingChar)
  52300. {
  52301. $this->crossingChar = $crossingChar;
  52302. return $this;
  52303. }
  52304. public function getCrossingChar()
  52305. {
  52306. return $this->crossingChar;
  52307. }
  52308. public function setCellHeaderFormat($cellHeaderFormat)
  52309. {
  52310. $this->cellHeaderFormat = $cellHeaderFormat;
  52311. return $this;
  52312. }
  52313. public function getCellHeaderFormat()
  52314. {
  52315. return $this->cellHeaderFormat;
  52316. }
  52317. public function setCellRowFormat($cellRowFormat)
  52318. {
  52319. $this->cellRowFormat = $cellRowFormat;
  52320. return $this;
  52321. }
  52322. public function getCellRowFormat()
  52323. {
  52324. return $this->cellRowFormat;
  52325. }
  52326. public function setCellRowContentFormat($cellRowContentFormat)
  52327. {
  52328. $this->cellRowContentFormat = $cellRowContentFormat;
  52329. return $this;
  52330. }
  52331. public function getCellRowContentFormat()
  52332. {
  52333. return $this->cellRowContentFormat;
  52334. }
  52335. public function setBorderFormat($borderFormat)
  52336. {
  52337. $this->borderFormat = $borderFormat;
  52338. return $this;
  52339. }
  52340. public function getBorderFormat()
  52341. {
  52342. return $this->borderFormat;
  52343. }
  52344. public function setPadType($padType)
  52345. {
  52346. if (!\in_array($padType, array(STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH), true)) {
  52347. throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
  52348. }
  52349. $this->padType = $padType;
  52350. return $this;
  52351. }
  52352. public function getPadType()
  52353. {
  52354. return $this->padType;
  52355. }
  52356. }
  52357. <?php
  52358. namespace Symfony\Component\Console\Input;
  52359. use Symfony\Component\Console\Exception\RuntimeException;
  52360. class ArgvInput extends Input
  52361. {
  52362. private $tokens;
  52363. private $parsed;
  52364. public function __construct(array $argv = null, InputDefinition $definition = null)
  52365. {
  52366. if (null === $argv) {
  52367. $argv = $_SERVER['argv'];
  52368. }
  52369. array_shift($argv);
  52370. $this->tokens = $argv;
  52371. parent::__construct($definition);
  52372. }
  52373. protected function setTokens(array $tokens)
  52374. {
  52375. $this->tokens = $tokens;
  52376. }
  52377. protected function parse()
  52378. {
  52379. $parseOptions = true;
  52380. $this->parsed = $this->tokens;
  52381. while (null !== $token = array_shift($this->parsed)) {
  52382. if ($parseOptions && '' == $token) {
  52383. $this->parseArgument($token);
  52384. } elseif ($parseOptions && '--' == $token) {
  52385. $parseOptions = false;
  52386. } elseif ($parseOptions && 0 === strpos($token, '--')) {
  52387. $this->parseLongOption($token);
  52388. } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
  52389. $this->parseShortOption($token);
  52390. } else {
  52391. $this->parseArgument($token);
  52392. }
  52393. }
  52394. }
  52395. private function parseShortOption($token)
  52396. {
  52397. $name = substr($token, 1);
  52398. if (\strlen($name) > 1) {
  52399. if ($this->definition->hasShortcut($name[0]) && $this->definition->getOptionForShortcut($name[0])->acceptValue()) {
  52400. $this->addShortOption($name[0], substr($name, 1));
  52401. } else {
  52402. $this->parseShortOptionSet($name);
  52403. }
  52404. } else {
  52405. $this->addShortOption($name, null);
  52406. }
  52407. }
  52408. private function parseShortOptionSet($name)
  52409. {
  52410. $len = \strlen($name);
  52411. for ($i = 0; $i < $len; ++$i) {
  52412. if (!$this->definition->hasShortcut($name[$i])) {
  52413. $encoding = mb_detect_encoding($name, null, true);
  52414. throw new RuntimeException(sprintf('The "-%s" option does not exist.', false === $encoding ? $name[$i] : mb_substr($name, $i, 1, $encoding)));
  52415. }
  52416. $option = $this->definition->getOptionForShortcut($name[$i]);
  52417. if ($option->acceptValue()) {
  52418. $this->addLongOption($option->getName(), $i === $len - 1 ? null : substr($name, $i + 1));
  52419. break;
  52420. } else {
  52421. $this->addLongOption($option->getName(), null);
  52422. }
  52423. }
  52424. }
  52425. private function parseLongOption($token)
  52426. {
  52427. $name = substr($token, 2);
  52428. if (false !== $pos = strpos($name, '=')) {
  52429. if (0 === \strlen($value = substr($name, $pos + 1))) {
  52430. array_unshift($this->parsed, null);
  52431. }
  52432. $this->addLongOption(substr($name, 0, $pos), $value);
  52433. } else {
  52434. $this->addLongOption($name, null);
  52435. }
  52436. }
  52437. private function parseArgument($token)
  52438. {
  52439. $c = \count($this->arguments);
  52440. if ($this->definition->hasArgument($c)) {
  52441. $arg = $this->definition->getArgument($c);
  52442. $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token;
  52443. } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
  52444. $arg = $this->definition->getArgument($c - 1);
  52445. $this->arguments[$arg->getName()][] = $token;
  52446. } else {
  52447. $all = $this->definition->getArguments();
  52448. if (\count($all)) {
  52449. throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
  52450. }
  52451. throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
  52452. }
  52453. }
  52454. private function addShortOption($shortcut, $value)
  52455. {
  52456. if (!$this->definition->hasShortcut($shortcut)) {
  52457. throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
  52458. }
  52459. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  52460. }
  52461. private function addLongOption($name, $value)
  52462. {
  52463. if (!$this->definition->hasOption($name)) {
  52464. throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
  52465. }
  52466. $option = $this->definition->getOption($name);
  52467. if (!isset($value[0])) {
  52468. $value = null;
  52469. }
  52470. if (null !== $value && !$option->acceptValue()) {
  52471. throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
  52472. }
  52473. if (null === $value && $option->acceptValue() && \count($this->parsed)) {
  52474. $next = array_shift($this->parsed);
  52475. if (isset($next[0]) && '-' !== $next[0]) {
  52476. $value = $next;
  52477. } elseif (empty($next)) {
  52478. $value = null;
  52479. } else {
  52480. array_unshift($this->parsed, $next);
  52481. }
  52482. }
  52483. if (null === $value) {
  52484. if ($option->isValueRequired()) {
  52485. throw new RuntimeException(sprintf('The "--%s" option requires a value.', $name));
  52486. }
  52487. if (!$option->isArray()) {
  52488. $value = $option->isValueOptional() ? $option->getDefault() : true;
  52489. }
  52490. }
  52491. if ($option->isArray()) {
  52492. $this->options[$name][] = $value;
  52493. } else {
  52494. $this->options[$name] = $value;
  52495. }
  52496. }
  52497. public function getFirstArgument()
  52498. {
  52499. foreach ($this->tokens as $token) {
  52500. if ($token && '-' === $token[0]) {
  52501. continue;
  52502. }
  52503. return $token;
  52504. }
  52505. }
  52506. public function hasParameterOption($values)
  52507. {
  52508. $values = (array) $values;
  52509. foreach ($this->tokens as $token) {
  52510. foreach ($values as $value) {
  52511. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  52512. if ($token === $value || '' !== $leading && 0 === strpos($token, $leading)) {
  52513. return true;
  52514. }
  52515. }
  52516. }
  52517. return false;
  52518. }
  52519. public function getParameterOption($values, $default = false)
  52520. {
  52521. $values = (array) $values;
  52522. $tokens = $this->tokens;
  52523. while (0 < \count($tokens)) {
  52524. $token = array_shift($tokens);
  52525. foreach ($values as $value) {
  52526. if ($token === $value) {
  52527. return array_shift($tokens);
  52528. }
  52529. $leading = 0 === strpos($value, '--') ? $value.'=' : $value;
  52530. if ('' !== $leading && 0 === strpos($token, $leading)) {
  52531. return substr($token, \strlen($leading));
  52532. }
  52533. }
  52534. }
  52535. return $default;
  52536. }
  52537. public function __toString()
  52538. {
  52539. $self = $this;
  52540. $tokens = array_map(function ($token) use ($self) {
  52541. if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {
  52542. return $match[1].$self->escapeToken($match[2]);
  52543. }
  52544. if ($token && '-' !== $token[0]) {
  52545. return $self->escapeToken($token);
  52546. }
  52547. return $token;
  52548. }, $this->tokens);
  52549. return implode(' ', $tokens);
  52550. }
  52551. }
  52552. <?php
  52553. namespace Symfony\Component\Console\Input;
  52554. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52555. use Symfony\Component\Console\Exception\InvalidOptionException;
  52556. class ArrayInput extends Input
  52557. {
  52558. private $parameters;
  52559. public function __construct(array $parameters, InputDefinition $definition = null)
  52560. {
  52561. $this->parameters = $parameters;
  52562. parent::__construct($definition);
  52563. }
  52564. public function getFirstArgument()
  52565. {
  52566. foreach ($this->parameters as $key => $value) {
  52567. if ($key && '-' === $key[0]) {
  52568. continue;
  52569. }
  52570. return $value;
  52571. }
  52572. }
  52573. public function hasParameterOption($values)
  52574. {
  52575. $values = (array) $values;
  52576. foreach ($this->parameters as $k => $v) {
  52577. if (!\is_int($k)) {
  52578. $v = $k;
  52579. }
  52580. if (\in_array($v, $values)) {
  52581. return true;
  52582. }
  52583. }
  52584. return false;
  52585. }
  52586. public function getParameterOption($values, $default = false)
  52587. {
  52588. $values = (array) $values;
  52589. foreach ($this->parameters as $k => $v) {
  52590. if (\is_int($k)) {
  52591. if (\in_array($v, $values)) {
  52592. return true;
  52593. }
  52594. } elseif (\in_array($k, $values)) {
  52595. return $v;
  52596. }
  52597. }
  52598. return $default;
  52599. }
  52600. public function __toString()
  52601. {
  52602. $params = array();
  52603. foreach ($this->parameters as $param => $val) {
  52604. if ($param && '-' === $param[0]) {
  52605. if (\is_array($val)) {
  52606. foreach ($val as $v) {
  52607. $params[] = $param.('' != $v ? '='.$this->escapeToken($v) : '');
  52608. }
  52609. } else {
  52610. $params[] = $param.('' != $val ? '='.$this->escapeToken($val) : '');
  52611. }
  52612. } else {
  52613. $params[] = \is_array($val) ? implode(' ', array_map(array($this, 'escapeToken'), $val)) : $this->escapeToken($val);
  52614. }
  52615. }
  52616. return implode(' ', $params);
  52617. }
  52618. protected function parse()
  52619. {
  52620. foreach ($this->parameters as $key => $value) {
  52621. if (0 === strpos($key, '--')) {
  52622. $this->addLongOption(substr($key, 2), $value);
  52623. } elseif ('-' === $key[0]) {
  52624. $this->addShortOption(substr($key, 1), $value);
  52625. } else {
  52626. $this->addArgument($key, $value);
  52627. }
  52628. }
  52629. }
  52630. private function addShortOption($shortcut, $value)
  52631. {
  52632. if (!$this->definition->hasShortcut($shortcut)) {
  52633. throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
  52634. }
  52635. $this->addLongOption($this->definition->getOptionForShortcut($shortcut)->getName(), $value);
  52636. }
  52637. private function addLongOption($name, $value)
  52638. {
  52639. if (!$this->definition->hasOption($name)) {
  52640. throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
  52641. }
  52642. $option = $this->definition->getOption($name);
  52643. if (null === $value) {
  52644. if ($option->isValueRequired()) {
  52645. throw new InvalidOptionException(sprintf('The "--%s" option requires a value.', $name));
  52646. }
  52647. $value = $option->isValueOptional() ? $option->getDefault() : true;
  52648. }
  52649. $this->options[$name] = $value;
  52650. }
  52651. private function addArgument($name, $value)
  52652. {
  52653. if (!$this->definition->hasArgument($name)) {
  52654. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52655. }
  52656. $this->arguments[$name] = $value;
  52657. }
  52658. }
  52659. <?php
  52660. namespace Symfony\Component\Console\Input;
  52661. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52662. use Symfony\Component\Console\Exception\RuntimeException;
  52663. abstract class Input implements InputInterface
  52664. {
  52665. protected $definition;
  52666. protected $options = array();
  52667. protected $arguments = array();
  52668. protected $interactive = true;
  52669. public function __construct(InputDefinition $definition = null)
  52670. {
  52671. if (null === $definition) {
  52672. $this->definition = new InputDefinition();
  52673. } else {
  52674. $this->bind($definition);
  52675. $this->validate();
  52676. }
  52677. }
  52678. public function bind(InputDefinition $definition)
  52679. {
  52680. $this->arguments = array();
  52681. $this->options = array();
  52682. $this->definition = $definition;
  52683. $this->parse();
  52684. }
  52685. abstract protected function parse();
  52686. public function validate()
  52687. {
  52688. $definition = $this->definition;
  52689. $givenArguments = $this->arguments;
  52690. $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) {
  52691. return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired();
  52692. });
  52693. if (\count($missingArguments) > 0) {
  52694. throw new RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(', ', $missingArguments)));
  52695. }
  52696. }
  52697. public function isInteractive()
  52698. {
  52699. return $this->interactive;
  52700. }
  52701. public function setInteractive($interactive)
  52702. {
  52703. $this->interactive = (bool) $interactive;
  52704. }
  52705. public function getArguments()
  52706. {
  52707. return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
  52708. }
  52709. public function getArgument($name)
  52710. {
  52711. if (!$this->definition->hasArgument($name)) {
  52712. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52713. }
  52714. return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault();
  52715. }
  52716. public function setArgument($name, $value)
  52717. {
  52718. if (!$this->definition->hasArgument($name)) {
  52719. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52720. }
  52721. $this->arguments[$name] = $value;
  52722. }
  52723. public function hasArgument($name)
  52724. {
  52725. return $this->definition->hasArgument($name);
  52726. }
  52727. public function getOptions()
  52728. {
  52729. return array_merge($this->definition->getOptionDefaults(), $this->options);
  52730. }
  52731. public function getOption($name)
  52732. {
  52733. if (!$this->definition->hasOption($name)) {
  52734. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  52735. }
  52736. return isset($this->options[$name]) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
  52737. }
  52738. public function setOption($name, $value)
  52739. {
  52740. if (!$this->definition->hasOption($name)) {
  52741. throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
  52742. }
  52743. $this->options[$name] = $value;
  52744. }
  52745. public function hasOption($name)
  52746. {
  52747. return $this->definition->hasOption($name);
  52748. }
  52749. public function escapeToken($token)
  52750. {
  52751. return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
  52752. }
  52753. }
  52754. <?php
  52755. namespace Symfony\Component\Console\Input;
  52756. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52757. use Symfony\Component\Console\Exception\LogicException;
  52758. class InputArgument
  52759. {
  52760. const REQUIRED = 1;
  52761. const OPTIONAL = 2;
  52762. const IS_ARRAY = 4;
  52763. private $name;
  52764. private $mode;
  52765. private $default;
  52766. private $description;
  52767. public function __construct($name, $mode = null, $description = '', $default = null)
  52768. {
  52769. if (null === $mode) {
  52770. $mode = self::OPTIONAL;
  52771. } elseif (!\is_int($mode) || $mode > 7 || $mode < 1) {
  52772. throw new InvalidArgumentException(sprintf('Argument mode "%s" is not valid.', $mode));
  52773. }
  52774. $this->name = $name;
  52775. $this->mode = $mode;
  52776. $this->description = $description;
  52777. $this->setDefault($default);
  52778. }
  52779. public function getName()
  52780. {
  52781. return $this->name;
  52782. }
  52783. public function isRequired()
  52784. {
  52785. return self::REQUIRED === (self::REQUIRED & $this->mode);
  52786. }
  52787. public function isArray()
  52788. {
  52789. return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
  52790. }
  52791. public function setDefault($default = null)
  52792. {
  52793. if (self::REQUIRED === $this->mode && null !== $default) {
  52794. throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
  52795. }
  52796. if ($this->isArray()) {
  52797. if (null === $default) {
  52798. $default = array();
  52799. } elseif (!\is_array($default)) {
  52800. throw new LogicException('A default value for an array argument must be an array.');
  52801. }
  52802. }
  52803. $this->default = $default;
  52804. }
  52805. public function getDefault()
  52806. {
  52807. return $this->default;
  52808. }
  52809. public function getDescription()
  52810. {
  52811. return $this->description;
  52812. }
  52813. }
  52814. <?php
  52815. namespace Symfony\Component\Console\Input;
  52816. interface InputAwareInterface
  52817. {
  52818. public function setInput(InputInterface $input);
  52819. }
  52820. <?php
  52821. namespace Symfony\Component\Console\Input;
  52822. use Symfony\Component\Console\Descriptor\TextDescriptor;
  52823. use Symfony\Component\Console\Descriptor\XmlDescriptor;
  52824. use Symfony\Component\Console\Exception\InvalidArgumentException;
  52825. use Symfony\Component\Console\Exception\LogicException;
  52826. use Symfony\Component\Console\Output\BufferedOutput;
  52827. class InputDefinition
  52828. {
  52829. private $arguments;
  52830. private $requiredCount;
  52831. private $hasAnArrayArgument = false;
  52832. private $hasOptional;
  52833. private $options;
  52834. private $shortcuts;
  52835. public function __construct(array $definition = array())
  52836. {
  52837. $this->setDefinition($definition);
  52838. }
  52839. public function setDefinition(array $definition)
  52840. {
  52841. $arguments = array();
  52842. $options = array();
  52843. foreach ($definition as $item) {
  52844. if ($item instanceof InputOption) {
  52845. $options[] = $item;
  52846. } else {
  52847. $arguments[] = $item;
  52848. }
  52849. }
  52850. $this->setArguments($arguments);
  52851. $this->setOptions($options);
  52852. }
  52853. public function setArguments($arguments = array())
  52854. {
  52855. $this->arguments = array();
  52856. $this->requiredCount = 0;
  52857. $this->hasOptional = false;
  52858. $this->hasAnArrayArgument = false;
  52859. $this->addArguments($arguments);
  52860. }
  52861. public function addArguments($arguments = array())
  52862. {
  52863. if (null !== $arguments) {
  52864. foreach ($arguments as $argument) {
  52865. $this->addArgument($argument);
  52866. }
  52867. }
  52868. }
  52869. public function addArgument(InputArgument $argument)
  52870. {
  52871. if (isset($this->arguments[$argument->getName()])) {
  52872. throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
  52873. }
  52874. if ($this->hasAnArrayArgument) {
  52875. throw new LogicException('Cannot add an argument after an array argument.');
  52876. }
  52877. if ($argument->isRequired() && $this->hasOptional) {
  52878. throw new LogicException('Cannot add a required argument after an optional one.');
  52879. }
  52880. if ($argument->isArray()) {
  52881. $this->hasAnArrayArgument = true;
  52882. }
  52883. if ($argument->isRequired()) {
  52884. ++$this->requiredCount;
  52885. } else {
  52886. $this->hasOptional = true;
  52887. }
  52888. $this->arguments[$argument->getName()] = $argument;
  52889. }
  52890. public function getArgument($name)
  52891. {
  52892. if (!$this->hasArgument($name)) {
  52893. throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
  52894. }
  52895. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  52896. return $arguments[$name];
  52897. }
  52898. public function hasArgument($name)
  52899. {
  52900. $arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
  52901. return isset($arguments[$name]);
  52902. }
  52903. public function getArguments()
  52904. {
  52905. return $this->arguments;
  52906. }
  52907. public function getArgumentCount()
  52908. {
  52909. return $this->hasAnArrayArgument ? PHP_INT_MAX : \count($this->arguments);
  52910. }
  52911. public function getArgumentRequiredCount()
  52912. {
  52913. return $this->requiredCount;
  52914. }
  52915. public function getArgumentDefaults()
  52916. {
  52917. $values = array();
  52918. foreach ($this->arguments as $argument) {
  52919. $values[$argument->getName()] = $argument->getDefault();
  52920. }
  52921. return $values;
  52922. }
  52923. public function setOptions($options = array())
  52924. {
  52925. $this->options = array();
  52926. $this->shortcuts = array();
  52927. $this->addOptions($options);
  52928. }
  52929. public function addOptions($options = array())
  52930. {
  52931. foreach ($options as $option) {
  52932. $this->addOption($option);
  52933. }
  52934. }
  52935. public function addOption(InputOption $option)
  52936. {
  52937. if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
  52938. throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
  52939. }
  52940. if ($option->getShortcut()) {
  52941. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  52942. if (isset($this->shortcuts[$shortcut]) && !$option->equals($this->options[$this->shortcuts[$shortcut]])) {
  52943. throw new LogicException(sprintf('An option with shortcut "%s" already exists.', $shortcut));
  52944. }
  52945. }
  52946. }
  52947. $this->options[$option->getName()] = $option;
  52948. if ($option->getShortcut()) {
  52949. foreach (explode('|', $option->getShortcut()) as $shortcut) {
  52950. $this->shortcuts[$shortcut] = $option->getName();
  52951. }
  52952. }
  52953. }
  52954. public function getOption($name)
  52955. {
  52956. if (!$this->hasOption($name)) {
  52957. throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
  52958. }
  52959. return $this->options[$name];
  52960. }
  52961. public function hasOption($name)
  52962. {
  52963. return isset($this->options[$name]);
  52964. }
  52965. public function getOptions()
  52966. {
  52967. return $this->options;
  52968. }
  52969. public function hasShortcut($name)
  52970. {
  52971. return isset($this->shortcuts[$name]);
  52972. }
  52973. public function getOptionForShortcut($shortcut)
  52974. {
  52975. return $this->getOption($this->shortcutToName($shortcut));
  52976. }
  52977. public function getOptionDefaults()
  52978. {
  52979. $values = array();
  52980. foreach ($this->options as $option) {
  52981. $values[$option->getName()] = $option->getDefault();
  52982. }
  52983. return $values;
  52984. }
  52985. private function shortcutToName($shortcut)
  52986. {
  52987. if (!isset($this->shortcuts[$shortcut])) {
  52988. throw new InvalidArgumentException(sprintf('The "-%s" option does not exist.', $shortcut));
  52989. }
  52990. return $this->shortcuts[$shortcut];
  52991. }
  52992. public function getSynopsis($short = false)
  52993. {
  52994. $elements = array();
  52995. if ($short && $this->getOptions()) {
  52996. $elements[] = '[options]';
  52997. } elseif (!$short) {
  52998. foreach ($this->getOptions() as $option) {
  52999. $value = '';
  53000. if ($option->acceptValue()) {
  53001. $value = sprintf(
  53002. ' %s%s%s',
  53003. $option->isValueOptional() ? '[' : '',
  53004. strtoupper($option->getName()),
  53005. $option->isValueOptional() ? ']' : ''
  53006. );
  53007. }
  53008. $shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
  53009. $elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value);
  53010. }
  53011. }
  53012. if (\count($elements) && $this->getArguments()) {
  53013. $elements[] = '[--]';
  53014. }
  53015. foreach ($this->getArguments() as $argument) {
  53016. $element = '<'.$argument->getName().'>';
  53017. if (!$argument->isRequired()) {
  53018. $element = '['.$element.']';
  53019. } elseif ($argument->isArray()) {
  53020. $element .= ' ('.$element.')';
  53021. }
  53022. if ($argument->isArray()) {
  53023. $element .= '...';
  53024. }
  53025. $elements[] = $element;
  53026. }
  53027. return implode(' ', $elements);
  53028. }
  53029. public function asText()
  53030. {
  53031. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  53032. $descriptor = new TextDescriptor();
  53033. $output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
  53034. $descriptor->describe($output, $this, array('raw_output' => true));
  53035. return $output->fetch();
  53036. }
  53037. public function asXml($asDom = false)
  53038. {
  53039. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.3 and will be removed in 3.0.', E_USER_DEPRECATED);
  53040. $descriptor = new XmlDescriptor();
  53041. if ($asDom) {
  53042. return $descriptor->getInputDefinitionDocument($this);
  53043. }
  53044. $output = new BufferedOutput();
  53045. $descriptor->describe($output, $this);
  53046. return $output->fetch();
  53047. }
  53048. }
  53049. <?php
  53050. namespace Symfony\Component\Console\Input;
  53051. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53052. use Symfony\Component\Console\Exception\RuntimeException;
  53053. interface InputInterface
  53054. {
  53055. public function getFirstArgument();
  53056. public function hasParameterOption($values);
  53057. public function getParameterOption($values, $default = false);
  53058. public function bind(InputDefinition $definition);
  53059. public function validate();
  53060. public function getArguments();
  53061. public function getArgument($name);
  53062. public function setArgument($name, $value);
  53063. public function hasArgument($name);
  53064. public function getOptions();
  53065. public function getOption($name);
  53066. public function setOption($name, $value);
  53067. public function hasOption($name);
  53068. public function isInteractive();
  53069. public function setInteractive($interactive);
  53070. }
  53071. <?php
  53072. namespace Symfony\Component\Console\Input;
  53073. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53074. use Symfony\Component\Console\Exception\LogicException;
  53075. class InputOption
  53076. {
  53077. const VALUE_NONE = 1;
  53078. const VALUE_REQUIRED = 2;
  53079. const VALUE_OPTIONAL = 4;
  53080. const VALUE_IS_ARRAY = 8;
  53081. private $name;
  53082. private $shortcut;
  53083. private $mode;
  53084. private $default;
  53085. private $description;
  53086. public function __construct($name, $shortcut = null, $mode = null, $description = '', $default = null)
  53087. {
  53088. if (0 === strpos($name, '--')) {
  53089. $name = substr($name, 2);
  53090. }
  53091. if (empty($name)) {
  53092. throw new InvalidArgumentException('An option name cannot be empty.');
  53093. }
  53094. if (empty($shortcut)) {
  53095. $shortcut = null;
  53096. }
  53097. if (null !== $shortcut) {
  53098. if (\is_array($shortcut)) {
  53099. $shortcut = implode('|', $shortcut);
  53100. }
  53101. $shortcuts = preg_split('{(\|)-?}', ltrim($shortcut, '-'));
  53102. $shortcuts = array_filter($shortcuts);
  53103. $shortcut = implode('|', $shortcuts);
  53104. if (empty($shortcut)) {
  53105. throw new InvalidArgumentException('An option shortcut cannot be empty.');
  53106. }
  53107. }
  53108. if (null === $mode) {
  53109. $mode = self::VALUE_NONE;
  53110. } elseif (!\is_int($mode) || $mode > 15 || $mode < 1) {
  53111. throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
  53112. }
  53113. $this->name = $name;
  53114. $this->shortcut = $shortcut;
  53115. $this->mode = $mode;
  53116. $this->description = $description;
  53117. if ($this->isArray() && !$this->acceptValue()) {
  53118. throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
  53119. }
  53120. $this->setDefault($default);
  53121. }
  53122. public function getShortcut()
  53123. {
  53124. return $this->shortcut;
  53125. }
  53126. public function getName()
  53127. {
  53128. return $this->name;
  53129. }
  53130. public function acceptValue()
  53131. {
  53132. return $this->isValueRequired() || $this->isValueOptional();
  53133. }
  53134. public function isValueRequired()
  53135. {
  53136. return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
  53137. }
  53138. public function isValueOptional()
  53139. {
  53140. return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
  53141. }
  53142. public function isArray()
  53143. {
  53144. return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
  53145. }
  53146. public function setDefault($default = null)
  53147. {
  53148. if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
  53149. throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
  53150. }
  53151. if ($this->isArray()) {
  53152. if (null === $default) {
  53153. $default = array();
  53154. } elseif (!\is_array($default)) {
  53155. throw new LogicException('A default value for an array option must be an array.');
  53156. }
  53157. }
  53158. $this->default = $this->acceptValue() ? $default : false;
  53159. }
  53160. public function getDefault()
  53161. {
  53162. return $this->default;
  53163. }
  53164. public function getDescription()
  53165. {
  53166. return $this->description;
  53167. }
  53168. public function equals(self $option)
  53169. {
  53170. return $option->getName() === $this->getName()
  53171. && $option->getShortcut() === $this->getShortcut()
  53172. && $option->getDefault() === $this->getDefault()
  53173. && $option->isArray() === $this->isArray()
  53174. && $option->isValueRequired() === $this->isValueRequired()
  53175. && $option->isValueOptional() === $this->isValueOptional()
  53176. ;
  53177. }
  53178. }
  53179. <?php
  53180. namespace Symfony\Component\Console\Input;
  53181. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53182. class StringInput extends ArgvInput
  53183. {
  53184. const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
  53185. const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';
  53186. public function __construct($input, InputDefinition $definition = null)
  53187. {
  53188. if ($definition) {
  53189. @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);
  53190. }
  53191. parent::__construct(array(), null);
  53192. $this->setTokens($this->tokenize($input));
  53193. if (null !== $definition) {
  53194. $this->bind($definition);
  53195. }
  53196. }
  53197. private function tokenize($input)
  53198. {
  53199. $tokens = array();
  53200. $length = \strlen($input);
  53201. $cursor = 0;
  53202. while ($cursor < $length) {
  53203. if (preg_match('/\s+/A', $input, $match, null, $cursor)) {
  53204. } elseif (preg_match('/([^="\'\s]+?)(=?)('.self::REGEX_QUOTED_STRING.'+)/A', $input, $match, null, $cursor)) {
  53205. $tokens[] = $match[1].$match[2].stripcslashes(str_replace(array('"\'', '\'"', '\'\'', '""'), '', substr($match[3], 1, \strlen($match[3]) - 2)));
  53206. } elseif (preg_match('/'.self::REGEX_QUOTED_STRING.'/A', $input, $match, null, $cursor)) {
  53207. $tokens[] = stripcslashes(substr($match[0], 1, \strlen($match[0]) - 2));
  53208. } elseif (preg_match('/'.self::REGEX_STRING.'/A', $input, $match, null, $cursor)) {
  53209. $tokens[] = stripcslashes($match[1]);
  53210. } else {
  53211. throw new InvalidArgumentException(sprintf('Unable to parse input near "... %s ..."', substr($input, $cursor, 10)));
  53212. }
  53213. $cursor += \strlen($match[0]);
  53214. }
  53215. return $tokens;
  53216. }
  53217. }
  53218. Copyright (c) 2004-2018 Fabien Potencier
  53219. Permission is hereby granted, free of charge, to any person obtaining a copy
  53220. of this software and associated documentation files (the "Software"), to deal
  53221. in the Software without restriction, including without limitation the rights
  53222. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  53223. copies of the Software, and to permit persons to whom the Software is furnished
  53224. to do so, subject to the following conditions:
  53225. The above copyright notice and this permission notice shall be included in all
  53226. copies or substantial portions of the Software.
  53227. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  53228. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  53229. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  53230. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  53231. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  53232. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  53233. THE SOFTWARE.
  53234. <?php
  53235. namespace Symfony\Component\Console\Logger;
  53236. use Psr\Log\AbstractLogger;
  53237. use Psr\Log\InvalidArgumentException;
  53238. use Psr\Log\LogLevel;
  53239. use Symfony\Component\Console\Output\ConsoleOutputInterface;
  53240. use Symfony\Component\Console\Output\OutputInterface;
  53241. class ConsoleLogger extends AbstractLogger
  53242. {
  53243. const INFO = 'info';
  53244. const ERROR = 'error';
  53245. private $output;
  53246. private $verbosityLevelMap = array(
  53247. LogLevel::EMERGENCY => OutputInterface::VERBOSITY_NORMAL,
  53248. LogLevel::ALERT => OutputInterface::VERBOSITY_NORMAL,
  53249. LogLevel::CRITICAL => OutputInterface::VERBOSITY_NORMAL,
  53250. LogLevel::ERROR => OutputInterface::VERBOSITY_NORMAL,
  53251. LogLevel::WARNING => OutputInterface::VERBOSITY_NORMAL,
  53252. LogLevel::NOTICE => OutputInterface::VERBOSITY_VERBOSE,
  53253. LogLevel::INFO => OutputInterface::VERBOSITY_VERY_VERBOSE,
  53254. LogLevel::DEBUG => OutputInterface::VERBOSITY_DEBUG,
  53255. );
  53256. private $formatLevelMap = array(
  53257. LogLevel::EMERGENCY => self::ERROR,
  53258. LogLevel::ALERT => self::ERROR,
  53259. LogLevel::CRITICAL => self::ERROR,
  53260. LogLevel::ERROR => self::ERROR,
  53261. LogLevel::WARNING => self::INFO,
  53262. LogLevel::NOTICE => self::INFO,
  53263. LogLevel::INFO => self::INFO,
  53264. LogLevel::DEBUG => self::INFO,
  53265. );
  53266. public function __construct(OutputInterface $output, array $verbosityLevelMap = array(), array $formatLevelMap = array())
  53267. {
  53268. $this->output = $output;
  53269. $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap;
  53270. $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap;
  53271. }
  53272. public function log($level, $message, array $context = array())
  53273. {
  53274. if (!isset($this->verbosityLevelMap[$level])) {
  53275. throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level));
  53276. }
  53277. if (self::ERROR === $this->formatLevelMap[$level] && $this->output instanceof ConsoleOutputInterface) {
  53278. $output = $this->output->getErrorOutput();
  53279. } else {
  53280. $output = $this->output;
  53281. }
  53282. if ($output->getVerbosity() >= $this->verbosityLevelMap[$level]) {
  53283. $output->writeln(sprintf('<%1$s>[%2$s] %3$s</%1$s>', $this->formatLevelMap[$level], $level, $this->interpolate($message, $context)));
  53284. }
  53285. }
  53286. private function interpolate($message, array $context)
  53287. {
  53288. $replace = array();
  53289. foreach ($context as $key => $val) {
  53290. if (!\is_array($val) && (!\is_object($val) || method_exists($val, '__toString'))) {
  53291. $replace[sprintf('{%s}', $key)] = $val;
  53292. }
  53293. }
  53294. return strtr($message, $replace);
  53295. }
  53296. }
  53297. <?php
  53298. namespace Symfony\Component\Console\Output;
  53299. class BufferedOutput extends Output
  53300. {
  53301. private $buffer = '';
  53302. public function fetch()
  53303. {
  53304. $content = $this->buffer;
  53305. $this->buffer = '';
  53306. return $content;
  53307. }
  53308. protected function doWrite($message, $newline)
  53309. {
  53310. $this->buffer .= $message;
  53311. if ($newline) {
  53312. $this->buffer .= PHP_EOL;
  53313. }
  53314. }
  53315. }
  53316. <?php
  53317. namespace Symfony\Component\Console\Output;
  53318. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53319. class ConsoleOutput extends StreamOutput implements ConsoleOutputInterface
  53320. {
  53321. private $stderr;
  53322. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  53323. {
  53324. parent::__construct($this->openOutputStream(), $verbosity, $decorated, $formatter);
  53325. $actualDecorated = $this->isDecorated();
  53326. $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter());
  53327. if (null === $decorated) {
  53328. $this->setDecorated($actualDecorated && $this->stderr->isDecorated());
  53329. }
  53330. }
  53331. public function setDecorated($decorated)
  53332. {
  53333. parent::setDecorated($decorated);
  53334. $this->stderr->setDecorated($decorated);
  53335. }
  53336. public function setFormatter(OutputFormatterInterface $formatter)
  53337. {
  53338. parent::setFormatter($formatter);
  53339. $this->stderr->setFormatter($formatter);
  53340. }
  53341. public function setVerbosity($level)
  53342. {
  53343. parent::setVerbosity($level);
  53344. $this->stderr->setVerbosity($level);
  53345. }
  53346. public function getErrorOutput()
  53347. {
  53348. return $this->stderr;
  53349. }
  53350. public function setErrorOutput(OutputInterface $error)
  53351. {
  53352. $this->stderr = $error;
  53353. }
  53354. protected function hasStdoutSupport()
  53355. {
  53356. return false === $this->isRunningOS400();
  53357. }
  53358. protected function hasStderrSupport()
  53359. {
  53360. return false === $this->isRunningOS400();
  53361. }
  53362. private function isRunningOS400()
  53363. {
  53364. $checks = array(
  53365. \function_exists('php_uname') ? php_uname('s') : '',
  53366. getenv('OSTYPE'),
  53367. PHP_OS,
  53368. );
  53369. return false !== stripos(implode(';', $checks), 'OS400');
  53370. }
  53371. private function openOutputStream()
  53372. {
  53373. $outputStream = $this->hasStdoutSupport() ? 'php://stdout' : 'php://output';
  53374. return @fopen($outputStream, 'w') ?: fopen('php://output', 'w');
  53375. }
  53376. private function openErrorStream()
  53377. {
  53378. $errorStream = $this->hasStderrSupport() ? 'php://stderr' : 'php://output';
  53379. return fopen($errorStream, 'w');
  53380. }
  53381. }
  53382. <?php
  53383. namespace Symfony\Component\Console\Output;
  53384. interface ConsoleOutputInterface extends OutputInterface
  53385. {
  53386. public function getErrorOutput();
  53387. public function setErrorOutput(OutputInterface $error);
  53388. }
  53389. <?php
  53390. namespace Symfony\Component\Console\Output;
  53391. use Symfony\Component\Console\Formatter\OutputFormatter;
  53392. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53393. class NullOutput implements OutputInterface
  53394. {
  53395. public function setFormatter(OutputFormatterInterface $formatter)
  53396. {
  53397. }
  53398. public function getFormatter()
  53399. {
  53400. return new OutputFormatter();
  53401. }
  53402. public function setDecorated($decorated)
  53403. {
  53404. }
  53405. public function isDecorated()
  53406. {
  53407. return false;
  53408. }
  53409. public function setVerbosity($level)
  53410. {
  53411. }
  53412. public function getVerbosity()
  53413. {
  53414. return self::VERBOSITY_QUIET;
  53415. }
  53416. public function isQuiet()
  53417. {
  53418. return true;
  53419. }
  53420. public function isVerbose()
  53421. {
  53422. return false;
  53423. }
  53424. public function isVeryVerbose()
  53425. {
  53426. return false;
  53427. }
  53428. public function isDebug()
  53429. {
  53430. return false;
  53431. }
  53432. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  53433. {
  53434. }
  53435. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  53436. {
  53437. }
  53438. }
  53439. <?php
  53440. namespace Symfony\Component\Console\Output;
  53441. use Symfony\Component\Console\Formatter\OutputFormatter;
  53442. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53443. abstract class Output implements OutputInterface
  53444. {
  53445. private $verbosity;
  53446. private $formatter;
  53447. public function __construct($verbosity = self::VERBOSITY_NORMAL, $decorated = false, OutputFormatterInterface $formatter = null)
  53448. {
  53449. $this->verbosity = null === $verbosity ? self::VERBOSITY_NORMAL : $verbosity;
  53450. $this->formatter = $formatter ?: new OutputFormatter();
  53451. $this->formatter->setDecorated($decorated);
  53452. }
  53453. public function setFormatter(OutputFormatterInterface $formatter)
  53454. {
  53455. $this->formatter = $formatter;
  53456. }
  53457. public function getFormatter()
  53458. {
  53459. return $this->formatter;
  53460. }
  53461. public function setDecorated($decorated)
  53462. {
  53463. $this->formatter->setDecorated($decorated);
  53464. }
  53465. public function isDecorated()
  53466. {
  53467. return $this->formatter->isDecorated();
  53468. }
  53469. public function setVerbosity($level)
  53470. {
  53471. $this->verbosity = (int) $level;
  53472. }
  53473. public function getVerbosity()
  53474. {
  53475. return $this->verbosity;
  53476. }
  53477. public function isQuiet()
  53478. {
  53479. return self::VERBOSITY_QUIET === $this->verbosity;
  53480. }
  53481. public function isVerbose()
  53482. {
  53483. return self::VERBOSITY_VERBOSE <= $this->verbosity;
  53484. }
  53485. public function isVeryVerbose()
  53486. {
  53487. return self::VERBOSITY_VERY_VERBOSE <= $this->verbosity;
  53488. }
  53489. public function isDebug()
  53490. {
  53491. return self::VERBOSITY_DEBUG <= $this->verbosity;
  53492. }
  53493. public function writeln($messages, $options = self::OUTPUT_NORMAL)
  53494. {
  53495. $this->write($messages, true, $options);
  53496. }
  53497. public function write($messages, $newline = false, $options = self::OUTPUT_NORMAL)
  53498. {
  53499. $messages = (array) $messages;
  53500. $types = self::OUTPUT_NORMAL | self::OUTPUT_RAW | self::OUTPUT_PLAIN;
  53501. $type = $types & $options ?: self::OUTPUT_NORMAL;
  53502. $verbosities = self::VERBOSITY_QUIET | self::VERBOSITY_NORMAL | self::VERBOSITY_VERBOSE | self::VERBOSITY_VERY_VERBOSE | self::VERBOSITY_DEBUG;
  53503. $verbosity = $verbosities & $options ?: self::VERBOSITY_NORMAL;
  53504. if ($verbosity > $this->getVerbosity()) {
  53505. return;
  53506. }
  53507. foreach ($messages as $message) {
  53508. switch ($type) {
  53509. case OutputInterface::OUTPUT_NORMAL:
  53510. $message = $this->formatter->format($message);
  53511. break;
  53512. case OutputInterface::OUTPUT_RAW:
  53513. break;
  53514. case OutputInterface::OUTPUT_PLAIN:
  53515. $message = strip_tags($this->formatter->format($message));
  53516. break;
  53517. }
  53518. $this->doWrite($message, $newline);
  53519. }
  53520. }
  53521. abstract protected function doWrite($message, $newline);
  53522. }
  53523. <?php
  53524. namespace Symfony\Component\Console\Output;
  53525. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53526. interface OutputInterface
  53527. {
  53528. const VERBOSITY_QUIET = 16;
  53529. const VERBOSITY_NORMAL = 32;
  53530. const VERBOSITY_VERBOSE = 64;
  53531. const VERBOSITY_VERY_VERBOSE = 128;
  53532. const VERBOSITY_DEBUG = 256;
  53533. const OUTPUT_NORMAL = 1;
  53534. const OUTPUT_RAW = 2;
  53535. const OUTPUT_PLAIN = 4;
  53536. public function write($messages, $newline = false, $options = 0);
  53537. public function writeln($messages, $options = 0);
  53538. public function setVerbosity($level);
  53539. public function getVerbosity();
  53540. public function setDecorated($decorated);
  53541. public function isDecorated();
  53542. public function setFormatter(OutputFormatterInterface $formatter);
  53543. public function getFormatter();
  53544. }
  53545. <?php
  53546. namespace Symfony\Component\Console\Output;
  53547. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53548. use Symfony\Component\Console\Exception\RuntimeException;
  53549. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53550. class StreamOutput extends Output
  53551. {
  53552. private $stream;
  53553. public function __construct($stream, $verbosity = self::VERBOSITY_NORMAL, $decorated = null, OutputFormatterInterface $formatter = null)
  53554. {
  53555. if (!\is_resource($stream) || 'stream' !== get_resource_type($stream)) {
  53556. throw new InvalidArgumentException('The StreamOutput class needs a stream as its first argument.');
  53557. }
  53558. $this->stream = $stream;
  53559. if (null === $decorated) {
  53560. $decorated = $this->hasColorSupport();
  53561. }
  53562. parent::__construct($verbosity, $decorated, $formatter);
  53563. }
  53564. public function getStream()
  53565. {
  53566. return $this->stream;
  53567. }
  53568. protected function doWrite($message, $newline)
  53569. {
  53570. if ($newline) {
  53571. $message .= PHP_EOL;
  53572. }
  53573. if (false === @fwrite($this->stream, $message)) {
  53574. throw new RuntimeException('Unable to write output.');
  53575. }
  53576. fflush($this->stream);
  53577. }
  53578. protected function hasColorSupport()
  53579. {
  53580. if ('Hyper' === getenv('TERM_PROGRAM')) {
  53581. return true;
  53582. }
  53583. if (\DIRECTORY_SEPARATOR === '\\') {
  53584. return (\function_exists('sapi_windows_vt100_support')
  53585. && @sapi_windows_vt100_support($this->stream))
  53586. || false !== getenv('ANSICON')
  53587. || 'ON' === getenv('ConEmuANSI')
  53588. || 'xterm' === getenv('TERM');
  53589. }
  53590. if (\function_exists('stream_isatty')) {
  53591. return @stream_isatty($this->stream);
  53592. }
  53593. if (\function_exists('posix_isatty')) {
  53594. return @posix_isatty($this->stream);
  53595. }
  53596. $stat = @fstat($this->stream);
  53597. return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
  53598. }
  53599. }
  53600. <?php
  53601. namespace Symfony\Component\Console\Question;
  53602. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53603. class ChoiceQuestion extends Question
  53604. {
  53605. private $choices;
  53606. private $multiselect = false;
  53607. private $prompt = ' > ';
  53608. private $errorMessage = 'Value "%s" is invalid';
  53609. public function __construct($question, array $choices, $default = null)
  53610. {
  53611. if (!$choices) {
  53612. throw new \LogicException('Choice question must have at least 1 choice available.');
  53613. }
  53614. parent::__construct($question, $default);
  53615. $this->choices = $choices;
  53616. $this->setValidator($this->getDefaultValidator());
  53617. $this->setAutocompleterValues($choices);
  53618. }
  53619. public function getChoices()
  53620. {
  53621. return $this->choices;
  53622. }
  53623. public function setMultiselect($multiselect)
  53624. {
  53625. $this->multiselect = $multiselect;
  53626. $this->setValidator($this->getDefaultValidator());
  53627. return $this;
  53628. }
  53629. public function isMultiselect()
  53630. {
  53631. return $this->multiselect;
  53632. }
  53633. public function getPrompt()
  53634. {
  53635. return $this->prompt;
  53636. }
  53637. public function setPrompt($prompt)
  53638. {
  53639. $this->prompt = $prompt;
  53640. return $this;
  53641. }
  53642. public function setErrorMessage($errorMessage)
  53643. {
  53644. $this->errorMessage = $errorMessage;
  53645. $this->setValidator($this->getDefaultValidator());
  53646. return $this;
  53647. }
  53648. private function getDefaultValidator()
  53649. {
  53650. $choices = $this->choices;
  53651. $errorMessage = $this->errorMessage;
  53652. $multiselect = $this->multiselect;
  53653. $isAssoc = $this->isAssoc($choices);
  53654. return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
  53655. $selectedChoices = str_replace(' ', '', $selected);
  53656. if ($multiselect) {
  53657. if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
  53658. throw new InvalidArgumentException(sprintf($errorMessage, $selected));
  53659. }
  53660. $selectedChoices = explode(',', $selectedChoices);
  53661. } else {
  53662. $selectedChoices = array($selected);
  53663. }
  53664. $multiselectChoices = array();
  53665. foreach ($selectedChoices as $value) {
  53666. $results = array();
  53667. foreach ($choices as $key => $choice) {
  53668. if ($choice === $value) {
  53669. $results[] = $key;
  53670. }
  53671. }
  53672. if (\count($results) > 1) {
  53673. throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results)));
  53674. }
  53675. $result = array_search($value, $choices);
  53676. if (!$isAssoc) {
  53677. if (false !== $result) {
  53678. $result = $choices[$result];
  53679. } elseif (isset($choices[$value])) {
  53680. $result = $choices[$value];
  53681. }
  53682. } elseif (false === $result && isset($choices[$value])) {
  53683. $result = $value;
  53684. }
  53685. if (false === $result) {
  53686. throw new InvalidArgumentException(sprintf($errorMessage, $value));
  53687. }
  53688. $multiselectChoices[] = (string) $result;
  53689. }
  53690. if ($multiselect) {
  53691. return $multiselectChoices;
  53692. }
  53693. return current($multiselectChoices);
  53694. };
  53695. }
  53696. }
  53697. <?php
  53698. namespace Symfony\Component\Console\Question;
  53699. class ConfirmationQuestion extends Question
  53700. {
  53701. private $trueAnswerRegex;
  53702. public function __construct($question, $default = true, $trueAnswerRegex = '/^y/i')
  53703. {
  53704. parent::__construct($question, (bool) $default);
  53705. $this->trueAnswerRegex = $trueAnswerRegex;
  53706. $this->setNormalizer($this->getDefaultNormalizer());
  53707. }
  53708. private function getDefaultNormalizer()
  53709. {
  53710. $default = $this->getDefault();
  53711. $regex = $this->trueAnswerRegex;
  53712. return function ($answer) use ($default, $regex) {
  53713. if (\is_bool($answer)) {
  53714. return $answer;
  53715. }
  53716. $answerIsTrue = (bool) preg_match($regex, $answer);
  53717. if (false === $default) {
  53718. return $answer && $answerIsTrue;
  53719. }
  53720. return !$answer || $answerIsTrue;
  53721. };
  53722. }
  53723. }
  53724. <?php
  53725. namespace Symfony\Component\Console\Question;
  53726. use Symfony\Component\Console\Exception\InvalidArgumentException;
  53727. use Symfony\Component\Console\Exception\LogicException;
  53728. class Question
  53729. {
  53730. private $question;
  53731. private $attempts;
  53732. private $hidden = false;
  53733. private $hiddenFallback = true;
  53734. private $autocompleterValues;
  53735. private $validator;
  53736. private $default;
  53737. private $normalizer;
  53738. public function __construct($question, $default = null)
  53739. {
  53740. $this->question = $question;
  53741. $this->default = $default;
  53742. }
  53743. public function getQuestion()
  53744. {
  53745. return $this->question;
  53746. }
  53747. public function getDefault()
  53748. {
  53749. return $this->default;
  53750. }
  53751. public function isHidden()
  53752. {
  53753. return $this->hidden;
  53754. }
  53755. public function setHidden($hidden)
  53756. {
  53757. if ($this->autocompleterValues) {
  53758. throw new LogicException('A hidden question cannot use the autocompleter.');
  53759. }
  53760. $this->hidden = (bool) $hidden;
  53761. return $this;
  53762. }
  53763. public function isHiddenFallback()
  53764. {
  53765. return $this->hiddenFallback;
  53766. }
  53767. public function setHiddenFallback($fallback)
  53768. {
  53769. $this->hiddenFallback = (bool) $fallback;
  53770. return $this;
  53771. }
  53772. public function getAutocompleterValues()
  53773. {
  53774. return $this->autocompleterValues;
  53775. }
  53776. public function setAutocompleterValues($values)
  53777. {
  53778. if (\is_array($values)) {
  53779. $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values);
  53780. }
  53781. if (null !== $values && !\is_array($values) && !$values instanceof \Traversable) {
  53782. throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.');
  53783. }
  53784. if ($this->hidden) {
  53785. throw new LogicException('A hidden question cannot use the autocompleter.');
  53786. }
  53787. $this->autocompleterValues = $values;
  53788. return $this;
  53789. }
  53790. public function setValidator($validator)
  53791. {
  53792. $this->validator = $validator;
  53793. return $this;
  53794. }
  53795. public function getValidator()
  53796. {
  53797. return $this->validator;
  53798. }
  53799. public function setMaxAttempts($attempts)
  53800. {
  53801. if (null !== $attempts && $attempts < 1) {
  53802. throw new InvalidArgumentException('Maximum number of attempts must be a positive value.');
  53803. }
  53804. $this->attempts = $attempts;
  53805. return $this;
  53806. }
  53807. public function getMaxAttempts()
  53808. {
  53809. return $this->attempts;
  53810. }
  53811. public function setNormalizer($normalizer)
  53812. {
  53813. $this->normalizer = $normalizer;
  53814. return $this;
  53815. }
  53816. public function getNormalizer()
  53817. {
  53818. return $this->normalizer;
  53819. }
  53820. protected function isAssoc($array)
  53821. {
  53822. return (bool) \count(array_filter(array_keys($array), 'is_string'));
  53823. }
  53824. }
  53825. MZ��������ÿÿ��¸�������@�����������������������������������è���º�´ Í!¸LÍ!This program cannot be run in DOS mode.
  53826. $�������Æ,Í;§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��������à�  ��
  53827. ���������8������ ����@����������������������`�����?œ���@�����������������������������"��P����@�� �������������������P��p���!�����������������������������8!��@������������ ��Ø���������������������������.text��� ������
  53828. ����������������� ��`.rdata����� ���
  53829. �����������������@��@.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
  53830. 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
  53831. 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
  53832. 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">
  53833. <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
  53834. <security>
  53835. <requestedPrivileges>
  53836. <requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
  53837. </requestedPrivileges>
  53838. </security>
  53839. </trustInfo>
  53840. <dependency>
  53841. <dependentAssembly>
  53842. <assemblyIdentity type="win32" name="Microsoft.VC90.CRT" version="9.0.21022.8" processorArchitecture="x86" publicKeyToken="1fc8b3b9a1e18e3b"></assemblyIdentity>
  53843. </dependentAssembly>
  53844. </dependency>
  53845. </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
  53846. namespace Symfony\Component\Console;
  53847. use Symfony\Component\Console\Exception\RuntimeException;
  53848. use Symfony\Component\Console\Input\StringInput;
  53849. use Symfony\Component\Console\Output\ConsoleOutput;
  53850. use Symfony\Component\Process\PhpExecutableFinder;
  53851. use Symfony\Component\Process\ProcessBuilder;
  53852. class Shell
  53853. {
  53854. private $application;
  53855. private $history;
  53856. private $output;
  53857. private $hasReadline;
  53858. private $processIsolation = false;
  53859. public function __construct(Application $application)
  53860. {
  53861. @trigger_error('The '.__CLASS__.' class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  53862. $this->hasReadline = \function_exists('readline');
  53863. $this->application = $application;
  53864. $this->history = getenv('HOME').'/.history_'.$application->getName();
  53865. $this->output = new ConsoleOutput();
  53866. }
  53867. public function run()
  53868. {
  53869. $this->application->setAutoExit(false);
  53870. $this->application->setCatchExceptions(true);
  53871. if ($this->hasReadline) {
  53872. readline_read_history($this->history);
  53873. readline_completion_function(array($this, 'autocompleter'));
  53874. }
  53875. $this->output->writeln($this->getHeader());
  53876. $php = null;
  53877. if ($this->processIsolation) {
  53878. $finder = new PhpExecutableFinder();
  53879. $php = $finder->find();
  53880. $this->output->writeln(<<<'EOF'
  53881. <info>Running with process isolation, you should consider this:</info>
  53882. * each command is executed as separate process,
  53883. * commands don't support interactivity, all params must be passed explicitly,
  53884. * commands output is not colorized.
  53885. EOF
  53886. );
  53887. }
  53888. while (true) {
  53889. $command = $this->readline();
  53890. if (false === $command) {
  53891. $this->output->writeln("\n");
  53892. break;
  53893. }
  53894. if ($this->hasReadline) {
  53895. readline_add_history($command);
  53896. readline_write_history($this->history);
  53897. }
  53898. if ($this->processIsolation) {
  53899. $pb = new ProcessBuilder();
  53900. $process = $pb
  53901. ->add($php)
  53902. ->add($_SERVER['argv'][0])
  53903. ->add($command)
  53904. ->inheritEnvironmentVariables(true)
  53905. ->getProcess()
  53906. ;
  53907. $output = $this->output;
  53908. $process->run(function ($type, $data) use ($output) {
  53909. $output->writeln($data);
  53910. });
  53911. $ret = $process->getExitCode();
  53912. } else {
  53913. $ret = $this->application->run(new StringInput($command), $this->output);
  53914. }
  53915. if (0 !== $ret) {
  53916. $this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret));
  53917. }
  53918. }
  53919. }
  53920. protected function getHeader()
  53921. {
  53922. return <<<EOF
  53923. Welcome to the <info>{$this->application->getName()}</info> shell (<comment>{$this->application->getVersion()}</comment>).
  53924. At the prompt, type <comment>help</comment> for some help,
  53925. or <comment>list</comment> to get a list of available commands.
  53926. To exit the shell, type <comment>^D</comment>.
  53927. EOF;
  53928. }
  53929. protected function getPrompt()
  53930. {
  53931. return $this->output->getFormatter()->format($this->application->getName().' > ');
  53932. }
  53933. protected function getOutput()
  53934. {
  53935. return $this->output;
  53936. }
  53937. protected function getApplication()
  53938. {
  53939. return $this->application;
  53940. }
  53941. private function autocompleter($text)
  53942. {
  53943. $info = readline_info();
  53944. $text = substr($info['line_buffer'], 0, $info['end']);
  53945. if ($info['point'] !== $info['end']) {
  53946. return true;
  53947. }
  53948. if (false === strpos($text, ' ') || !$text) {
  53949. return array_keys($this->application->all());
  53950. }
  53951. try {
  53952. $command = $this->application->find(substr($text, 0, strpos($text, ' ')));
  53953. } catch (\Exception $e) {
  53954. return true;
  53955. }
  53956. $list = array('--help');
  53957. foreach ($command->getDefinition()->getOptions() as $option) {
  53958. $list[] = '--'.$option->getName();
  53959. }
  53960. return $list;
  53961. }
  53962. private function readline()
  53963. {
  53964. if ($this->hasReadline) {
  53965. $line = readline($this->getPrompt());
  53966. } else {
  53967. $this->output->write($this->getPrompt());
  53968. $line = fgets(STDIN, 1024);
  53969. $line = (false === $line || '' === $line) ? false : rtrim($line);
  53970. }
  53971. return $line;
  53972. }
  53973. public function getProcessIsolation()
  53974. {
  53975. return $this->processIsolation;
  53976. }
  53977. public function setProcessIsolation($processIsolation)
  53978. {
  53979. $this->processIsolation = (bool) $processIsolation;
  53980. if ($this->processIsolation && !class_exists('Symfony\\Component\\Process\\Process')) {
  53981. throw new RuntimeException('Unable to isolate processes as the Symfony Process Component is not installed.');
  53982. }
  53983. }
  53984. }
  53985. <?php
  53986. namespace Symfony\Component\Console\Style;
  53987. use Symfony\Component\Console\Formatter\OutputFormatterInterface;
  53988. use Symfony\Component\Console\Helper\ProgressBar;
  53989. use Symfony\Component\Console\Output\OutputInterface;
  53990. abstract class OutputStyle implements OutputInterface, StyleInterface
  53991. {
  53992. private $output;
  53993. public function __construct(OutputInterface $output)
  53994. {
  53995. $this->output = $output;
  53996. }
  53997. public function newLine($count = 1)
  53998. {
  53999. $this->output->write(str_repeat(PHP_EOL, $count));
  54000. }
  54001. public function createProgressBar($max = 0)
  54002. {
  54003. return new ProgressBar($this->output, $max);
  54004. }
  54005. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  54006. {
  54007. $this->output->write($messages, $newline, $type);
  54008. }
  54009. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  54010. {
  54011. $this->output->writeln($messages, $type);
  54012. }
  54013. public function setVerbosity($level)
  54014. {
  54015. $this->output->setVerbosity($level);
  54016. }
  54017. public function getVerbosity()
  54018. {
  54019. return $this->output->getVerbosity();
  54020. }
  54021. public function setDecorated($decorated)
  54022. {
  54023. $this->output->setDecorated($decorated);
  54024. }
  54025. public function isDecorated()
  54026. {
  54027. return $this->output->isDecorated();
  54028. }
  54029. public function setFormatter(OutputFormatterInterface $formatter)
  54030. {
  54031. $this->output->setFormatter($formatter);
  54032. }
  54033. public function getFormatter()
  54034. {
  54035. return $this->output->getFormatter();
  54036. }
  54037. }
  54038. <?php
  54039. namespace Symfony\Component\Console\Style;
  54040. interface StyleInterface
  54041. {
  54042. public function title($message);
  54043. public function section($message);
  54044. public function listing(array $elements);
  54045. public function text($message);
  54046. public function success($message);
  54047. public function error($message);
  54048. public function warning($message);
  54049. public function note($message);
  54050. public function caution($message);
  54051. public function table(array $headers, array $rows);
  54052. public function ask($question, $default = null, $validator = null);
  54053. public function askHidden($question, $validator = null);
  54054. public function confirm($question, $default = true);
  54055. public function choice($question, array $choices, $default = null);
  54056. public function newLine($count = 1);
  54057. public function progressStart($max = 0);
  54058. public function progressAdvance($step = 1);
  54059. public function progressFinish();
  54060. }
  54061. <?php
  54062. namespace Symfony\Component\Console\Style;
  54063. use Symfony\Component\Console\Application;
  54064. use Symfony\Component\Console\Exception\RuntimeException;
  54065. use Symfony\Component\Console\Formatter\OutputFormatter;
  54066. use Symfony\Component\Console\Helper\Helper;
  54067. use Symfony\Component\Console\Helper\ProgressBar;
  54068. use Symfony\Component\Console\Helper\SymfonyQuestionHelper;
  54069. use Symfony\Component\Console\Helper\Table;
  54070. use Symfony\Component\Console\Input\InputInterface;
  54071. use Symfony\Component\Console\Output\BufferedOutput;
  54072. use Symfony\Component\Console\Output\OutputInterface;
  54073. use Symfony\Component\Console\Question\ChoiceQuestion;
  54074. use Symfony\Component\Console\Question\ConfirmationQuestion;
  54075. use Symfony\Component\Console\Question\Question;
  54076. class SymfonyStyle extends OutputStyle
  54077. {
  54078. const MAX_LINE_LENGTH = 120;
  54079. private $input;
  54080. private $questionHelper;
  54081. private $progressBar;
  54082. private $lineLength;
  54083. private $bufferedOutput;
  54084. public function __construct(InputInterface $input, OutputInterface $output)
  54085. {
  54086. $this->input = $input;
  54087. $this->bufferedOutput = new BufferedOutput($output->getVerbosity(), false, clone $output->getFormatter());
  54088. $this->lineLength = min($this->getTerminalWidth() - (int) (\DIRECTORY_SEPARATOR === '\\'), self::MAX_LINE_LENGTH);
  54089. parent::__construct($output);
  54090. }
  54091. public function block($messages, $type = null, $style = null, $prefix = ' ', $padding = false)
  54092. {
  54093. $messages = \is_array($messages) ? array_values($messages) : array($messages);
  54094. $this->autoPrependBlock();
  54095. $this->writeln($this->createBlock($messages, $type, $style, $prefix, $padding, true));
  54096. $this->newLine();
  54097. }
  54098. public function title($message)
  54099. {
  54100. $this->autoPrependBlock();
  54101. $this->writeln(array(
  54102. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  54103. sprintf('<comment>%s</>', str_repeat('=', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  54104. ));
  54105. $this->newLine();
  54106. }
  54107. public function section($message)
  54108. {
  54109. $this->autoPrependBlock();
  54110. $this->writeln(array(
  54111. sprintf('<comment>%s</>', OutputFormatter::escapeTrailingBackslash($message)),
  54112. sprintf('<comment>%s</>', str_repeat('-', Helper::strlenWithoutDecoration($this->getFormatter(), $message))),
  54113. ));
  54114. $this->newLine();
  54115. }
  54116. public function listing(array $elements)
  54117. {
  54118. $this->autoPrependText();
  54119. $elements = array_map(function ($element) {
  54120. return sprintf(' * %s', $element);
  54121. }, $elements);
  54122. $this->writeln($elements);
  54123. $this->newLine();
  54124. }
  54125. public function text($message)
  54126. {
  54127. $this->autoPrependText();
  54128. $messages = \is_array($message) ? array_values($message) : array($message);
  54129. foreach ($messages as $message) {
  54130. $this->writeln(sprintf(' %s', $message));
  54131. }
  54132. }
  54133. public function comment($message)
  54134. {
  54135. $messages = \is_array($message) ? array_values($message) : array($message);
  54136. $this->autoPrependBlock();
  54137. $this->writeln($this->createBlock($messages, null, null, '<fg=default;bg=default> // </>'));
  54138. $this->newLine();
  54139. }
  54140. public function success($message)
  54141. {
  54142. $this->block($message, 'OK', 'fg=black;bg=green', ' ', true);
  54143. }
  54144. public function error($message)
  54145. {
  54146. $this->block($message, 'ERROR', 'fg=white;bg=red', ' ', true);
  54147. }
  54148. public function warning($message)
  54149. {
  54150. $this->block($message, 'WARNING', 'fg=white;bg=red', ' ', true);
  54151. }
  54152. public function note($message)
  54153. {
  54154. $this->block($message, 'NOTE', 'fg=yellow', ' ! ');
  54155. }
  54156. public function caution($message)
  54157. {
  54158. $this->block($message, 'CAUTION', 'fg=white;bg=red', ' ! ', true);
  54159. }
  54160. public function table(array $headers, array $rows)
  54161. {
  54162. $style = clone Table::getStyleDefinition('symfony-style-guide');
  54163. $style->setCellHeaderFormat('<info>%s</info>');
  54164. $table = new Table($this);
  54165. $table->setHeaders($headers);
  54166. $table->setRows($rows);
  54167. $table->setStyle($style);
  54168. $table->render();
  54169. $this->newLine();
  54170. }
  54171. public function ask($question, $default = null, $validator = null)
  54172. {
  54173. $question = new Question($question, $default);
  54174. $question->setValidator($validator);
  54175. return $this->askQuestion($question);
  54176. }
  54177. public function askHidden($question, $validator = null)
  54178. {
  54179. $question = new Question($question);
  54180. $question->setHidden(true);
  54181. $question->setValidator($validator);
  54182. return $this->askQuestion($question);
  54183. }
  54184. public function confirm($question, $default = true)
  54185. {
  54186. return $this->askQuestion(new ConfirmationQuestion($question, $default));
  54187. }
  54188. public function choice($question, array $choices, $default = null)
  54189. {
  54190. if (null !== $default) {
  54191. $values = array_flip($choices);
  54192. $default = $values[$default];
  54193. }
  54194. return $this->askQuestion(new ChoiceQuestion($question, $choices, $default));
  54195. }
  54196. public function progressStart($max = 0)
  54197. {
  54198. $this->progressBar = $this->createProgressBar($max);
  54199. $this->progressBar->start();
  54200. }
  54201. public function progressAdvance($step = 1)
  54202. {
  54203. $this->getProgressBar()->advance($step);
  54204. }
  54205. public function progressFinish()
  54206. {
  54207. $this->getProgressBar()->finish();
  54208. $this->newLine(2);
  54209. $this->progressBar = null;
  54210. }
  54211. public function createProgressBar($max = 0)
  54212. {
  54213. $progressBar = parent::createProgressBar($max);
  54214. if ('\\' !== \DIRECTORY_SEPARATOR || 'Hyper' === getenv('TERM_PROGRAM')) {
  54215. $progressBar->setEmptyBarCharacter('â–‘');
  54216. $progressBar->setProgressCharacter('');
  54217. $progressBar->setBarCharacter('â–“');
  54218. }
  54219. return $progressBar;
  54220. }
  54221. public function askQuestion(Question $question)
  54222. {
  54223. if ($this->input->isInteractive()) {
  54224. $this->autoPrependBlock();
  54225. }
  54226. if (!$this->questionHelper) {
  54227. $this->questionHelper = new SymfonyQuestionHelper();
  54228. }
  54229. $answer = $this->questionHelper->ask($this->input, $this, $question);
  54230. if ($this->input->isInteractive()) {
  54231. $this->newLine();
  54232. $this->bufferedOutput->write("\n");
  54233. }
  54234. return $answer;
  54235. }
  54236. public function writeln($messages, $type = self::OUTPUT_NORMAL)
  54237. {
  54238. parent::writeln($messages, $type);
  54239. $this->bufferedOutput->writeln($this->reduceBuffer($messages), $type);
  54240. }
  54241. public function write($messages, $newline = false, $type = self::OUTPUT_NORMAL)
  54242. {
  54243. parent::write($messages, $newline, $type);
  54244. $this->bufferedOutput->write($this->reduceBuffer($messages), $newline, $type);
  54245. }
  54246. public function newLine($count = 1)
  54247. {
  54248. parent::newLine($count);
  54249. $this->bufferedOutput->write(str_repeat("\n", $count));
  54250. }
  54251. private function getProgressBar()
  54252. {
  54253. if (!$this->progressBar) {
  54254. throw new RuntimeException('The ProgressBar is not started.');
  54255. }
  54256. return $this->progressBar;
  54257. }
  54258. private function getTerminalWidth()
  54259. {
  54260. $application = new Application();
  54261. $dimensions = $application->getTerminalDimensions();
  54262. return $dimensions[0] ?: self::MAX_LINE_LENGTH;
  54263. }
  54264. private function autoPrependBlock()
  54265. {
  54266. $chars = substr(str_replace(PHP_EOL, "\n", $this->bufferedOutput->fetch()), -2);
  54267. if (!isset($chars[0])) {
  54268. return $this->newLine();
  54269. }
  54270. $this->newLine(2 - substr_count($chars, "\n"));
  54271. }
  54272. private function autoPrependText()
  54273. {
  54274. $fetched = $this->bufferedOutput->fetch();
  54275. if ("\n" !== substr($fetched, -1)) {
  54276. $this->newLine();
  54277. }
  54278. }
  54279. private function reduceBuffer($messages)
  54280. {
  54281. return array_map(function ($value) {
  54282. return substr($value, -4);
  54283. }, array_merge(array($this->bufferedOutput->fetch()), (array) $messages));
  54284. }
  54285. private function createBlock($messages, $type = null, $style = null, $prefix = ' ', $padding = false, $escape = false)
  54286. {
  54287. $indentLength = 0;
  54288. $prefixLength = Helper::strlenWithoutDecoration($this->getFormatter(), $prefix);
  54289. $lines = array();
  54290. if (null !== $type) {
  54291. $type = sprintf('[%s] ', $type);
  54292. $indentLength = \strlen($type);
  54293. $lineIndentation = str_repeat(' ', $indentLength);
  54294. }
  54295. foreach ($messages as $key => $message) {
  54296. if ($escape) {
  54297. $message = OutputFormatter::escape($message);
  54298. }
  54299. $lines = array_merge($lines, explode(PHP_EOL, wordwrap($message, $this->lineLength - $prefixLength - $indentLength, PHP_EOL, true)));
  54300. if (\count($messages) > 1 && $key < \count($messages) - 1) {
  54301. $lines[] = '';
  54302. }
  54303. }
  54304. $firstLineIndex = 0;
  54305. if ($padding && $this->isDecorated()) {
  54306. $firstLineIndex = 1;
  54307. array_unshift($lines, '');
  54308. $lines[] = '';
  54309. }
  54310. foreach ($lines as $i => &$line) {
  54311. if (null !== $type) {
  54312. $line = $firstLineIndex === $i ? $type.$line : $lineIndentation.$line;
  54313. }
  54314. $line = $prefix.$line;
  54315. $line .= str_repeat(' ', $this->lineLength - Helper::strlenWithoutDecoration($this->getFormatter(), $line));
  54316. if ($style) {
  54317. $line = sprintf('<%s>%s</>', $style, $line);
  54318. }
  54319. }
  54320. return $lines;
  54321. }
  54322. }
  54323. <?php
  54324. namespace Symfony\Component\Console\Tester;
  54325. use Symfony\Component\Console\Application;
  54326. use Symfony\Component\Console\Input\ArrayInput;
  54327. use Symfony\Component\Console\Input\InputInterface;
  54328. use Symfony\Component\Console\Output\OutputInterface;
  54329. use Symfony\Component\Console\Output\StreamOutput;
  54330. class ApplicationTester
  54331. {
  54332. private $application;
  54333. private $input;
  54334. private $output;
  54335. private $statusCode;
  54336. public function __construct(Application $application)
  54337. {
  54338. $this->application = $application;
  54339. }
  54340. public function run(array $input, $options = array())
  54341. {
  54342. $this->input = new ArrayInput($input);
  54343. if (isset($options['interactive'])) {
  54344. $this->input->setInteractive($options['interactive']);
  54345. }
  54346. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  54347. if (isset($options['decorated'])) {
  54348. $this->output->setDecorated($options['decorated']);
  54349. }
  54350. if (isset($options['verbosity'])) {
  54351. $this->output->setVerbosity($options['verbosity']);
  54352. }
  54353. return $this->statusCode = $this->application->run($this->input, $this->output);
  54354. }
  54355. public function getDisplay($normalize = false)
  54356. {
  54357. rewind($this->output->getStream());
  54358. $display = stream_get_contents($this->output->getStream());
  54359. if ($normalize) {
  54360. $display = str_replace(PHP_EOL, "\n", $display);
  54361. }
  54362. return $display;
  54363. }
  54364. public function getInput()
  54365. {
  54366. return $this->input;
  54367. }
  54368. public function getOutput()
  54369. {
  54370. return $this->output;
  54371. }
  54372. public function getStatusCode()
  54373. {
  54374. return $this->statusCode;
  54375. }
  54376. }
  54377. <?php
  54378. namespace Symfony\Component\Console\Tester;
  54379. use Symfony\Component\Console\Command\Command;
  54380. use Symfony\Component\Console\Input\ArrayInput;
  54381. use Symfony\Component\Console\Input\InputInterface;
  54382. use Symfony\Component\Console\Output\OutputInterface;
  54383. use Symfony\Component\Console\Output\StreamOutput;
  54384. class CommandTester
  54385. {
  54386. private $command;
  54387. private $input;
  54388. private $output;
  54389. private $statusCode;
  54390. public function __construct(Command $command)
  54391. {
  54392. $this->command = $command;
  54393. }
  54394. public function execute(array $input, array $options = array())
  54395. {
  54396. if (!isset($input['command'])
  54397. && (null !== $application = $this->command->getApplication())
  54398. && $application->getDefinition()->hasArgument('command')
  54399. ) {
  54400. $input = array_merge(array('command' => $this->command->getName()), $input);
  54401. }
  54402. $this->input = new ArrayInput($input);
  54403. if (isset($options['interactive'])) {
  54404. $this->input->setInteractive($options['interactive']);
  54405. }
  54406. $this->output = new StreamOutput(fopen('php://memory', 'w', false));
  54407. $this->output->setDecorated(isset($options['decorated']) ? $options['decorated'] : false);
  54408. if (isset($options['verbosity'])) {
  54409. $this->output->setVerbosity($options['verbosity']);
  54410. }
  54411. return $this->statusCode = $this->command->run($this->input, $this->output);
  54412. }
  54413. public function getDisplay($normalize = false)
  54414. {
  54415. rewind($this->output->getStream());
  54416. $display = stream_get_contents($this->output->getStream());
  54417. if ($normalize) {
  54418. $display = str_replace(PHP_EOL, "\n", $display);
  54419. }
  54420. return $display;
  54421. }
  54422. public function getInput()
  54423. {
  54424. return $this->input;
  54425. }
  54426. public function getOutput()
  54427. {
  54428. return $this->output;
  54429. }
  54430. public function getStatusCode()
  54431. {
  54432. return $this->statusCode;
  54433. }
  54434. }
  54435. <?php
  54436. namespace Symfony\Component\Debug;
  54437. use Psr\Log\AbstractLogger;
  54438. class BufferingLogger extends AbstractLogger
  54439. {
  54440. private $logs = array();
  54441. public function log($level, $message, array $context = array())
  54442. {
  54443. $this->logs[] = array($level, $message, $context);
  54444. }
  54445. public function cleanLogs()
  54446. {
  54447. $logs = $this->logs;
  54448. $this->logs = array();
  54449. return $logs;
  54450. }
  54451. }
  54452. <?php
  54453. namespace Symfony\Component\Debug;
  54454. class Debug
  54455. {
  54456. private static $enabled = false;
  54457. public static function enable($errorReportingLevel = null, $displayErrors = true)
  54458. {
  54459. if (static::$enabled) {
  54460. return;
  54461. }
  54462. static::$enabled = true;
  54463. if (null !== $errorReportingLevel) {
  54464. error_reporting($errorReportingLevel);
  54465. } else {
  54466. error_reporting(-1);
  54467. }
  54468. if (!\in_array(\PHP_SAPI, array('cli', 'phpdbg'), true)) {
  54469. ini_set('display_errors', 0);
  54470. ExceptionHandler::register();
  54471. } elseif ($displayErrors && (!filter_var(ini_get('log_errors'), FILTER_VALIDATE_BOOLEAN) || ini_get('error_log'))) {
  54472. ini_set('display_errors', 1);
  54473. }
  54474. if ($displayErrors) {
  54475. ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
  54476. } else {
  54477. ErrorHandler::register()->throwAt(0, true);
  54478. }
  54479. DebugClassLoader::enable();
  54480. }
  54481. }
  54482. <?php
  54483. namespace Symfony\Component\Debug;
  54484. class DebugClassLoader
  54485. {
  54486. private $classLoader;
  54487. private $isFinder;
  54488. private $loaded = array();
  54489. private $wasFinder;
  54490. private static $caseCheck;
  54491. private static $deprecated = array();
  54492. private static $php7Reserved = array('int', 'float', 'bool', 'string', 'true', 'false', 'null');
  54493. private static $darwinCache = array('/' => array('/', array()));
  54494. public function __construct($classLoader)
  54495. {
  54496. $this->wasFinder = \is_object($classLoader) && method_exists($classLoader, 'findFile');
  54497. if ($this->wasFinder) {
  54498. @trigger_error('The '.__METHOD__.' method will no longer support receiving an object into its $classLoader argument in 3.0.', E_USER_DEPRECATED);
  54499. $this->classLoader = array($classLoader, 'loadClass');
  54500. $this->isFinder = true;
  54501. } else {
  54502. $this->classLoader = $classLoader;
  54503. $this->isFinder = \is_array($classLoader) && method_exists($classLoader[0], 'findFile');
  54504. }
  54505. if (!isset(self::$caseCheck)) {
  54506. $file = file_exists(__FILE__) ? __FILE__ : rtrim(realpath('.'), \DIRECTORY_SEPARATOR);
  54507. $i = strrpos($file, \DIRECTORY_SEPARATOR);
  54508. $dir = substr($file, 0, 1 + $i);
  54509. $file = substr($file, 1 + $i);
  54510. $test = strtoupper($file) === $file ? strtolower($file) : strtoupper($file);
  54511. $test = realpath($dir.$test);
  54512. if (false === $test || false === $i) {
  54513. self::$caseCheck = 0;
  54514. } elseif (substr($test, -\strlen($file)) === $file) {
  54515. self::$caseCheck = 1;
  54516. } elseif (false !== stripos(PHP_OS, 'darwin')) {
  54517. self::$caseCheck = 2;
  54518. } else {
  54519. self::$caseCheck = 0;
  54520. }
  54521. }
  54522. }
  54523. public function getClassLoader()
  54524. {
  54525. return $this->wasFinder ? $this->classLoader[0] : $this->classLoader;
  54526. }
  54527. public static function enable()
  54528. {
  54529. class_exists('Symfony\Component\Debug\ErrorHandler');
  54530. class_exists('Psr\Log\LogLevel');
  54531. if (!\is_array($functions = spl_autoload_functions())) {
  54532. return;
  54533. }
  54534. foreach ($functions as $function) {
  54535. spl_autoload_unregister($function);
  54536. }
  54537. foreach ($functions as $function) {
  54538. if (!\is_array($function) || !$function[0] instanceof self) {
  54539. $function = array(new static($function), 'loadClass');
  54540. }
  54541. spl_autoload_register($function);
  54542. }
  54543. }
  54544. public static function disable()
  54545. {
  54546. if (!\is_array($functions = spl_autoload_functions())) {
  54547. return;
  54548. }
  54549. foreach ($functions as $function) {
  54550. spl_autoload_unregister($function);
  54551. }
  54552. foreach ($functions as $function) {
  54553. if (\is_array($function) && $function[0] instanceof self) {
  54554. $function = $function[0]->getClassLoader();
  54555. }
  54556. spl_autoload_register($function);
  54557. }
  54558. }
  54559. public function findFile($class)
  54560. {
  54561. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  54562. if ($this->wasFinder) {
  54563. return $this->classLoader[0]->findFile($class);
  54564. }
  54565. }
  54566. public function loadClass($class)
  54567. {
  54568. ErrorHandler::stackErrors();
  54569. try {
  54570. if ($this->isFinder && !isset($this->loaded[$class])) {
  54571. $this->loaded[$class] = true;
  54572. if ($file = $this->classLoader[0]->findFile($class)) {
  54573. require $file;
  54574. }
  54575. } else {
  54576. \call_user_func($this->classLoader, $class);
  54577. $file = false;
  54578. }
  54579. } catch (\Exception $e) {
  54580. ErrorHandler::unstackErrors();
  54581. throw $e;
  54582. } catch (\Throwable $e) {
  54583. ErrorHandler::unstackErrors();
  54584. throw $e;
  54585. }
  54586. ErrorHandler::unstackErrors();
  54587. $exists = class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  54588. if ($class && '\\' === $class[0]) {
  54589. $class = substr($class, 1);
  54590. }
  54591. if ($exists) {
  54592. $refl = new \ReflectionClass($class);
  54593. $name = $refl->getName();
  54594. if ($name !== $class && 0 === strcasecmp($name, $class)) {
  54595. throw new \RuntimeException(sprintf('Case mismatch between loaded and declared class names: %s vs %s', $class, $name));
  54596. }
  54597. if (\in_array(strtolower($refl->getShortName()), self::$php7Reserved)) {
  54598. @trigger_error(sprintf('%s uses a reserved class name (%s) that will break on PHP 7 and higher', $name, $refl->getShortName()), E_USER_DEPRECATED);
  54599. } elseif (preg_match('#\n \* @deprecated (.*?)\r?\n \*(?: @|/$)#s', $refl->getDocComment(), $notice)) {
  54600. self::$deprecated[$name] = preg_replace('#\s*\r?\n \* +#', ' ', $notice[1]);
  54601. } else {
  54602. if (2 > $len = 1 + (strpos($name, '\\') ?: strpos($name, '_'))) {
  54603. $len = 0;
  54604. $ns = '';
  54605. } else {
  54606. $ns = substr($name, 0, $len);
  54607. }
  54608. $parent = get_parent_class($class);
  54609. if (!$parent || strncmp($ns, $parent, $len)) {
  54610. if ($parent && isset(self::$deprecated[$parent]) && strncmp($ns, $parent, $len)) {
  54611. @trigger_error(sprintf('The %s class extends %s that is deprecated %s', $name, $parent, self::$deprecated[$parent]), E_USER_DEPRECATED);
  54612. }
  54613. $parentInterfaces = array();
  54614. $deprecatedInterfaces = array();
  54615. if ($parent) {
  54616. foreach (class_implements($parent) as $interface) {
  54617. $parentInterfaces[$interface] = 1;
  54618. }
  54619. }
  54620. foreach ($refl->getInterfaceNames() as $interface) {
  54621. if (isset(self::$deprecated[$interface]) && strncmp($ns, $interface, $len)) {
  54622. $deprecatedInterfaces[] = $interface;
  54623. }
  54624. foreach (class_implements($interface) as $interface) {
  54625. $parentInterfaces[$interface] = 1;
  54626. }
  54627. }
  54628. foreach ($deprecatedInterfaces as $interface) {
  54629. if (!isset($parentInterfaces[$interface])) {
  54630. @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);
  54631. }
  54632. }
  54633. }
  54634. }
  54635. }
  54636. if ($file) {
  54637. if (!$exists) {
  54638. if (false !== strpos($class, '/')) {
  54639. 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));
  54640. }
  54641. 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));
  54642. }
  54643. if (self::$caseCheck) {
  54644. $real = explode('\\', $class.strrchr($file, '.'));
  54645. $tail = explode(\DIRECTORY_SEPARATOR, str_replace('/', \DIRECTORY_SEPARATOR, $file));
  54646. $i = \count($tail) - 1;
  54647. $j = \count($real) - 1;
  54648. while (isset($tail[$i], $real[$j]) && $tail[$i] === $real[$j]) {
  54649. --$i;
  54650. --$j;
  54651. }
  54652. array_splice($tail, 0, $i + 1);
  54653. }
  54654. if (self::$caseCheck && $tail) {
  54655. $tail = \DIRECTORY_SEPARATOR.implode(\DIRECTORY_SEPARATOR, $tail);
  54656. $tailLen = \strlen($tail);
  54657. $real = $refl->getFileName();
  54658. if (2 === self::$caseCheck) {
  54659. $i = 1 + strrpos($real, '/');
  54660. $file = substr($real, $i);
  54661. $real = substr($real, 0, $i);
  54662. if (isset(self::$darwinCache[$real])) {
  54663. $kDir = $real;
  54664. } else {
  54665. $kDir = strtolower($real);
  54666. if (isset(self::$darwinCache[$kDir])) {
  54667. $real = self::$darwinCache[$kDir][0];
  54668. } else {
  54669. $dir = getcwd();
  54670. chdir($real);
  54671. $real = getcwd().'/';
  54672. chdir($dir);
  54673. $dir = $real;
  54674. $k = $kDir;
  54675. $i = \strlen($dir) - 1;
  54676. while (!isset(self::$darwinCache[$k])) {
  54677. self::$darwinCache[$k] = array($dir, array());
  54678. self::$darwinCache[$dir] = &self::$darwinCache[$k];
  54679. while ('/' !== $dir[--$i]) {
  54680. }
  54681. $k = substr($k, 0, ++$i);
  54682. $dir = substr($dir, 0, $i--);
  54683. }
  54684. }
  54685. }
  54686. $dirFiles = self::$darwinCache[$kDir][1];
  54687. if (isset($dirFiles[$file])) {
  54688. $kFile = $file;
  54689. } else {
  54690. $kFile = strtolower($file);
  54691. if (!isset($dirFiles[$kFile])) {
  54692. foreach (scandir($real, 2) as $f) {
  54693. if ('.' !== $f[0]) {
  54694. $dirFiles[$f] = $f;
  54695. if ($f === $file) {
  54696. $kFile = $k = $file;
  54697. } elseif ($f !== $k = strtolower($f)) {
  54698. $dirFiles[$k] = $f;
  54699. }
  54700. }
  54701. }
  54702. self::$darwinCache[$kDir][1] = $dirFiles;
  54703. }
  54704. }
  54705. $real .= $dirFiles[$kFile];
  54706. }
  54707. if (0 === substr_compare($real, $tail, -$tailLen, $tailLen, true)
  54708. && 0 !== substr_compare($real, $tail, -$tailLen, $tailLen, false)
  54709. ) {
  54710. 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)));
  54711. }
  54712. }
  54713. return true;
  54714. }
  54715. }
  54716. }
  54717. <?php
  54718. namespace Symfony\Component\Debug;
  54719. use Psr\Log\LoggerInterface;
  54720. use Psr\Log\LogLevel;
  54721. use Symfony\Component\Debug\Exception\ContextErrorException;
  54722. use Symfony\Component\Debug\Exception\FatalErrorException;
  54723. use Symfony\Component\Debug\Exception\FatalThrowableError;
  54724. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  54725. use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
  54726. use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface;
  54727. use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
  54728. use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
  54729. class ErrorHandler
  54730. {
  54731. const TYPE_DEPRECATION = -100;
  54732. private $levels = array(
  54733. E_DEPRECATED => 'Deprecated',
  54734. E_USER_DEPRECATED => 'User Deprecated',
  54735. E_NOTICE => 'Notice',
  54736. E_USER_NOTICE => 'User Notice',
  54737. E_STRICT => 'Runtime Notice',
  54738. E_WARNING => 'Warning',
  54739. E_USER_WARNING => 'User Warning',
  54740. E_COMPILE_WARNING => 'Compile Warning',
  54741. E_CORE_WARNING => 'Core Warning',
  54742. E_USER_ERROR => 'User Error',
  54743. E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
  54744. E_COMPILE_ERROR => 'Compile Error',
  54745. E_PARSE => 'Parse Error',
  54746. E_ERROR => 'Error',
  54747. E_CORE_ERROR => 'Core Error',
  54748. );
  54749. private $loggers = array(
  54750. E_DEPRECATED => array(null, LogLevel::INFO),
  54751. E_USER_DEPRECATED => array(null, LogLevel::INFO),
  54752. E_NOTICE => array(null, LogLevel::WARNING),
  54753. E_USER_NOTICE => array(null, LogLevel::WARNING),
  54754. E_STRICT => array(null, LogLevel::WARNING),
  54755. E_WARNING => array(null, LogLevel::WARNING),
  54756. E_USER_WARNING => array(null, LogLevel::WARNING),
  54757. E_COMPILE_WARNING => array(null, LogLevel::WARNING),
  54758. E_CORE_WARNING => array(null, LogLevel::WARNING),
  54759. E_USER_ERROR => array(null, LogLevel::CRITICAL),
  54760. E_RECOVERABLE_ERROR => array(null, LogLevel::CRITICAL),
  54761. E_COMPILE_ERROR => array(null, LogLevel::CRITICAL),
  54762. E_PARSE => array(null, LogLevel::CRITICAL),
  54763. E_ERROR => array(null, LogLevel::CRITICAL),
  54764. E_CORE_ERROR => array(null, LogLevel::CRITICAL),
  54765. );
  54766. private $thrownErrors = 0x1FFF;
  54767. private $scopedErrors = 0x1FFF;
  54768. private $tracedErrors = 0x77FB;
  54769. private $screamedErrors = 0x55;
  54770. private $loggedErrors = 0;
  54771. private $loggedTraces = array();
  54772. private $isRecursive = 0;
  54773. private $isRoot = false;
  54774. private $exceptionHandler;
  54775. private $bootstrappingLogger;
  54776. private static $reservedMemory;
  54777. private static $stackedErrors = array();
  54778. private static $stackedErrorLevels = array();
  54779. private static $toStringException = null;
  54780. private static $exitCode = 0;
  54781. private $displayErrors = 0x1FFF;
  54782. public static function register($handler = null, $replace = true)
  54783. {
  54784. if (null === self::$reservedMemory) {
  54785. self::$reservedMemory = str_repeat('x', 10240);
  54786. register_shutdown_function(__CLASS__.'::handleFatalError');
  54787. }
  54788. $levels = -1;
  54789. if ($handlerIsNew = !$handler instanceof self) {
  54790. if (null !== $handler) {
  54791. $levels = $replace ? $handler : 0;
  54792. $replace = true;
  54793. }
  54794. $handler = new static();
  54795. }
  54796. if (null === $prev = set_error_handler(array($handler, 'handleError'))) {
  54797. restore_error_handler();
  54798. set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors);
  54799. $handler->isRoot = true;
  54800. }
  54801. if ($handlerIsNew && \is_array($prev) && $prev[0] instanceof self) {
  54802. $handler = $prev[0];
  54803. $replace = false;
  54804. }
  54805. if (!$replace && $prev) {
  54806. restore_error_handler();
  54807. $handlerIsRegistered = \is_array($prev) && $handler === $prev[0];
  54808. } else {
  54809. $handlerIsRegistered = true;
  54810. }
  54811. if (\is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] instanceof self) {
  54812. restore_exception_handler();
  54813. if (!$handlerIsRegistered) {
  54814. $handler = $prev[0];
  54815. } elseif ($handler !== $prev[0] && $replace) {
  54816. set_exception_handler(array($handler, 'handleException'));
  54817. $p = $prev[0]->setExceptionHandler(null);
  54818. $handler->setExceptionHandler($p);
  54819. $prev[0]->setExceptionHandler($p);
  54820. }
  54821. } else {
  54822. $handler->setExceptionHandler($prev);
  54823. }
  54824. $handler->throwAt($levels & $handler->thrownErrors, true);
  54825. return $handler;
  54826. }
  54827. public function __construct(BufferingLogger $bootstrappingLogger = null)
  54828. {
  54829. if ($bootstrappingLogger) {
  54830. $this->bootstrappingLogger = $bootstrappingLogger;
  54831. $this->setDefaultLogger($bootstrappingLogger);
  54832. }
  54833. }
  54834. public function setDefaultLogger(LoggerInterface $logger, $levels = null, $replace = false)
  54835. {
  54836. $loggers = array();
  54837. if (\is_array($levels)) {
  54838. foreach ($levels as $type => $logLevel) {
  54839. if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) {
  54840. $loggers[$type] = array($logger, $logLevel);
  54841. }
  54842. }
  54843. } else {
  54844. if (null === $levels) {
  54845. $levels = E_ALL | E_STRICT;
  54846. }
  54847. foreach ($this->loggers as $type => $log) {
  54848. if (($type & $levels) && (empty($log[0]) || $replace || $log[0] === $this->bootstrappingLogger)) {
  54849. $log[0] = $logger;
  54850. $loggers[$type] = $log;
  54851. }
  54852. }
  54853. }
  54854. $this->setLoggers($loggers);
  54855. }
  54856. public function setLoggers(array $loggers)
  54857. {
  54858. $prevLogged = $this->loggedErrors;
  54859. $prev = $this->loggers;
  54860. $flush = array();
  54861. foreach ($loggers as $type => $log) {
  54862. if (!isset($prev[$type])) {
  54863. throw new \InvalidArgumentException('Unknown error type: '.$type);
  54864. }
  54865. if (!\is_array($log)) {
  54866. $log = array($log);
  54867. } elseif (!array_key_exists(0, $log)) {
  54868. throw new \InvalidArgumentException('No logger provided');
  54869. }
  54870. if (null === $log[0]) {
  54871. $this->loggedErrors &= ~$type;
  54872. } elseif ($log[0] instanceof LoggerInterface) {
  54873. $this->loggedErrors |= $type;
  54874. } else {
  54875. throw new \InvalidArgumentException('Invalid logger provided');
  54876. }
  54877. $this->loggers[$type] = $log + $prev[$type];
  54878. if ($this->bootstrappingLogger && $prev[$type][0] === $this->bootstrappingLogger) {
  54879. $flush[$type] = $type;
  54880. }
  54881. }
  54882. $this->reRegister($prevLogged | $this->thrownErrors);
  54883. if ($flush) {
  54884. foreach ($this->bootstrappingLogger->cleanLogs() as $log) {
  54885. $type = $log[2]['type'];
  54886. if (!isset($flush[$type])) {
  54887. $this->bootstrappingLogger->log($log[0], $log[1], $log[2]);
  54888. } elseif ($this->loggers[$type][0]) {
  54889. $this->loggers[$type][0]->log($this->loggers[$type][1], $log[1], $log[2]);
  54890. }
  54891. }
  54892. }
  54893. return $prev;
  54894. }
  54895. public function setExceptionHandler($handler)
  54896. {
  54897. if (null !== $handler && !\is_callable($handler)) {
  54898. throw new \LogicException('The exception handler must be a valid PHP callable.');
  54899. }
  54900. $prev = $this->exceptionHandler;
  54901. $this->exceptionHandler = $handler;
  54902. return $prev;
  54903. }
  54904. public function throwAt($levels, $replace = false)
  54905. {
  54906. $prev = $this->thrownErrors;
  54907. $this->thrownErrors = ($levels | E_RECOVERABLE_ERROR | E_USER_ERROR) & ~E_USER_DEPRECATED & ~E_DEPRECATED;
  54908. if (!$replace) {
  54909. $this->thrownErrors |= $prev;
  54910. }
  54911. $this->reRegister($prev | $this->loggedErrors);
  54912. $this->displayErrors = $this->thrownErrors;
  54913. return $prev;
  54914. }
  54915. public function scopeAt($levels, $replace = false)
  54916. {
  54917. $prev = $this->scopedErrors;
  54918. $this->scopedErrors = (int) $levels;
  54919. if (!$replace) {
  54920. $this->scopedErrors |= $prev;
  54921. }
  54922. return $prev;
  54923. }
  54924. public function traceAt($levels, $replace = false)
  54925. {
  54926. $prev = $this->tracedErrors;
  54927. $this->tracedErrors = (int) $levels;
  54928. if (!$replace) {
  54929. $this->tracedErrors |= $prev;
  54930. }
  54931. return $prev;
  54932. }
  54933. public function screamAt($levels, $replace = false)
  54934. {
  54935. $prev = $this->screamedErrors;
  54936. $this->screamedErrors = (int) $levels;
  54937. if (!$replace) {
  54938. $this->screamedErrors |= $prev;
  54939. }
  54940. return $prev;
  54941. }
  54942. private function reRegister($prev)
  54943. {
  54944. if ($prev !== $this->thrownErrors | $this->loggedErrors) {
  54945. $handler = set_error_handler('var_dump');
  54946. $handler = \is_array($handler) ? $handler[0] : null;
  54947. restore_error_handler();
  54948. if ($handler === $this) {
  54949. restore_error_handler();
  54950. if ($this->isRoot) {
  54951. set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors);
  54952. } else {
  54953. set_error_handler(array($this, 'handleError'));
  54954. }
  54955. }
  54956. }
  54957. }
  54958. public function handleError($type, $message, $file, $line)
  54959. {
  54960. $level = error_reporting();
  54961. $silenced = 0 === ($level & $type);
  54962. $level |= E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED;
  54963. $log = $this->loggedErrors & $type;
  54964. $throw = $this->thrownErrors & $type & $level;
  54965. $type &= $level | $this->screamedErrors;
  54966. if (!$type || (!$log && !$throw)) {
  54967. return !$silenced && $type && $log;
  54968. }
  54969. $scope = $this->scopedErrors & $type;
  54970. if (4 < $numArgs = \func_num_args()) {
  54971. $context = $scope ? (func_get_arg(4) ?: array()) : array();
  54972. $backtrace = 5 < $numArgs ? func_get_arg(5) : null;
  54973. } else {
  54974. $context = array();
  54975. $backtrace = null;
  54976. }
  54977. if (isset($context['GLOBALS']) && $scope) {
  54978. $e = $context;
  54979. unset($e['GLOBALS'], $context);
  54980. $context = $e;
  54981. }
  54982. if (null !== $backtrace && $type & E_ERROR) {
  54983. $this->handleFatalError(compact('type', 'message', 'file', 'line', 'backtrace'));
  54984. return true;
  54985. }
  54986. if ($throw) {
  54987. if (null !== self::$toStringException) {
  54988. $throw = self::$toStringException;
  54989. self::$toStringException = null;
  54990. } elseif ($scope && class_exists('Symfony\Component\Debug\Exception\ContextErrorException')) {
  54991. $throw = new ContextErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line, $context);
  54992. } else {
  54993. $throw = new \ErrorException($this->levels[$type].': '.$message, 0, $type, $file, $line);
  54994. }
  54995. if (\PHP_VERSION_ID <= 50407 && (\PHP_VERSION_ID >= 50400 || \PHP_VERSION_ID <= 50317)) {
  54996. $throw->errorHandlerCanary = new ErrorHandlerCanary();
  54997. }
  54998. if (E_USER_ERROR & $type) {
  54999. $backtrace = $backtrace ?: $throw->getTrace();
  55000. for ($i = 1; isset($backtrace[$i]); ++$i) {
  55001. if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
  55002. && '__toString' === $backtrace[$i]['function']
  55003. && '->' === $backtrace[$i]['type']
  55004. && !isset($backtrace[$i - 1]['class'])
  55005. && ('trigger_error' === $backtrace[$i - 1]['function'] || 'user_error' === $backtrace[$i - 1]['function'])
  55006. ) {
  55007. foreach ($context as $e) {
  55008. if (($e instanceof \Exception || $e instanceof \Throwable) && $e->__toString() === $message) {
  55009. if (1 === $i) {
  55010. $throw = $e;
  55011. break;
  55012. }
  55013. self::$toStringException = $e;
  55014. return true;
  55015. }
  55016. }
  55017. if (1 < $i) {
  55018. $this->handleException($throw);
  55019. return false;
  55020. }
  55021. }
  55022. }
  55023. }
  55024. throw $throw;
  55025. }
  55026. $e = md5("{$type}/{$line}/{$file}\x00{$message}", true);
  55027. $trace = true;
  55028. if (!($this->tracedErrors & $type) || isset($this->loggedTraces[$e])) {
  55029. $trace = false;
  55030. } else {
  55031. $this->loggedTraces[$e] = 1;
  55032. }
  55033. $e = compact('type', 'file', 'line', 'level');
  55034. if ($type & $level) {
  55035. if ($scope) {
  55036. $e['scope_vars'] = $context;
  55037. if ($trace) {
  55038. $e['stack'] = $backtrace ?: debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
  55039. }
  55040. } elseif ($trace) {
  55041. if (null === $backtrace) {
  55042. $e['stack'] = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
  55043. } else {
  55044. foreach ($backtrace as &$frame) {
  55045. unset($frame['args'], $frame);
  55046. }
  55047. $e['stack'] = $backtrace;
  55048. }
  55049. }
  55050. }
  55051. if ($this->isRecursive) {
  55052. $log = 0;
  55053. } elseif (self::$stackedErrorLevels) {
  55054. self::$stackedErrors[] = array($this->loggers[$type][0], ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  55055. } else {
  55056. try {
  55057. $this->isRecursive = true;
  55058. $this->loggers[$type][0]->log(($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, $message, $e);
  55059. $this->isRecursive = false;
  55060. } catch (\Exception $e) {
  55061. $this->isRecursive = false;
  55062. throw $e;
  55063. } catch (\Throwable $e) {
  55064. $this->isRecursive = false;
  55065. throw $e;
  55066. }
  55067. }
  55068. return !$silenced && $type && $log;
  55069. }
  55070. public function handleException($exception, array $error = null)
  55071. {
  55072. if (null === $error) {
  55073. self::$exitCode = 255;
  55074. }
  55075. if (!$exception instanceof \Exception) {
  55076. $exception = new FatalThrowableError($exception);
  55077. }
  55078. $type = $exception instanceof FatalErrorException ? $exception->getSeverity() : E_ERROR;
  55079. $handlerException = null;
  55080. if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
  55081. $e = array(
  55082. 'type' => $type,
  55083. 'file' => $exception->getFile(),
  55084. 'line' => $exception->getLine(),
  55085. 'level' => error_reporting(),
  55086. 'stack' => $exception->getTrace(),
  55087. );
  55088. if ($exception instanceof FatalErrorException) {
  55089. if ($exception instanceof FatalThrowableError) {
  55090. $error = array(
  55091. 'type' => $type,
  55092. 'message' => $message = $exception->getMessage(),
  55093. 'file' => $e['file'],
  55094. 'line' => $e['line'],
  55095. );
  55096. } else {
  55097. $message = 'Fatal '.$exception->getMessage();
  55098. }
  55099. } elseif ($exception instanceof \ErrorException) {
  55100. $message = 'Uncaught '.$exception->getMessage();
  55101. if ($exception instanceof ContextErrorException) {
  55102. $e['context'] = $exception->getContext();
  55103. }
  55104. } else {
  55105. $message = 'Uncaught Exception: '.$exception->getMessage();
  55106. }
  55107. }
  55108. if ($this->loggedErrors & $type) {
  55109. try {
  55110. $this->loggers[$type][0]->log($this->loggers[$type][1], $message, $e);
  55111. } catch (\Exception $handlerException) {
  55112. } catch (\Throwable $handlerException) {
  55113. }
  55114. }
  55115. if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
  55116. foreach ($this->getFatalErrorHandlers() as $handler) {
  55117. if ($e = $handler->handleError($error, $exception)) {
  55118. $exception = $e;
  55119. break;
  55120. }
  55121. }
  55122. }
  55123. $exceptionHandler = $this->exceptionHandler;
  55124. $this->exceptionHandler = null;
  55125. try {
  55126. if (null !== $exceptionHandler) {
  55127. return \call_user_func($exceptionHandler, $exception);
  55128. }
  55129. $handlerException = $handlerException ?: $exception;
  55130. } catch (\Exception $handlerException) {
  55131. } catch (\Throwable $handlerException) {
  55132. }
  55133. if ($exception === $handlerException) {
  55134. self::$reservedMemory = null;
  55135. throw $exception;
  55136. }
  55137. $this->handleException($handlerException);
  55138. }
  55139. public static function handleFatalError(array $error = null)
  55140. {
  55141. if (null === self::$reservedMemory) {
  55142. return;
  55143. }
  55144. $handler = self::$reservedMemory = null;
  55145. $handlers = array();
  55146. $previousHandler = null;
  55147. $sameHandlerLimit = 10;
  55148. while (!\is_array($handler) || !$handler[0] instanceof self) {
  55149. $handler = set_exception_handler('var_dump');
  55150. restore_exception_handler();
  55151. if (!$handler) {
  55152. break;
  55153. }
  55154. restore_exception_handler();
  55155. if ($handler !== $previousHandler) {
  55156. array_unshift($handlers, $handler);
  55157. $previousHandler = $handler;
  55158. } elseif (0 === --$sameHandlerLimit) {
  55159. $handler = null;
  55160. break;
  55161. }
  55162. }
  55163. foreach ($handlers as $h) {
  55164. set_exception_handler($h);
  55165. }
  55166. if (!$handler) {
  55167. return;
  55168. }
  55169. if ($handler !== $h) {
  55170. $handler[0]->setExceptionHandler($h);
  55171. }
  55172. $handler = $handler[0];
  55173. $handlers = array();
  55174. if ($exit = null === $error) {
  55175. $error = error_get_last();
  55176. }
  55177. try {
  55178. while (self::$stackedErrorLevels) {
  55179. static::unstackErrors();
  55180. }
  55181. } catch (\Exception $exception) {
  55182. } catch (\Throwable $exception) {
  55183. }
  55184. if ($error && $error['type'] &= E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR) {
  55185. $handler->throwAt(0, true);
  55186. $trace = isset($error['backtrace']) ? $error['backtrace'] : null;
  55187. if (0 === strpos($error['message'], 'Allowed memory') || 0 === strpos($error['message'], 'Out of memory')) {
  55188. $exception = new OutOfMemoryException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, false, $trace);
  55189. } else {
  55190. $exception = new FatalErrorException($handler->levels[$error['type']].': '.$error['message'], 0, $error['type'], $error['file'], $error['line'], 2, true, $trace);
  55191. }
  55192. }
  55193. try {
  55194. if (isset($exception)) {
  55195. self::$exitCode = 255;
  55196. $handler->handleException($exception, $error);
  55197. }
  55198. } catch (FatalErrorException $e) {
  55199. }
  55200. if ($exit && self::$exitCode) {
  55201. $exitCode = self::$exitCode;
  55202. register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
  55203. }
  55204. }
  55205. public static function stackErrors()
  55206. {
  55207. self::$stackedErrorLevels[] = error_reporting(error_reporting() | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  55208. }
  55209. public static function unstackErrors()
  55210. {
  55211. $level = array_pop(self::$stackedErrorLevels);
  55212. if (null !== $level) {
  55213. $e = error_reporting($level);
  55214. if ($e !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
  55215. error_reporting($e);
  55216. }
  55217. }
  55218. if (empty(self::$stackedErrorLevels)) {
  55219. $errors = self::$stackedErrors;
  55220. self::$stackedErrors = array();
  55221. foreach ($errors as $e) {
  55222. $e[0]->log($e[1], $e[2], $e[3]);
  55223. }
  55224. }
  55225. }
  55226. protected function getFatalErrorHandlers()
  55227. {
  55228. return array(
  55229. new UndefinedFunctionFatalErrorHandler(),
  55230. new UndefinedMethodFatalErrorHandler(),
  55231. new ClassNotFoundFatalErrorHandler(),
  55232. );
  55233. }
  55234. public function setLevel($level)
  55235. {
  55236. @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);
  55237. $level = null === $level ? error_reporting() : $level;
  55238. $this->throwAt($level, true);
  55239. }
  55240. public function setDisplayErrors($displayErrors)
  55241. {
  55242. @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);
  55243. if ($displayErrors) {
  55244. $this->throwAt($this->displayErrors, true);
  55245. } else {
  55246. $displayErrors = $this->displayErrors;
  55247. $this->throwAt(0, true);
  55248. $this->displayErrors = $displayErrors;
  55249. }
  55250. }
  55251. public static function setLogger(LoggerInterface $logger, $channel = 'deprecation')
  55252. {
  55253. @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);
  55254. $handler = set_error_handler('var_dump');
  55255. $handler = \is_array($handler) ? $handler[0] : null;
  55256. restore_error_handler();
  55257. if (!$handler instanceof self) {
  55258. return;
  55259. }
  55260. if ('deprecation' === $channel) {
  55261. $handler->setDefaultLogger($logger, E_DEPRECATED | E_USER_DEPRECATED, true);
  55262. $handler->screamAt(E_DEPRECATED | E_USER_DEPRECATED);
  55263. } elseif ('scream' === $channel) {
  55264. $handler->setDefaultLogger($logger, E_ALL | E_STRICT, false);
  55265. $handler->screamAt(E_ALL | E_STRICT);
  55266. } elseif ('emergency' === $channel) {
  55267. $handler->setDefaultLogger($logger, E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR, true);
  55268. $handler->screamAt(E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR);
  55269. }
  55270. }
  55271. public function handle($level, $message, $file = 'unknown', $line = 0, $context = array())
  55272. {
  55273. $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());
  55274. return $this->handleError($level, $message, $file, $line, (array) $context);
  55275. }
  55276. public function handleFatal()
  55277. {
  55278. @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);
  55279. static::handleFatalError();
  55280. }
  55281. }
  55282. class ErrorHandlerCanary
  55283. {
  55284. private static $displayErrors = null;
  55285. public function __construct()
  55286. {
  55287. if (null === self::$displayErrors) {
  55288. self::$displayErrors = ini_set('display_errors', 1);
  55289. }
  55290. }
  55291. public function __destruct()
  55292. {
  55293. if (null !== self::$displayErrors) {
  55294. ini_set('display_errors', self::$displayErrors);
  55295. self::$displayErrors = null;
  55296. }
  55297. }
  55298. }
  55299. <?php
  55300. namespace Symfony\Component\Debug\Exception;
  55301. class ClassNotFoundException extends FatalErrorException
  55302. {
  55303. public function __construct($message, \ErrorException $previous)
  55304. {
  55305. parent::__construct(
  55306. $message,
  55307. $previous->getCode(),
  55308. $previous->getSeverity(),
  55309. $previous->getFile(),
  55310. $previous->getLine(),
  55311. null,
  55312. true,
  55313. null,
  55314. $previous->getPrevious()
  55315. );
  55316. $this->setTrace($previous->getTrace());
  55317. }
  55318. }
  55319. <?php
  55320. namespace Symfony\Component\Debug\Exception;
  55321. class ContextErrorException extends \ErrorException
  55322. {
  55323. private $context = array();
  55324. public function __construct($message, $code, $severity, $filename, $lineno, $context = array())
  55325. {
  55326. parent::__construct($message, $code, $severity, $filename, $lineno);
  55327. $this->context = $context;
  55328. }
  55329. public function getContext()
  55330. {
  55331. return $this->context;
  55332. }
  55333. }
  55334. <?php
  55335. namespace Symfony\Component\Debug\Exception;
  55336. @trigger_error('The '.__NAMESPACE__.'\DummyException class is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  55337. class DummyException extends \ErrorException
  55338. {
  55339. }
  55340. <?php
  55341. namespace Symfony\Component\HttpKernel\Exception;
  55342. class FatalErrorException extends \ErrorException
  55343. {
  55344. }
  55345. namespace Symfony\Component\Debug\Exception;
  55346. use Symfony\Component\HttpKernel\Exception\FatalErrorException as LegacyFatalErrorException;
  55347. class FatalErrorException extends LegacyFatalErrorException
  55348. {
  55349. public function __construct($message, $code, $severity, $filename, $lineno, $traceOffset = null, $traceArgs = true, array $trace = null, $previous = null)
  55350. {
  55351. parent::__construct($message, $code, $severity, $filename, $lineno, $previous);
  55352. if (null !== $trace) {
  55353. if (!$traceArgs) {
  55354. foreach ($trace as &$frame) {
  55355. unset($frame['args'], $frame['this'], $frame);
  55356. }
  55357. }
  55358. $this->setTrace($trace);
  55359. } elseif (null !== $traceOffset) {
  55360. if (\function_exists('xdebug_get_function_stack')) {
  55361. $trace = xdebug_get_function_stack();
  55362. if (0 < $traceOffset) {
  55363. array_splice($trace, -$traceOffset);
  55364. }
  55365. foreach ($trace as &$frame) {
  55366. if (!isset($frame['type'])) {
  55367. if (isset($frame['class'])) {
  55368. $frame['type'] = '::';
  55369. }
  55370. } elseif ('dynamic' === $frame['type']) {
  55371. $frame['type'] = '->';
  55372. } elseif ('static' === $frame['type']) {
  55373. $frame['type'] = '::';
  55374. }
  55375. if (!$traceArgs) {
  55376. unset($frame['params'], $frame['args']);
  55377. } elseif (isset($frame['params']) && !isset($frame['args'])) {
  55378. $frame['args'] = $frame['params'];
  55379. unset($frame['params']);
  55380. }
  55381. }
  55382. unset($frame);
  55383. $trace = array_reverse($trace);
  55384. } elseif (\function_exists('symfony_debug_backtrace')) {
  55385. $trace = symfony_debug_backtrace();
  55386. if (0 < $traceOffset) {
  55387. array_splice($trace, 0, $traceOffset);
  55388. }
  55389. } else {
  55390. $trace = array();
  55391. }
  55392. $this->setTrace($trace);
  55393. }
  55394. }
  55395. protected function setTrace($trace)
  55396. {
  55397. $traceReflector = new \ReflectionProperty('Exception', 'trace');
  55398. $traceReflector->setAccessible(true);
  55399. $traceReflector->setValue($this, $trace);
  55400. }
  55401. }
  55402. <?php
  55403. namespace Symfony\Component\Debug\Exception;
  55404. class FatalThrowableError extends FatalErrorException
  55405. {
  55406. public function __construct(\Throwable $e)
  55407. {
  55408. if ($e instanceof \ParseError) {
  55409. $message = 'Parse error: '.$e->getMessage();
  55410. $severity = E_PARSE;
  55411. } elseif ($e instanceof \TypeError) {
  55412. $message = 'Type error: '.$e->getMessage();
  55413. $severity = E_RECOVERABLE_ERROR;
  55414. } else {
  55415. $message = $e->getMessage();
  55416. $severity = E_ERROR;
  55417. }
  55418. \ErrorException::__construct(
  55419. $message,
  55420. $e->getCode(),
  55421. $severity,
  55422. $e->getFile(),
  55423. $e->getLine(),
  55424. $e->getPrevious()
  55425. );
  55426. $this->setTrace($e->getTrace());
  55427. }
  55428. }
  55429. <?php
  55430. namespace Symfony\Component\HttpKernel\Exception;
  55431. use Symfony\Component\Debug\Exception\FlattenException as DebugFlattenException;
  55432. class FlattenException
  55433. {
  55434. private $handler;
  55435. public static function __callStatic($method, $args)
  55436. {
  55437. if (!method_exists('Symfony\Component\Debug\Exception\FlattenException', $method)) {
  55438. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_called_class(), $method));
  55439. }
  55440. return \call_user_func_array(array('Symfony\Component\Debug\Exception\FlattenException', $method), $args);
  55441. }
  55442. public function __call($method, $args)
  55443. {
  55444. if (!isset($this->handler)) {
  55445. $this->handler = new DebugFlattenException();
  55446. }
  55447. if (!method_exists($this->handler, $method)) {
  55448. throw new \BadMethodCallException(sprintf('Call to undefined method %s::%s()', \get_class($this), $method));
  55449. }
  55450. return \call_user_func_array(array($this->handler, $method), $args);
  55451. }
  55452. }
  55453. namespace Symfony\Component\Debug\Exception;
  55454. use Symfony\Component\HttpKernel\Exception\FlattenException as LegacyFlattenException;
  55455. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  55456. class FlattenException extends LegacyFlattenException
  55457. {
  55458. private $message;
  55459. private $code;
  55460. private $previous;
  55461. private $trace;
  55462. private $class;
  55463. private $statusCode;
  55464. private $headers;
  55465. private $file;
  55466. private $line;
  55467. public static function create(\Exception $exception, $statusCode = null, array $headers = array())
  55468. {
  55469. $e = new static();
  55470. $e->setMessage($exception->getMessage());
  55471. $e->setCode($exception->getCode());
  55472. if ($exception instanceof HttpExceptionInterface) {
  55473. $statusCode = $exception->getStatusCode();
  55474. $headers = array_merge($headers, $exception->getHeaders());
  55475. }
  55476. if (null === $statusCode) {
  55477. $statusCode = 500;
  55478. }
  55479. $e->setStatusCode($statusCode);
  55480. $e->setHeaders($headers);
  55481. $e->setTraceFromException($exception);
  55482. $e->setClass(\get_class($exception));
  55483. $e->setFile($exception->getFile());
  55484. $e->setLine($exception->getLine());
  55485. $previous = $exception->getPrevious();
  55486. if ($previous instanceof \Exception) {
  55487. $e->setPrevious(static::create($previous));
  55488. } elseif ($previous instanceof \Throwable) {
  55489. $e->setPrevious(static::create(new FatalThrowableError($previous)));
  55490. }
  55491. return $e;
  55492. }
  55493. public function toArray()
  55494. {
  55495. $exceptions = array();
  55496. foreach (array_merge(array($this), $this->getAllPrevious()) as $exception) {
  55497. $exceptions[] = array(
  55498. 'message' => $exception->getMessage(),
  55499. 'class' => $exception->getClass(),
  55500. 'trace' => $exception->getTrace(),
  55501. );
  55502. }
  55503. return $exceptions;
  55504. }
  55505. public function getStatusCode()
  55506. {
  55507. return $this->statusCode;
  55508. }
  55509. public function setStatusCode($code)
  55510. {
  55511. $this->statusCode = $code;
  55512. }
  55513. public function getHeaders()
  55514. {
  55515. return $this->headers;
  55516. }
  55517. public function setHeaders(array $headers)
  55518. {
  55519. $this->headers = $headers;
  55520. }
  55521. public function getClass()
  55522. {
  55523. return $this->class;
  55524. }
  55525. public function setClass($class)
  55526. {
  55527. $this->class = $class;
  55528. }
  55529. public function getFile()
  55530. {
  55531. return $this->file;
  55532. }
  55533. public function setFile($file)
  55534. {
  55535. $this->file = $file;
  55536. }
  55537. public function getLine()
  55538. {
  55539. return $this->line;
  55540. }
  55541. public function setLine($line)
  55542. {
  55543. $this->line = $line;
  55544. }
  55545. public function getMessage()
  55546. {
  55547. return $this->message;
  55548. }
  55549. public function setMessage($message)
  55550. {
  55551. $this->message = $message;
  55552. }
  55553. public function getCode()
  55554. {
  55555. return $this->code;
  55556. }
  55557. public function setCode($code)
  55558. {
  55559. $this->code = $code;
  55560. }
  55561. public function getPrevious()
  55562. {
  55563. return $this->previous;
  55564. }
  55565. public function setPrevious(FlattenException $previous)
  55566. {
  55567. $this->previous = $previous;
  55568. }
  55569. public function getAllPrevious()
  55570. {
  55571. $exceptions = array();
  55572. $e = $this;
  55573. while ($e = $e->getPrevious()) {
  55574. $exceptions[] = $e;
  55575. }
  55576. return $exceptions;
  55577. }
  55578. public function getTrace()
  55579. {
  55580. return $this->trace;
  55581. }
  55582. public function setTraceFromException(\Exception $exception)
  55583. {
  55584. $this->setTrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
  55585. }
  55586. public function setTrace($trace, $file, $line)
  55587. {
  55588. $this->trace = array();
  55589. $this->trace[] = array(
  55590. 'namespace' => '',
  55591. 'short_class' => '',
  55592. 'class' => '',
  55593. 'type' => '',
  55594. 'function' => '',
  55595. 'file' => $file,
  55596. 'line' => $line,
  55597. 'args' => array(),
  55598. );
  55599. foreach ($trace as $entry) {
  55600. $class = '';
  55601. $namespace = '';
  55602. if (isset($entry['class'])) {
  55603. $parts = explode('\\', $entry['class']);
  55604. $class = array_pop($parts);
  55605. $namespace = implode('\\', $parts);
  55606. }
  55607. $this->trace[] = array(
  55608. 'namespace' => $namespace,
  55609. 'short_class' => $class,
  55610. 'class' => isset($entry['class']) ? $entry['class'] : '',
  55611. 'type' => isset($entry['type']) ? $entry['type'] : '',
  55612. 'function' => isset($entry['function']) ? $entry['function'] : null,
  55613. 'file' => isset($entry['file']) ? $entry['file'] : null,
  55614. 'line' => isset($entry['line']) ? $entry['line'] : null,
  55615. 'args' => isset($entry['args']) ? $this->flattenArgs($entry['args']) : array(),
  55616. );
  55617. }
  55618. }
  55619. private function flattenArgs($args, $level = 0, &$count = 0)
  55620. {
  55621. $result = array();
  55622. foreach ($args as $key => $value) {
  55623. if (++$count > 1e4) {
  55624. return array('array', '*SKIPPED over 10000 entries*');
  55625. }
  55626. if ($value instanceof \__PHP_Incomplete_Class) {
  55627. $result[$key] = array('incomplete-object', $this->getClassNameFromIncomplete($value));
  55628. } elseif (\is_object($value)) {
  55629. $result[$key] = array('object', \get_class($value));
  55630. } elseif (\is_array($value)) {
  55631. if ($level > 10) {
  55632. $result[$key] = array('array', '*DEEP NESTED ARRAY*');
  55633. } else {
  55634. $result[$key] = array('array', $this->flattenArgs($value, $level + 1, $count));
  55635. }
  55636. } elseif (null === $value) {
  55637. $result[$key] = array('null', null);
  55638. } elseif (\is_bool($value)) {
  55639. $result[$key] = array('boolean', $value);
  55640. } elseif (\is_resource($value)) {
  55641. $result[$key] = array('resource', get_resource_type($value));
  55642. } else {
  55643. $result[$key] = array('string', (string) $value);
  55644. }
  55645. }
  55646. return $result;
  55647. }
  55648. private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
  55649. {
  55650. $array = new \ArrayObject($value);
  55651. return $array['__PHP_Incomplete_Class_Name'];
  55652. }
  55653. }
  55654. <?php
  55655. namespace Symfony\Component\Debug\Exception;
  55656. class OutOfMemoryException extends FatalErrorException
  55657. {
  55658. }
  55659. <?php
  55660. namespace Symfony\Component\Debug\Exception;
  55661. class UndefinedFunctionException extends FatalErrorException
  55662. {
  55663. public function __construct($message, \ErrorException $previous)
  55664. {
  55665. parent::__construct(
  55666. $message,
  55667. $previous->getCode(),
  55668. $previous->getSeverity(),
  55669. $previous->getFile(),
  55670. $previous->getLine(),
  55671. null,
  55672. true,
  55673. null,
  55674. $previous->getPrevious()
  55675. );
  55676. $this->setTrace($previous->getTrace());
  55677. }
  55678. }
  55679. <?php
  55680. namespace Symfony\Component\Debug\Exception;
  55681. class UndefinedMethodException extends FatalErrorException
  55682. {
  55683. public function __construct($message, \ErrorException $previous)
  55684. {
  55685. parent::__construct(
  55686. $message,
  55687. $previous->getCode(),
  55688. $previous->getSeverity(),
  55689. $previous->getFile(),
  55690. $previous->getLine(),
  55691. null,
  55692. true,
  55693. null,
  55694. $previous->getPrevious()
  55695. );
  55696. $this->setTrace($previous->getTrace());
  55697. }
  55698. }
  55699. <?php
  55700. namespace Symfony\Component\Debug;
  55701. use Symfony\Component\Debug\Exception\FlattenException;
  55702. use Symfony\Component\Debug\Exception\OutOfMemoryException;
  55703. use Symfony\Component\HttpFoundation\Response;
  55704. class ExceptionHandler
  55705. {
  55706. private $debug;
  55707. private $charset;
  55708. private $handler;
  55709. private $caughtBuffer;
  55710. private $caughtLength;
  55711. private $fileLinkFormat;
  55712. public function __construct($debug = true, $charset = null, $fileLinkFormat = null)
  55713. {
  55714. if (false !== strpos($charset, '%')) {
  55715. @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);
  55716. $pivot = $fileLinkFormat;
  55717. $fileLinkFormat = $charset;
  55718. $charset = $pivot;
  55719. }
  55720. $this->debug = $debug;
  55721. $this->charset = $charset ?: ini_get('default_charset') ?: 'UTF-8';
  55722. $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
  55723. }
  55724. public static function register($debug = true, $charset = null, $fileLinkFormat = null)
  55725. {
  55726. $handler = new static($debug, $charset, $fileLinkFormat);
  55727. $prev = set_exception_handler(array($handler, 'handle'));
  55728. if (\is_array($prev) && $prev[0] instanceof ErrorHandler) {
  55729. restore_exception_handler();
  55730. $prev[0]->setExceptionHandler(array($handler, 'handle'));
  55731. }
  55732. return $handler;
  55733. }
  55734. public function setHandler($handler)
  55735. {
  55736. if (null !== $handler && !\is_callable($handler)) {
  55737. throw new \LogicException('The exception handler must be a valid PHP callable.');
  55738. }
  55739. $old = $this->handler;
  55740. $this->handler = $handler;
  55741. return $old;
  55742. }
  55743. public function setFileLinkFormat($format)
  55744. {
  55745. $old = $this->fileLinkFormat;
  55746. $this->fileLinkFormat = $format;
  55747. return $old;
  55748. }
  55749. public function handle(\Exception $exception)
  55750. {
  55751. if (null === $this->handler || $exception instanceof OutOfMemoryException) {
  55752. $this->failSafeHandle($exception);
  55753. return;
  55754. }
  55755. $caughtLength = $this->caughtLength = 0;
  55756. ob_start(array($this, 'catchOutput'));
  55757. $this->failSafeHandle($exception);
  55758. while (null === $this->caughtBuffer && ob_end_flush()) {
  55759. }
  55760. if (isset($this->caughtBuffer[0])) {
  55761. ob_start(array($this, 'cleanOutput'));
  55762. echo $this->caughtBuffer;
  55763. $caughtLength = ob_get_length();
  55764. }
  55765. $this->caughtBuffer = null;
  55766. try {
  55767. \call_user_func($this->handler, $exception);
  55768. $this->caughtLength = $caughtLength;
  55769. } catch (\Exception $e) {
  55770. if (!$caughtLength) {
  55771. throw $exception;
  55772. }
  55773. }
  55774. }
  55775. private function failSafeHandle(\Exception $exception)
  55776. {
  55777. if (class_exists('Symfony\Component\HttpFoundation\Response', false)
  55778. && __CLASS__ !== \get_class($this)
  55779. && ($reflector = new \ReflectionMethod($this, 'createResponse'))
  55780. && __CLASS__ !== $reflector->class
  55781. ) {
  55782. $response = $this->createResponse($exception);
  55783. $response->sendHeaders();
  55784. $response->sendContent();
  55785. @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);
  55786. return;
  55787. }
  55788. $this->sendPhpResponse($exception);
  55789. }
  55790. public function sendPhpResponse($exception)
  55791. {
  55792. if (!$exception instanceof FlattenException) {
  55793. $exception = FlattenException::create($exception);
  55794. }
  55795. if (!headers_sent()) {
  55796. header(sprintf('HTTP/1.0 %s', $exception->getStatusCode()));
  55797. foreach ($exception->getHeaders() as $name => $value) {
  55798. header($name.': '.$value, false);
  55799. }
  55800. header('Content-Type: text/html; charset='.$this->charset);
  55801. }
  55802. echo $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  55803. }
  55804. public function createResponse($exception)
  55805. {
  55806. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  55807. if (!$exception instanceof FlattenException) {
  55808. $exception = FlattenException::create($exception);
  55809. }
  55810. return Response::create($this->getHtml($exception), $exception->getStatusCode(), $exception->getHeaders())->setCharset($this->charset);
  55811. }
  55812. public function getHtml($exception)
  55813. {
  55814. if (!$exception instanceof FlattenException) {
  55815. $exception = FlattenException::create($exception);
  55816. }
  55817. return $this->decorate($this->getContent($exception), $this->getStylesheet($exception));
  55818. }
  55819. public function getContent(FlattenException $exception)
  55820. {
  55821. switch ($exception->getStatusCode()) {
  55822. case 404:
  55823. $title = 'Sorry, the page you are looking for could not be found.';
  55824. break;
  55825. default:
  55826. $title = 'Whoops, looks like something went wrong.';
  55827. }
  55828. $content = '';
  55829. if ($this->debug) {
  55830. try {
  55831. $count = \count($exception->getAllPrevious());
  55832. $total = $count + 1;
  55833. foreach ($exception->toArray() as $position => $e) {
  55834. $ind = $count - $position + 1;
  55835. $class = $this->formatClass($e['class']);
  55836. $message = nl2br($this->escapeHtml($e['message']));
  55837. $content .= sprintf(<<<'EOF'
  55838. <h2 class="block_exception clear_fix">
  55839. <span class="exception_counter">%d/%d</span>
  55840. <span class="exception_title">%s%s:</span>
  55841. <span class="exception_message">%s</span>
  55842. </h2>
  55843. <div class="block">
  55844. <ol class="traces list_exception">
  55845. EOF
  55846. , $ind, $total, $class, $this->formatPath($e['trace'][0]['file'], $e['trace'][0]['line']), $message);
  55847. foreach ($e['trace'] as $trace) {
  55848. $content .= ' <li>';
  55849. if ($trace['function']) {
  55850. $content .= sprintf('at %s%s%s(%s)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args']));
  55851. }
  55852. if (isset($trace['file']) && isset($trace['line'])) {
  55853. $content .= $this->formatPath($trace['file'], $trace['line']);
  55854. }
  55855. $content .= "</li>\n";
  55856. }
  55857. $content .= " </ol>\n</div>\n";
  55858. }
  55859. } catch (\Exception $e) {
  55860. if ($this->debug) {
  55861. $title = sprintf('Exception thrown when handling an exception (%s: %s)', \get_class($e), $this->escapeHtml($e->getMessage()));
  55862. } else {
  55863. $title = 'Whoops, looks like something went wrong.';
  55864. }
  55865. }
  55866. }
  55867. return <<<EOF
  55868. <div id="sf-resetcontent" class="sf-reset">
  55869. <h1>$title</h1>
  55870. $content
  55871. </div>
  55872. EOF;
  55873. }
  55874. public function getStylesheet(FlattenException $exception)
  55875. {
  55876. return <<<'EOF'
  55877. .sf-reset { font: 11px Verdana, Arial, sans-serif; color: #333 }
  55878. .sf-reset .clear { clear:both; height:0; font-size:0; line-height:0; }
  55879. .sf-reset .clear_fix:after { display:block; height:0; clear:both; visibility:hidden; }
  55880. .sf-reset .clear_fix { display:inline-block; }
  55881. .sf-reset * html .clear_fix { height:1%; }
  55882. .sf-reset .clear_fix { display:block; }
  55883. .sf-reset, .sf-reset .block { margin: auto }
  55884. .sf-reset abbr { border-bottom: 1px dotted #000; cursor: help; }
  55885. .sf-reset p { font-size:14px; line-height:20px; color:#868686; padding-bottom:20px }
  55886. .sf-reset strong { font-weight:bold; }
  55887. .sf-reset a { color:#6c6159; cursor: default; }
  55888. .sf-reset a img { border:none; }
  55889. .sf-reset a:hover { text-decoration:underline; }
  55890. .sf-reset em { font-style:italic; }
  55891. .sf-reset h1, .sf-reset h2 { font: 20px Georgia, "Times New Roman", Times, serif }
  55892. .sf-reset .exception_counter { background-color: #fff; color: #333; padding: 6px; float: left; margin-right: 10px; float: left; display: block; }
  55893. .sf-reset .exception_title { margin-left: 3em; margin-bottom: 0.7em; display: block; }
  55894. .sf-reset .exception_message { margin-left: 3em; display: block; }
  55895. .sf-reset .traces li { font-size:12px; padding: 2px 4px; list-style-type:decimal; margin-left:20px; }
  55896. .sf-reset .block { background-color:#FFFFFF; padding:10px 28px; margin-bottom:20px;
  55897. -webkit-border-bottom-right-radius: 16px;
  55898. -webkit-border-bottom-left-radius: 16px;
  55899. -moz-border-radius-bottomright: 16px;
  55900. -moz-border-radius-bottomleft: 16px;
  55901. border-bottom-right-radius: 16px;
  55902. border-bottom-left-radius: 16px;
  55903. border-bottom:1px solid #ccc;
  55904. border-right:1px solid #ccc;
  55905. border-left:1px solid #ccc;
  55906. word-wrap: break-word;
  55907. }
  55908. .sf-reset .block_exception { background-color:#ddd; color: #333; padding:20px;
  55909. -webkit-border-top-left-radius: 16px;
  55910. -webkit-border-top-right-radius: 16px;
  55911. -moz-border-radius-topleft: 16px;
  55912. -moz-border-radius-topright: 16px;
  55913. border-top-left-radius: 16px;
  55914. border-top-right-radius: 16px;
  55915. border-top:1px solid #ccc;
  55916. border-right:1px solid #ccc;
  55917. border-left:1px solid #ccc;
  55918. overflow: hidden;
  55919. word-wrap: break-word;
  55920. }
  55921. .sf-reset a { background:none; color:#868686; text-decoration:none; }
  55922. .sf-reset a:hover { background:none; color:#313131; text-decoration:underline; }
  55923. .sf-reset ol { padding: 10px 0; }
  55924. .sf-reset h1 { background-color:#FFFFFF; padding: 15px 28px; margin-bottom: 20px;
  55925. -webkit-border-radius: 10px;
  55926. -moz-border-radius: 10px;
  55927. border-radius: 10px;
  55928. border: 1px solid #ccc;
  55929. }
  55930. EOF;
  55931. }
  55932. private function decorate($content, $css)
  55933. {
  55934. return <<<EOF
  55935. <!DOCTYPE html>
  55936. <html>
  55937. <head>
  55938. <meta charset="{$this->charset}" />
  55939. <meta name="robots" content="noindex,nofollow" />
  55940. <style>
  55941. /* Copyright (c) 2010, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.com/yui/license.html */
  55942. 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;}
  55943. html { background: #eee; padding: 10px }
  55944. img { border: 0; }
  55945. #sf-resetcontent { width:970px; margin:0 auto; }
  55946. $css
  55947. </style>
  55948. </head>
  55949. <body>
  55950. $content
  55951. </body>
  55952. </html>
  55953. EOF;
  55954. }
  55955. private function formatClass($class)
  55956. {
  55957. $parts = explode('\\', $class);
  55958. return sprintf('<abbr title="%s">%s</abbr>', $class, array_pop($parts));
  55959. }
  55960. private function formatPath($path, $line)
  55961. {
  55962. $path = $this->escapeHtml($path);
  55963. $file = preg_match('#[^/\\\\]*$#', $path, $file) ? $file[0] : $path;
  55964. if ($linkFormat = $this->fileLinkFormat) {
  55965. $link = strtr($this->escapeHtml($linkFormat), array('%f' => $path, '%l' => (int) $line));
  55966. return sprintf(' in <a href="%s" title="Go to source">%s line %d</a>', $link, $file, $line);
  55967. }
  55968. 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);
  55969. }
  55970. private function formatArgs(array $args)
  55971. {
  55972. $result = array();
  55973. foreach ($args as $key => $item) {
  55974. if ('object' === $item[0]) {
  55975. $formattedValue = sprintf('<em>object</em>(%s)', $this->formatClass($item[1]));
  55976. } elseif ('array' === $item[0]) {
  55977. $formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
  55978. } elseif ('string' === $item[0]) {
  55979. $formattedValue = sprintf("'%s'", $this->escapeHtml($item[1]));
  55980. } elseif ('null' === $item[0]) {
  55981. $formattedValue = '<em>null</em>';
  55982. } elseif ('boolean' === $item[0]) {
  55983. $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
  55984. } elseif ('resource' === $item[0]) {
  55985. $formattedValue = '<em>resource</em>';
  55986. } else {
  55987. $formattedValue = str_replace("\n", '', var_export($this->escapeHtml((string) $item[1]), true));
  55988. }
  55989. $result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $this->escapeHtml($key), $formattedValue);
  55990. }
  55991. return implode(', ', $result);
  55992. }
  55993. protected static function utf8Htmlize($str)
  55994. {
  55995. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
  55996. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), 'UTF-8');
  55997. }
  55998. private function escapeHtml($str)
  55999. {
  56000. return htmlspecialchars($str, ENT_QUOTES | (\PHP_VERSION_ID >= 50400 ? ENT_SUBSTITUTE : 0), $this->charset);
  56001. }
  56002. public function catchOutput($buffer)
  56003. {
  56004. $this->caughtBuffer = $buffer;
  56005. return '';
  56006. }
  56007. public function cleanOutput($buffer)
  56008. {
  56009. if ($this->caughtLength) {
  56010. $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtLength);
  56011. if (isset($cleanBuffer[0])) {
  56012. $buffer = $cleanBuffer;
  56013. }
  56014. }
  56015. return $buffer;
  56016. }
  56017. }
  56018. <?php
  56019. namespace Symfony\Component\Debug\FatalErrorHandler;
  56020. use Composer\Autoload\ClassLoader as ComposerClassLoader;
  56021. use Symfony\Component\ClassLoader\ClassLoader as SymfonyClassLoader;
  56022. use Symfony\Component\ClassLoader\UniversalClassLoader as SymfonyUniversalClassLoader;
  56023. use Symfony\Component\Debug\DebugClassLoader;
  56024. use Symfony\Component\Debug\Exception\ClassNotFoundException;
  56025. use Symfony\Component\Debug\Exception\FatalErrorException;
  56026. class ClassNotFoundFatalErrorHandler implements FatalErrorHandlerInterface
  56027. {
  56028. public function handleError(array $error, FatalErrorException $exception)
  56029. {
  56030. $messageLen = \strlen($error['message']);
  56031. $notFoundSuffix = '\' not found';
  56032. $notFoundSuffixLen = \strlen($notFoundSuffix);
  56033. if ($notFoundSuffixLen > $messageLen) {
  56034. return;
  56035. }
  56036. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  56037. return;
  56038. }
  56039. foreach (array('class', 'interface', 'trait') as $typeName) {
  56040. $prefix = ucfirst($typeName).' \'';
  56041. $prefixLen = \strlen($prefix);
  56042. if (0 !== strpos($error['message'], $prefix)) {
  56043. continue;
  56044. }
  56045. $fullyQualifiedClassName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  56046. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedClassName, '\\')) {
  56047. $className = substr($fullyQualifiedClassName, $namespaceSeparatorIndex + 1);
  56048. $namespacePrefix = substr($fullyQualifiedClassName, 0, $namespaceSeparatorIndex);
  56049. $message = sprintf('Attempted to load %s "%s" from namespace "%s".', $typeName, $className, $namespacePrefix);
  56050. $tail = ' for another namespace?';
  56051. } else {
  56052. $className = $fullyQualifiedClassName;
  56053. $message = sprintf('Attempted to load %s "%s" from the global namespace.', $typeName, $className);
  56054. $tail = '?';
  56055. }
  56056. if ($candidates = $this->getClassCandidates($className)) {
  56057. $tail = array_pop($candidates).'"?';
  56058. if ($candidates) {
  56059. $tail = ' for e.g. "'.implode('", "', $candidates).'" or "'.$tail;
  56060. } else {
  56061. $tail = ' for "'.$tail;
  56062. }
  56063. }
  56064. $message .= "\nDid you forget a \"use\" statement".$tail;
  56065. return new ClassNotFoundException($message, $exception);
  56066. }
  56067. }
  56068. private function getClassCandidates($class)
  56069. {
  56070. if (!\is_array($functions = spl_autoload_functions())) {
  56071. return array();
  56072. }
  56073. $classes = array();
  56074. foreach ($functions as $function) {
  56075. if (!\is_array($function)) {
  56076. continue;
  56077. }
  56078. if ($function[0] instanceof DebugClassLoader) {
  56079. $function = $function[0]->getClassLoader();
  56080. if (\is_object($function)) {
  56081. $function = array($function);
  56082. }
  56083. if (!\is_array($function)) {
  56084. continue;
  56085. }
  56086. }
  56087. if ($function[0] instanceof ComposerClassLoader || $function[0] instanceof SymfonyClassLoader || $function[0] instanceof SymfonyUniversalClassLoader) {
  56088. foreach ($function[0]->getPrefixes() as $prefix => $paths) {
  56089. foreach ($paths as $path) {
  56090. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  56091. }
  56092. }
  56093. }
  56094. if ($function[0] instanceof ComposerClassLoader) {
  56095. foreach ($function[0]->getPrefixesPsr4() as $prefix => $paths) {
  56096. foreach ($paths as $path) {
  56097. $classes = array_merge($classes, $this->findClassInPath($path, $class, $prefix));
  56098. }
  56099. }
  56100. }
  56101. }
  56102. return array_unique($classes);
  56103. }
  56104. private function findClassInPath($path, $class, $prefix)
  56105. {
  56106. if (!$path = realpath($path.'/'.strtr($prefix, '\\_', '//')) ?: realpath($path.'/'.\dirname(strtr($prefix, '\\_', '//'))) ?: realpath($path)) {
  56107. return array();
  56108. }
  56109. $classes = array();
  56110. $filename = $class.'.php';
  56111. foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
  56112. if ($filename == $file->getFileName() && $class = $this->convertFileToClass($path, $file->getPathName(), $prefix)) {
  56113. $classes[] = $class;
  56114. }
  56115. }
  56116. return $classes;
  56117. }
  56118. private function convertFileToClass($path, $file, $prefix)
  56119. {
  56120. $candidates = array(
  56121. $namespacedClass = str_replace(array($path.\DIRECTORY_SEPARATOR, '.php', '/'), array('', '', '\\'), $file),
  56122. $prefix.$namespacedClass,
  56123. $prefix.'\\'.$namespacedClass,
  56124. str_replace('\\', '_', $namespacedClass),
  56125. str_replace('\\', '_', $prefix.$namespacedClass),
  56126. str_replace('\\', '_', $prefix.'\\'.$namespacedClass),
  56127. );
  56128. if ($prefix) {
  56129. $candidates = array_filter($candidates, function ($candidate) use ($prefix) { return 0 === strpos($candidate, $prefix); });
  56130. }
  56131. foreach ($candidates as $candidate) {
  56132. if ($this->classExists($candidate)) {
  56133. return $candidate;
  56134. }
  56135. }
  56136. require_once $file;
  56137. foreach ($candidates as $candidate) {
  56138. if ($this->classExists($candidate)) {
  56139. return $candidate;
  56140. }
  56141. }
  56142. }
  56143. private function classExists($class)
  56144. {
  56145. return class_exists($class, false) || interface_exists($class, false) || (\function_exists('trait_exists') && trait_exists($class, false));
  56146. }
  56147. }
  56148. <?php
  56149. namespace Symfony\Component\Debug\FatalErrorHandler;
  56150. use Symfony\Component\Debug\Exception\FatalErrorException;
  56151. interface FatalErrorHandlerInterface
  56152. {
  56153. public function handleError(array $error, FatalErrorException $exception);
  56154. }
  56155. <?php
  56156. namespace Symfony\Component\Debug\FatalErrorHandler;
  56157. use Symfony\Component\Debug\Exception\FatalErrorException;
  56158. use Symfony\Component\Debug\Exception\UndefinedFunctionException;
  56159. class UndefinedFunctionFatalErrorHandler implements FatalErrorHandlerInterface
  56160. {
  56161. public function handleError(array $error, FatalErrorException $exception)
  56162. {
  56163. $messageLen = \strlen($error['message']);
  56164. $notFoundSuffix = '()';
  56165. $notFoundSuffixLen = \strlen($notFoundSuffix);
  56166. if ($notFoundSuffixLen > $messageLen) {
  56167. return;
  56168. }
  56169. if (0 !== substr_compare($error['message'], $notFoundSuffix, -$notFoundSuffixLen)) {
  56170. return;
  56171. }
  56172. $prefix = 'Call to undefined function ';
  56173. $prefixLen = \strlen($prefix);
  56174. if (0 !== strpos($error['message'], $prefix)) {
  56175. return;
  56176. }
  56177. $fullyQualifiedFunctionName = substr($error['message'], $prefixLen, -$notFoundSuffixLen);
  56178. if (false !== $namespaceSeparatorIndex = strrpos($fullyQualifiedFunctionName, '\\')) {
  56179. $functionName = substr($fullyQualifiedFunctionName, $namespaceSeparatorIndex + 1);
  56180. $namespacePrefix = substr($fullyQualifiedFunctionName, 0, $namespaceSeparatorIndex);
  56181. $message = sprintf('Attempted to call function "%s" from namespace "%s".', $functionName, $namespacePrefix);
  56182. } else {
  56183. $functionName = $fullyQualifiedFunctionName;
  56184. $message = sprintf('Attempted to call function "%s" from the global namespace.', $functionName);
  56185. }
  56186. $candidates = array();
  56187. foreach (get_defined_functions() as $type => $definedFunctionNames) {
  56188. foreach ($definedFunctionNames as $definedFunctionName) {
  56189. if (false !== $namespaceSeparatorIndex = strrpos($definedFunctionName, '\\')) {
  56190. $definedFunctionNameBasename = substr($definedFunctionName, $namespaceSeparatorIndex + 1);
  56191. } else {
  56192. $definedFunctionNameBasename = $definedFunctionName;
  56193. }
  56194. if ($definedFunctionNameBasename === $functionName) {
  56195. $candidates[] = '\\'.$definedFunctionName;
  56196. }
  56197. }
  56198. }
  56199. if ($candidates) {
  56200. sort($candidates);
  56201. $last = array_pop($candidates).'"?';
  56202. if ($candidates) {
  56203. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  56204. } else {
  56205. $candidates = '"'.$last;
  56206. }
  56207. $message .= "\nDid you mean to call ".$candidates;
  56208. }
  56209. return new UndefinedFunctionException($message, $exception);
  56210. }
  56211. }
  56212. <?php
  56213. namespace Symfony\Component\Debug\FatalErrorHandler;
  56214. use Symfony\Component\Debug\Exception\FatalErrorException;
  56215. use Symfony\Component\Debug\Exception\UndefinedMethodException;
  56216. class UndefinedMethodFatalErrorHandler implements FatalErrorHandlerInterface
  56217. {
  56218. public function handleError(array $error, FatalErrorException $exception)
  56219. {
  56220. preg_match('/^Call to undefined method (.*)::(.*)\(\)$/', $error['message'], $matches);
  56221. if (!$matches) {
  56222. return;
  56223. }
  56224. $className = $matches[1];
  56225. $methodName = $matches[2];
  56226. $message = sprintf('Attempted to call an undefined method named "%s" of class "%s".', $methodName, $className);
  56227. if (!class_exists($className) || null === $methods = get_class_methods($className)) {
  56228. return new UndefinedMethodException($message, $exception);
  56229. }
  56230. $candidates = array();
  56231. foreach ($methods as $definedMethodName) {
  56232. $lev = levenshtein($methodName, $definedMethodName);
  56233. if ($lev <= \strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) {
  56234. $candidates[] = $definedMethodName;
  56235. }
  56236. }
  56237. if ($candidates) {
  56238. sort($candidates);
  56239. $last = array_pop($candidates).'"?';
  56240. if ($candidates) {
  56241. $candidates = 'e.g. "'.implode('", "', $candidates).'" or "'.$last;
  56242. } else {
  56243. $candidates = '"'.$last;
  56244. }
  56245. $message .= "\nDid you mean to call ".$candidates;
  56246. }
  56247. return new UndefinedMethodException($message, $exception);
  56248. }
  56249. }
  56250. Copyright (c) 2004-2018 Fabien Potencier
  56251. Permission is hereby granted, free of charge, to any person obtaining a copy
  56252. of this software and associated documentation files (the "Software"), to deal
  56253. in the Software without restriction, including without limitation the rights
  56254. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  56255. copies of the Software, and to permit persons to whom the Software is furnished
  56256. to do so, subject to the following conditions:
  56257. The above copyright notice and this permission notice shall be included in all
  56258. copies or substantial portions of the Software.
  56259. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56260. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  56261. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  56262. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  56263. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  56264. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  56265. THE SOFTWARE.
  56266. <?php
  56267. namespace Symfony\Component\Filesystem\Exception;
  56268. interface ExceptionInterface
  56269. {
  56270. }
  56271. <?php
  56272. namespace Symfony\Component\Filesystem\Exception;
  56273. class FileNotFoundException extends IOException
  56274. {
  56275. public function __construct($message = null, $code = 0, \Exception $previous = null, $path = null)
  56276. {
  56277. if (null === $message) {
  56278. if (null === $path) {
  56279. $message = 'File could not be found.';
  56280. } else {
  56281. $message = sprintf('File "%s" could not be found.', $path);
  56282. }
  56283. }
  56284. parent::__construct($message, $code, $previous, $path);
  56285. }
  56286. }
  56287. <?php
  56288. namespace Symfony\Component\Filesystem\Exception;
  56289. class IOException extends \RuntimeException implements IOExceptionInterface
  56290. {
  56291. private $path;
  56292. public function __construct($message, $code = 0, \Exception $previous = null, $path = null)
  56293. {
  56294. $this->path = $path;
  56295. parent::__construct($message, $code, $previous);
  56296. }
  56297. public function getPath()
  56298. {
  56299. return $this->path;
  56300. }
  56301. }
  56302. <?php
  56303. namespace Symfony\Component\Filesystem\Exception;
  56304. interface IOExceptionInterface extends ExceptionInterface
  56305. {
  56306. public function getPath();
  56307. }
  56308. <?php
  56309. namespace Symfony\Component\Filesystem;
  56310. use Symfony\Component\Filesystem\Exception\FileNotFoundException;
  56311. use Symfony\Component\Filesystem\Exception\IOException;
  56312. class Filesystem
  56313. {
  56314. private static $lastError;
  56315. public function copy($originFile, $targetFile, $overwriteNewerFiles = false)
  56316. {
  56317. $originIsLocal = stream_is_local($originFile) || 0 === stripos($originFile, 'file://');
  56318. if ($originIsLocal && !is_file($originFile)) {
  56319. throw new FileNotFoundException(sprintf('Failed to copy "%s" because file does not exist.', $originFile), 0, null, $originFile);
  56320. }
  56321. $this->mkdir(\dirname($targetFile));
  56322. $doCopy = true;
  56323. if (!$overwriteNewerFiles && null === parse_url($originFile, PHP_URL_HOST) && is_file($targetFile)) {
  56324. $doCopy = filemtime($originFile) > filemtime($targetFile);
  56325. }
  56326. if ($doCopy) {
  56327. if (false === $source = @fopen($originFile, 'r')) {
  56328. throw new IOException(sprintf('Failed to copy "%s" to "%s" because source file could not be opened for reading.', $originFile, $targetFile), 0, null, $originFile);
  56329. }
  56330. if (false === $target = @fopen($targetFile, 'w', null, stream_context_create(array('ftp' => array('overwrite' => true))))) {
  56331. throw new IOException(sprintf('Failed to copy "%s" to "%s" because target file could not be opened for writing.', $originFile, $targetFile), 0, null, $originFile);
  56332. }
  56333. $bytesCopied = stream_copy_to_stream($source, $target);
  56334. fclose($source);
  56335. fclose($target);
  56336. unset($source, $target);
  56337. if (!is_file($targetFile)) {
  56338. throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
  56339. }
  56340. if ($originIsLocal) {
  56341. @chmod($targetFile, fileperms($targetFile) | (fileperms($originFile) & 0111));
  56342. if ($bytesCopied !== $bytesOrigin = filesize($originFile)) {
  56343. 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);
  56344. }
  56345. }
  56346. }
  56347. }
  56348. public function mkdir($dirs, $mode = 0777)
  56349. {
  56350. foreach ($this->toIterator($dirs) as $dir) {
  56351. if (is_dir($dir)) {
  56352. continue;
  56353. }
  56354. if (!self::box('mkdir', $dir, $mode, true)) {
  56355. if (!is_dir($dir)) {
  56356. if (self::$lastError) {
  56357. throw new IOException(sprintf('Failed to create "%s": %s.', $dir, self::$lastError), 0, null, $dir);
  56358. }
  56359. throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir);
  56360. }
  56361. }
  56362. }
  56363. }
  56364. public function exists($files)
  56365. {
  56366. $maxPathLength = PHP_MAXPATHLEN - 2;
  56367. foreach ($this->toIterator($files) as $file) {
  56368. if (\strlen($file) > $maxPathLength) {
  56369. throw new IOException(sprintf('Could not check if file exist because path length exceeds %d characters.', $maxPathLength), 0, null, $file);
  56370. }
  56371. if (!file_exists($file)) {
  56372. return false;
  56373. }
  56374. }
  56375. return true;
  56376. }
  56377. public function touch($files, $time = null, $atime = null)
  56378. {
  56379. foreach ($this->toIterator($files) as $file) {
  56380. $touch = $time ? @touch($file, $time, $atime) : @touch($file);
  56381. if (true !== $touch) {
  56382. throw new IOException(sprintf('Failed to touch "%s".', $file), 0, null, $file);
  56383. }
  56384. }
  56385. }
  56386. public function remove($files)
  56387. {
  56388. if ($files instanceof \Traversable) {
  56389. $files = iterator_to_array($files, false);
  56390. } elseif (!\is_array($files)) {
  56391. $files = array($files);
  56392. }
  56393. $files = array_reverse($files);
  56394. foreach ($files as $file) {
  56395. if (is_link($file)) {
  56396. if (!(self::box('unlink', $file) || '\\' !== \DIRECTORY_SEPARATOR || self::box('rmdir', $file)) && file_exists($file)) {
  56397. throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, self::$lastError));
  56398. }
  56399. } elseif (is_dir($file)) {
  56400. $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS));
  56401. if (!self::box('rmdir', $file) && file_exists($file)) {
  56402. throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, self::$lastError));
  56403. }
  56404. } elseif (!self::box('unlink', $file) && file_exists($file)) {
  56405. throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, self::$lastError));
  56406. }
  56407. }
  56408. }
  56409. public function chmod($files, $mode, $umask = 0000, $recursive = false)
  56410. {
  56411. foreach ($this->toIterator($files) as $file) {
  56412. if (true !== @chmod($file, $mode & ~$umask)) {
  56413. throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
  56414. }
  56415. if ($recursive && is_dir($file) && !is_link($file)) {
  56416. $this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
  56417. }
  56418. }
  56419. }
  56420. public function chown($files, $user, $recursive = false)
  56421. {
  56422. foreach ($this->toIterator($files) as $file) {
  56423. if ($recursive && is_dir($file) && !is_link($file)) {
  56424. $this->chown(new \FilesystemIterator($file), $user, true);
  56425. }
  56426. if (is_link($file) && \function_exists('lchown')) {
  56427. if (true !== @lchown($file, $user)) {
  56428. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  56429. }
  56430. } else {
  56431. if (true !== @chown($file, $user)) {
  56432. throw new IOException(sprintf('Failed to chown file "%s".', $file), 0, null, $file);
  56433. }
  56434. }
  56435. }
  56436. }
  56437. public function chgrp($files, $group, $recursive = false)
  56438. {
  56439. foreach ($this->toIterator($files) as $file) {
  56440. if ($recursive && is_dir($file) && !is_link($file)) {
  56441. $this->chgrp(new \FilesystemIterator($file), $group, true);
  56442. }
  56443. if (is_link($file) && \function_exists('lchgrp')) {
  56444. if (true !== @lchgrp($file, $group) || (\defined('HHVM_VERSION') && !posix_getgrnam($group))) {
  56445. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  56446. }
  56447. } else {
  56448. if (true !== @chgrp($file, $group)) {
  56449. throw new IOException(sprintf('Failed to chgrp file "%s".', $file), 0, null, $file);
  56450. }
  56451. }
  56452. }
  56453. }
  56454. public function rename($origin, $target, $overwrite = false)
  56455. {
  56456. if (!$overwrite && $this->isReadable($target)) {
  56457. throw new IOException(sprintf('Cannot rename because the target "%s" already exists.', $target), 0, null, $target);
  56458. }
  56459. if (true !== @rename($origin, $target)) {
  56460. if (is_dir($origin)) {
  56461. $this->mirror($origin, $target, null, array('override' => $overwrite, 'delete' => $overwrite));
  56462. $this->remove($origin);
  56463. return;
  56464. }
  56465. throw new IOException(sprintf('Cannot rename "%s" to "%s".', $origin, $target), 0, null, $target);
  56466. }
  56467. }
  56468. private function isReadable($filename)
  56469. {
  56470. $maxPathLength = PHP_MAXPATHLEN - 2;
  56471. if (\strlen($filename) > $maxPathLength) {
  56472. throw new IOException(sprintf('Could not check if file is readable because path length exceeds %d characters.', $maxPathLength), 0, null, $filename);
  56473. }
  56474. return is_readable($filename);
  56475. }
  56476. public function symlink($originDir, $targetDir, $copyOnWindows = false)
  56477. {
  56478. if ('\\' === \DIRECTORY_SEPARATOR) {
  56479. $originDir = strtr($originDir, '/', '\\');
  56480. $targetDir = strtr($targetDir, '/', '\\');
  56481. if ($copyOnWindows) {
  56482. $this->mirror($originDir, $targetDir);
  56483. return;
  56484. }
  56485. }
  56486. $this->mkdir(\dirname($targetDir));
  56487. if (is_link($targetDir)) {
  56488. if (readlink($targetDir) === $originDir) {
  56489. return;
  56490. }
  56491. $this->remove($targetDir);
  56492. }
  56493. if (!self::box('symlink', $originDir, $targetDir)) {
  56494. if (null !== self::$lastError) {
  56495. if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) {
  56496. 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);
  56497. }
  56498. }
  56499. throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir);
  56500. }
  56501. }
  56502. public function makePathRelative($endPath, $startPath)
  56503. {
  56504. if ('\\' === \DIRECTORY_SEPARATOR) {
  56505. $endPath = str_replace('\\', '/', $endPath);
  56506. $startPath = str_replace('\\', '/', $startPath);
  56507. }
  56508. $stripDriveLetter = function ($path) {
  56509. if (\strlen($path) > 2 && ':' === $path[1] && '/' === $path[2] && ctype_alpha($path[0])) {
  56510. return substr($path, 2);
  56511. }
  56512. return $path;
  56513. };
  56514. $endPath = $stripDriveLetter($endPath);
  56515. $startPath = $stripDriveLetter($startPath);
  56516. $startPathArr = explode('/', trim($startPath, '/'));
  56517. $endPathArr = explode('/', trim($endPath, '/'));
  56518. $normalizePathArray = function ($pathSegments, $absolute) {
  56519. $result = array();
  56520. foreach ($pathSegments as $segment) {
  56521. if ('..' === $segment && ($absolute || \count($result))) {
  56522. array_pop($result);
  56523. } elseif ('.' !== $segment) {
  56524. $result[] = $segment;
  56525. }
  56526. }
  56527. return $result;
  56528. };
  56529. $startPathArr = $normalizePathArray($startPathArr, static::isAbsolutePath($startPath));
  56530. $endPathArr = $normalizePathArray($endPathArr, static::isAbsolutePath($endPath));
  56531. $index = 0;
  56532. while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) {
  56533. ++$index;
  56534. }
  56535. if (1 === \count($startPathArr) && '' === $startPathArr[0]) {
  56536. $depth = 0;
  56537. } else {
  56538. $depth = \count($startPathArr) - $index;
  56539. }
  56540. $traverser = str_repeat('../', $depth);
  56541. $endPathRemainder = implode('/', \array_slice($endPathArr, $index));
  56542. $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : '');
  56543. return '' === $relativePath ? './' : $relativePath;
  56544. }
  56545. public function mirror($originDir, $targetDir, \Traversable $iterator = null, $options = array())
  56546. {
  56547. $targetDir = rtrim($targetDir, '/\\');
  56548. $originDir = rtrim($originDir, '/\\');
  56549. $originDirLen = \strlen($originDir);
  56550. if ($this->exists($targetDir) && isset($options['delete']) && $options['delete']) {
  56551. $deleteIterator = $iterator;
  56552. if (null === $deleteIterator) {
  56553. $flags = \FilesystemIterator::SKIP_DOTS;
  56554. $deleteIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($targetDir, $flags), \RecursiveIteratorIterator::CHILD_FIRST);
  56555. }
  56556. $targetDirLen = \strlen($targetDir);
  56557. foreach ($deleteIterator as $file) {
  56558. $origin = $originDir.substr($file->getPathname(), $targetDirLen);
  56559. if (!$this->exists($origin)) {
  56560. $this->remove($file);
  56561. }
  56562. }
  56563. }
  56564. $copyOnWindows = false;
  56565. if (isset($options['copy_on_windows'])) {
  56566. $copyOnWindows = $options['copy_on_windows'];
  56567. }
  56568. if (null === $iterator) {
  56569. $flags = $copyOnWindows ? \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::FOLLOW_SYMLINKS : \FilesystemIterator::SKIP_DOTS;
  56570. $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($originDir, $flags), \RecursiveIteratorIterator::SELF_FIRST);
  56571. }
  56572. if ($this->exists($originDir)) {
  56573. $this->mkdir($targetDir);
  56574. }
  56575. foreach ($iterator as $file) {
  56576. $target = $targetDir.substr($file->getPathname(), $originDirLen);
  56577. if ($copyOnWindows) {
  56578. if (is_file($file)) {
  56579. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  56580. } elseif (is_dir($file)) {
  56581. $this->mkdir($target);
  56582. } else {
  56583. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  56584. }
  56585. } else {
  56586. if (is_link($file)) {
  56587. $this->symlink($file->getLinkTarget(), $target);
  56588. } elseif (is_dir($file)) {
  56589. $this->mkdir($target);
  56590. } elseif (is_file($file)) {
  56591. $this->copy($file, $target, isset($options['override']) ? $options['override'] : false);
  56592. } else {
  56593. throw new IOException(sprintf('Unable to guess "%s" file type.', $file), 0, null, $file);
  56594. }
  56595. }
  56596. }
  56597. }
  56598. public function isAbsolutePath($file)
  56599. {
  56600. return strspn($file, '/\\', 0, 1)
  56601. || (\strlen($file) > 3 && ctype_alpha($file[0])
  56602. && ':' === substr($file, 1, 1)
  56603. && strspn($file, '/\\', 2, 1)
  56604. )
  56605. || null !== parse_url($file, PHP_URL_SCHEME)
  56606. ;
  56607. }
  56608. public function tempnam($dir, $prefix)
  56609. {
  56610. list($scheme, $hierarchy) = $this->getSchemeAndHierarchy($dir);
  56611. if (null === $scheme || 'file' === $scheme || 'gs' === $scheme) {
  56612. $tmpFile = @tempnam($hierarchy, $prefix);
  56613. if (false !== $tmpFile) {
  56614. if (null !== $scheme && 'gs' !== $scheme) {
  56615. return $scheme.'://'.$tmpFile;
  56616. }
  56617. return $tmpFile;
  56618. }
  56619. throw new IOException('A temporary file could not be created.');
  56620. }
  56621. for ($i = 0; $i < 10; ++$i) {
  56622. $tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true);
  56623. $handle = @fopen($tmpFile, 'x+');
  56624. if (false === $handle) {
  56625. continue;
  56626. }
  56627. @fclose($handle);
  56628. return $tmpFile;
  56629. }
  56630. throw new IOException('A temporary file could not be created.');
  56631. }
  56632. public function dumpFile($filename, $content, $mode = 0666)
  56633. {
  56634. $dir = \dirname($filename);
  56635. if (!is_dir($dir)) {
  56636. $this->mkdir($dir);
  56637. }
  56638. if (!is_writable($dir)) {
  56639. throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir);
  56640. }
  56641. $tmpFile = $this->tempnam($dir, basename($filename));
  56642. if (false === @file_put_contents($tmpFile, $content)) {
  56643. throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename);
  56644. }
  56645. if (null !== $mode) {
  56646. if (\func_num_args() > 2) {
  56647. @trigger_error('Support for modifying file permissions is deprecated since Symfony 2.3.12 and will be removed in 3.0.', E_USER_DEPRECATED);
  56648. }
  56649. $this->chmod($tmpFile, $mode);
  56650. } elseif (file_exists($filename)) {
  56651. @chmod($tmpFile, fileperms($filename));
  56652. }
  56653. $this->rename($tmpFile, $filename, true);
  56654. }
  56655. private function toIterator($files)
  56656. {
  56657. if (!$files instanceof \Traversable) {
  56658. $files = new \ArrayObject(\is_array($files) ? $files : array($files));
  56659. }
  56660. return $files;
  56661. }
  56662. private function getSchemeAndHierarchy($filename)
  56663. {
  56664. $components = explode('://', $filename, 2);
  56665. return 2 === \count($components) ? array($components[0], $components[1]) : array(null, $components[0]);
  56666. }
  56667. private static function box($func)
  56668. {
  56669. self::$lastError = null;
  56670. \set_error_handler(__CLASS__.'::handleError');
  56671. try {
  56672. $result = \call_user_func_array($func, \array_slice(\func_get_args(), 1));
  56673. \restore_error_handler();
  56674. return $result;
  56675. } catch (\Throwable $e) {
  56676. } catch (\Exception $e) {
  56677. }
  56678. \restore_error_handler();
  56679. throw $e;
  56680. }
  56681. public static function handleError($type, $msg)
  56682. {
  56683. self::$lastError = $msg;
  56684. }
  56685. }
  56686. Copyright (c) 2004-2018 Fabien Potencier
  56687. Permission is hereby granted, free of charge, to any person obtaining a copy
  56688. of this software and associated documentation files (the "Software"), to deal
  56689. in the Software without restriction, including without limitation the rights
  56690. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  56691. copies of the Software, and to permit persons to whom the Software is furnished
  56692. to do so, subject to the following conditions:
  56693. The above copyright notice and this permission notice shall be included in all
  56694. copies or substantial portions of the Software.
  56695. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56696. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  56697. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  56698. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  56699. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  56700. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  56701. THE SOFTWARE.
  56702. <?php
  56703. namespace Symfony\Component\Filesystem;
  56704. use Symfony\Component\Filesystem\Exception\IOException;
  56705. class LockHandler
  56706. {
  56707. private $file;
  56708. private $handle;
  56709. public function __construct($name, $lockPath = null)
  56710. {
  56711. $lockPath = $lockPath ?: sys_get_temp_dir();
  56712. if (!is_dir($lockPath)) {
  56713. $fs = new Filesystem();
  56714. $fs->mkdir($lockPath);
  56715. }
  56716. if (!is_writable($lockPath)) {
  56717. throw new IOException(sprintf('The directory "%s" is not writable.', $lockPath), 0, null, $lockPath);
  56718. }
  56719. $this->file = sprintf('%s/sf.%s.%s.lock', $lockPath, preg_replace('/[^a-z0-9\._-]+/i', '-', $name), hash('sha256', $name));
  56720. }
  56721. public function lock($blocking = false)
  56722. {
  56723. if ($this->handle) {
  56724. return true;
  56725. }
  56726. $error = null;
  56727. set_error_handler(function ($errno, $msg) use (&$error) {
  56728. $error = $msg;
  56729. });
  56730. if (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  56731. if ($this->handle = fopen($this->file, 'x')) {
  56732. chmod($this->file, 0666);
  56733. } elseif (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
  56734. usleep(100);
  56735. $this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r');
  56736. }
  56737. }
  56738. restore_error_handler();
  56739. if (!$this->handle) {
  56740. throw new IOException($error, 0, null, $this->file);
  56741. }
  56742. if (!flock($this->handle, LOCK_EX | ($blocking ? 0 : LOCK_NB))) {
  56743. fclose($this->handle);
  56744. $this->handle = null;
  56745. return false;
  56746. }
  56747. return true;
  56748. }
  56749. public function release()
  56750. {
  56751. if ($this->handle) {
  56752. flock($this->handle, LOCK_UN | LOCK_NB);
  56753. fclose($this->handle);
  56754. $this->handle = null;
  56755. }
  56756. }
  56757. }
  56758. <?php
  56759. namespace Symfony\Component\Finder\Adapter;
  56760. @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);
  56761. abstract class AbstractAdapter implements AdapterInterface
  56762. {
  56763. protected $followLinks = false;
  56764. protected $mode = 0;
  56765. protected $minDepth = 0;
  56766. protected $maxDepth = PHP_INT_MAX;
  56767. protected $exclude = array();
  56768. protected $names = array();
  56769. protected $notNames = array();
  56770. protected $contains = array();
  56771. protected $notContains = array();
  56772. protected $sizes = array();
  56773. protected $dates = array();
  56774. protected $filters = array();
  56775. protected $sort = false;
  56776. protected $paths = array();
  56777. protected $notPaths = array();
  56778. protected $ignoreUnreadableDirs = false;
  56779. private static $areSupported = array();
  56780. public function isSupported()
  56781. {
  56782. $name = $this->getName();
  56783. if (!array_key_exists($name, self::$areSupported)) {
  56784. self::$areSupported[$name] = $this->canBeUsed();
  56785. }
  56786. return self::$areSupported[$name];
  56787. }
  56788. public function setFollowLinks($followLinks)
  56789. {
  56790. $this->followLinks = $followLinks;
  56791. return $this;
  56792. }
  56793. public function setMode($mode)
  56794. {
  56795. $this->mode = $mode;
  56796. return $this;
  56797. }
  56798. public function setDepths(array $depths)
  56799. {
  56800. $this->minDepth = 0;
  56801. $this->maxDepth = PHP_INT_MAX;
  56802. foreach ($depths as $comparator) {
  56803. switch ($comparator->getOperator()) {
  56804. case '>':
  56805. $this->minDepth = $comparator->getTarget() + 1;
  56806. break;
  56807. case '>=':
  56808. $this->minDepth = $comparator->getTarget();
  56809. break;
  56810. case '<':
  56811. $this->maxDepth = $comparator->getTarget() - 1;
  56812. break;
  56813. case '<=':
  56814. $this->maxDepth = $comparator->getTarget();
  56815. break;
  56816. default:
  56817. $this->minDepth = $this->maxDepth = $comparator->getTarget();
  56818. }
  56819. }
  56820. return $this;
  56821. }
  56822. public function setExclude(array $exclude)
  56823. {
  56824. $this->exclude = $exclude;
  56825. return $this;
  56826. }
  56827. public function setNames(array $names)
  56828. {
  56829. $this->names = $names;
  56830. return $this;
  56831. }
  56832. public function setNotNames(array $notNames)
  56833. {
  56834. $this->notNames = $notNames;
  56835. return $this;
  56836. }
  56837. public function setContains(array $contains)
  56838. {
  56839. $this->contains = $contains;
  56840. return $this;
  56841. }
  56842. public function setNotContains(array $notContains)
  56843. {
  56844. $this->notContains = $notContains;
  56845. return $this;
  56846. }
  56847. public function setSizes(array $sizes)
  56848. {
  56849. $this->sizes = $sizes;
  56850. return $this;
  56851. }
  56852. public function setDates(array $dates)
  56853. {
  56854. $this->dates = $dates;
  56855. return $this;
  56856. }
  56857. public function setFilters(array $filters)
  56858. {
  56859. $this->filters = $filters;
  56860. return $this;
  56861. }
  56862. public function setSort($sort)
  56863. {
  56864. $this->sort = $sort;
  56865. return $this;
  56866. }
  56867. public function setPath(array $paths)
  56868. {
  56869. $this->paths = $paths;
  56870. return $this;
  56871. }
  56872. public function setNotPath(array $notPaths)
  56873. {
  56874. $this->notPaths = $notPaths;
  56875. return $this;
  56876. }
  56877. public function ignoreUnreadableDirs($ignore = true)
  56878. {
  56879. $this->ignoreUnreadableDirs = (bool) $ignore;
  56880. return $this;
  56881. }
  56882. abstract protected function canBeUsed();
  56883. }
  56884. <?php
  56885. namespace Symfony\Component\Finder\Adapter;
  56886. @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);
  56887. use Symfony\Component\Finder\Comparator\DateComparator;
  56888. use Symfony\Component\Finder\Comparator\NumberComparator;
  56889. use Symfony\Component\Finder\Exception\AccessDeniedException;
  56890. use Symfony\Component\Finder\Expression\Expression;
  56891. use Symfony\Component\Finder\Iterator;
  56892. use Symfony\Component\Finder\Shell\Command;
  56893. use Symfony\Component\Finder\Shell\Shell;
  56894. abstract class AbstractFindAdapter extends AbstractAdapter
  56895. {
  56896. protected $shell;
  56897. public function __construct()
  56898. {
  56899. $this->shell = new Shell();
  56900. }
  56901. public function searchInDirectory($dir)
  56902. {
  56903. $dir = realpath($dir);
  56904. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode && ($this->contains || $this->notContains)) {
  56905. return new Iterator\FilePathsIterator(array(), $dir);
  56906. }
  56907. $command = Command::create();
  56908. $find = $this->buildFindCommand($command, $dir);
  56909. if ($this->followLinks) {
  56910. $find->add('-follow');
  56911. }
  56912. $find->add('-mindepth')->add($this->minDepth + 1);
  56913. if (PHP_INT_MAX !== $this->maxDepth) {
  56914. $find->add('-maxdepth')->add($this->maxDepth + 1);
  56915. }
  56916. if (Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES === $this->mode) {
  56917. $find->add('-type d');
  56918. } elseif (Iterator\FileTypeFilterIterator::ONLY_FILES === $this->mode) {
  56919. $find->add('-type f');
  56920. }
  56921. $this->buildNamesFiltering($find, $this->names);
  56922. $this->buildNamesFiltering($find, $this->notNames, true);
  56923. $this->buildPathsFiltering($find, $dir, $this->paths);
  56924. $this->buildPathsFiltering($find, $dir, $this->notPaths, true);
  56925. $this->buildSizesFiltering($find, $this->sizes);
  56926. $this->buildDatesFiltering($find, $this->dates);
  56927. $useGrep = $this->shell->testCommand('grep') && $this->shell->testCommand('xargs');
  56928. $useSort = \is_int($this->sort) && $this->shell->testCommand('sort') && $this->shell->testCommand('cut');
  56929. if ($useGrep && ($this->contains || $this->notContains)) {
  56930. $grep = $command->ins('grep');
  56931. $this->buildContentFiltering($grep, $this->contains);
  56932. $this->buildContentFiltering($grep, $this->notContains, true);
  56933. }
  56934. if ($useSort) {
  56935. $this->buildSorting($command, $this->sort);
  56936. }
  56937. $command->setErrorHandler(
  56938. $this->ignoreUnreadableDirs
  56939. ? function ($stderr) { }
  56940. : function ($stderr) { throw new AccessDeniedException($stderr); }
  56941. );
  56942. $paths = $this->shell->testCommand('uniq') ? $command->add('| uniq')->execute() : array_unique($command->execute());
  56943. $iterator = new Iterator\FilePathsIterator($paths, $dir);
  56944. if ($this->exclude) {
  56945. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  56946. }
  56947. if (!$useGrep && ($this->contains || $this->notContains)) {
  56948. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  56949. }
  56950. if ($this->filters) {
  56951. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  56952. }
  56953. if (!$useSort && $this->sort) {
  56954. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  56955. $iterator = $iteratorAggregate->getIterator();
  56956. }
  56957. return $iterator;
  56958. }
  56959. protected function canBeUsed()
  56960. {
  56961. return $this->shell->testCommand('find');
  56962. }
  56963. protected function buildFindCommand(Command $command, $dir)
  56964. {
  56965. return $command
  56966. ->ins('find')
  56967. ->add('find ')
  56968. ->arg($dir)
  56969. ->add('-noleaf');
  56970. }
  56971. private function buildNamesFiltering(Command $command, array $names, $not = false)
  56972. {
  56973. if (0 === \count($names)) {
  56974. return;
  56975. }
  56976. $command->add($not ? '-not' : null)->cmd('(');
  56977. foreach ($names as $i => $name) {
  56978. $expr = Expression::create($name);
  56979. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  56980. $expr = Expression::create($expr->getGlob()->toRegex(false));
  56981. }
  56982. if ($expr->isRegex()) {
  56983. $regex = $expr->getRegex();
  56984. $regex->prepend($regex->hasStartFlag() ? '/' : '/[^/]*')
  56985. ->setStartFlag(false)
  56986. ->setStartJoker(true)
  56987. ->replaceJokers('[^/]');
  56988. if (!$regex->hasEndFlag() || $regex->hasEndJoker()) {
  56989. $regex->setEndJoker(false)->append('[^/]*');
  56990. }
  56991. }
  56992. $command
  56993. ->add($i > 0 ? '-or' : null)
  56994. ->add($expr->isRegex()
  56995. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  56996. : ($expr->isCaseSensitive() ? '-name' : '-iname')
  56997. )
  56998. ->arg($expr->renderPattern());
  56999. }
  57000. $command->cmd(')');
  57001. }
  57002. private function buildPathsFiltering(Command $command, $dir, array $paths, $not = false)
  57003. {
  57004. if (0 === \count($paths)) {
  57005. return;
  57006. }
  57007. $command->add($not ? '-not' : null)->cmd('(');
  57008. foreach ($paths as $i => $path) {
  57009. $expr = Expression::create($path);
  57010. if ($expr->isGlob() && $expr->getGlob()->isExpandable()) {
  57011. $expr = Expression::create($expr->getGlob()->toRegex(false));
  57012. }
  57013. if ($expr->isRegex()) {
  57014. $regex = $expr->getRegex();
  57015. $regex->prepend($regex->hasStartFlag() ? preg_quote($dir).\DIRECTORY_SEPARATOR : '.*')->setEndJoker(!$regex->hasEndFlag());
  57016. } else {
  57017. $expr->prepend('*')->append('*');
  57018. }
  57019. $command
  57020. ->add($i > 0 ? '-or' : null)
  57021. ->add($expr->isRegex()
  57022. ? ($expr->isCaseSensitive() ? '-regex' : '-iregex')
  57023. : ($expr->isCaseSensitive() ? '-path' : '-ipath')
  57024. )
  57025. ->arg($expr->renderPattern());
  57026. }
  57027. $command->cmd(')');
  57028. }
  57029. private function buildSizesFiltering(Command $command, array $sizes)
  57030. {
  57031. foreach ($sizes as $i => $size) {
  57032. $command->add($i > 0 ? '-and' : null);
  57033. switch ($size->getOperator()) {
  57034. case '<=':
  57035. $command->add('-size -'.($size->getTarget() + 1).'c');
  57036. break;
  57037. case '>=':
  57038. $command->add('-size +'.($size->getTarget() - 1).'c');
  57039. break;
  57040. case '>':
  57041. $command->add('-size +'.$size->getTarget().'c');
  57042. break;
  57043. case '!=':
  57044. $command->add('-size -'.$size->getTarget().'c');
  57045. $command->add('-size +'.$size->getTarget().'c');
  57046. break;
  57047. case '<':
  57048. default:
  57049. $command->add('-size -'.$size->getTarget().'c');
  57050. }
  57051. }
  57052. }
  57053. private function buildDatesFiltering(Command $command, array $dates)
  57054. {
  57055. foreach ($dates as $i => $date) {
  57056. $command->add($i > 0 ? '-and' : null);
  57057. $mins = (int) round((time() - $date->getTarget()) / 60);
  57058. if (0 > $mins) {
  57059. $command->add(' -mmin -0');
  57060. return;
  57061. }
  57062. switch ($date->getOperator()) {
  57063. case '<=':
  57064. $command->add('-mmin +'.($mins - 1));
  57065. break;
  57066. case '>=':
  57067. $command->add('-mmin -'.($mins + 1));
  57068. break;
  57069. case '>':
  57070. $command->add('-mmin -'.$mins);
  57071. break;
  57072. case '!=':
  57073. $command->add('-mmin +'.$mins.' -or -mmin -'.$mins);
  57074. break;
  57075. case '<':
  57076. default:
  57077. $command->add('-mmin +'.$mins);
  57078. }
  57079. }
  57080. }
  57081. private function buildSorting(Command $command, $sort)
  57082. {
  57083. $this->buildFormatSorting($command, $sort);
  57084. }
  57085. abstract protected function buildFormatSorting(Command $command, $sort);
  57086. abstract protected function buildContentFiltering(Command $command, array $contains, $not = false);
  57087. }
  57088. <?php
  57089. namespace Symfony\Component\Finder\Adapter;
  57090. interface AdapterInterface
  57091. {
  57092. public function setFollowLinks($followLinks);
  57093. public function setMode($mode);
  57094. public function setExclude(array $exclude);
  57095. public function setDepths(array $depths);
  57096. public function setNames(array $names);
  57097. public function setNotNames(array $notNames);
  57098. public function setContains(array $contains);
  57099. public function setNotContains(array $notContains);
  57100. public function setSizes(array $sizes);
  57101. public function setDates(array $dates);
  57102. public function setFilters(array $filters);
  57103. public function setSort($sort);
  57104. public function setPath(array $paths);
  57105. public function setNotPath(array $notPaths);
  57106. public function ignoreUnreadableDirs($ignore = true);
  57107. public function searchInDirectory($dir);
  57108. public function isSupported();
  57109. public function getName();
  57110. }
  57111. <?php
  57112. namespace Symfony\Component\Finder\Adapter;
  57113. @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);
  57114. use Symfony\Component\Finder\Expression\Expression;
  57115. use Symfony\Component\Finder\Iterator\SortableIterator;
  57116. use Symfony\Component\Finder\Shell\Command;
  57117. use Symfony\Component\Finder\Shell\Shell;
  57118. class BsdFindAdapter extends AbstractFindAdapter
  57119. {
  57120. public function getName()
  57121. {
  57122. return 'bsd_find';
  57123. }
  57124. protected function canBeUsed()
  57125. {
  57126. return \in_array($this->shell->getType(), array(Shell::TYPE_BSD, Shell::TYPE_DARWIN)) && parent::canBeUsed();
  57127. }
  57128. protected function buildFormatSorting(Command $command, $sort)
  57129. {
  57130. switch ($sort) {
  57131. case SortableIterator::SORT_BY_NAME:
  57132. $command->ins('sort')->add('| sort');
  57133. return;
  57134. case SortableIterator::SORT_BY_TYPE:
  57135. $format = '%HT';
  57136. break;
  57137. case SortableIterator::SORT_BY_ACCESSED_TIME:
  57138. $format = '%a';
  57139. break;
  57140. case SortableIterator::SORT_BY_CHANGED_TIME:
  57141. $format = '%c';
  57142. break;
  57143. case SortableIterator::SORT_BY_MODIFIED_TIME:
  57144. $format = '%m';
  57145. break;
  57146. default:
  57147. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  57148. }
  57149. $command
  57150. ->add('-print0 | xargs -0 stat -f')
  57151. ->arg($format.'%t%N')
  57152. ->add('| sort | cut -f 2');
  57153. }
  57154. protected function buildFindCommand(Command $command, $dir)
  57155. {
  57156. parent::buildFindCommand($command, $dir)->addAtIndex('-E', 1);
  57157. return $command;
  57158. }
  57159. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  57160. {
  57161. foreach ($contains as $contain) {
  57162. $expr = Expression::create($contain);
  57163. $command
  57164. ->add('| grep -v \'^$\'')
  57165. ->add('| xargs -I{} grep -I')
  57166. ->add($expr->isCaseSensitive() ? null : '-i')
  57167. ->add($not ? '-L' : '-l')
  57168. ->add('-Ee')->arg($expr->renderPattern())
  57169. ->add('{}')
  57170. ;
  57171. }
  57172. }
  57173. }
  57174. <?php
  57175. namespace Symfony\Component\Finder\Adapter;
  57176. @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);
  57177. use Symfony\Component\Finder\Expression\Expression;
  57178. use Symfony\Component\Finder\Iterator\SortableIterator;
  57179. use Symfony\Component\Finder\Shell\Command;
  57180. use Symfony\Component\Finder\Shell\Shell;
  57181. class GnuFindAdapter extends AbstractFindAdapter
  57182. {
  57183. public function getName()
  57184. {
  57185. return 'gnu_find';
  57186. }
  57187. protected function buildFormatSorting(Command $command, $sort)
  57188. {
  57189. switch ($sort) {
  57190. case SortableIterator::SORT_BY_NAME:
  57191. $command->ins('sort')->add('| sort');
  57192. return;
  57193. case SortableIterator::SORT_BY_TYPE:
  57194. $format = '%y';
  57195. break;
  57196. case SortableIterator::SORT_BY_ACCESSED_TIME:
  57197. $format = '%A@';
  57198. break;
  57199. case SortableIterator::SORT_BY_CHANGED_TIME:
  57200. $format = '%C@';
  57201. break;
  57202. case SortableIterator::SORT_BY_MODIFIED_TIME:
  57203. $format = '%T@';
  57204. break;
  57205. default:
  57206. throw new \InvalidArgumentException(sprintf('Unknown sort options: %s.', $sort));
  57207. }
  57208. $command
  57209. ->get('find')
  57210. ->add('-printf')
  57211. ->arg($format.' %h/%f\\n')
  57212. ->add('| sort | cut')
  57213. ->arg('-d ')
  57214. ->arg('-f2-')
  57215. ;
  57216. }
  57217. protected function canBeUsed()
  57218. {
  57219. return Shell::TYPE_UNIX === $this->shell->getType() && parent::canBeUsed();
  57220. }
  57221. protected function buildFindCommand(Command $command, $dir)
  57222. {
  57223. return parent::buildFindCommand($command, $dir)->add('-regextype posix-extended');
  57224. }
  57225. protected function buildContentFiltering(Command $command, array $contains, $not = false)
  57226. {
  57227. foreach ($contains as $contain) {
  57228. $expr = Expression::create($contain);
  57229. $command
  57230. ->add('| xargs -I{} -r grep -I')
  57231. ->add($expr->isCaseSensitive() ? null : '-i')
  57232. ->add($not ? '-L' : '-l')
  57233. ->add('-Ee')->arg($expr->renderPattern())
  57234. ->add('{}')
  57235. ;
  57236. }
  57237. }
  57238. }
  57239. <?php
  57240. namespace Symfony\Component\Finder\Adapter;
  57241. @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);
  57242. use Symfony\Component\Finder\Iterator;
  57243. class PhpAdapter extends AbstractAdapter
  57244. {
  57245. public function searchInDirectory($dir)
  57246. {
  57247. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  57248. if ($this->followLinks) {
  57249. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  57250. }
  57251. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  57252. if ($this->exclude) {
  57253. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  57254. }
  57255. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  57256. if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
  57257. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
  57258. }
  57259. if ($this->mode) {
  57260. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  57261. }
  57262. if ($this->names || $this->notNames) {
  57263. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  57264. }
  57265. if ($this->contains || $this->notContains) {
  57266. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  57267. }
  57268. if ($this->sizes) {
  57269. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  57270. }
  57271. if ($this->dates) {
  57272. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  57273. }
  57274. if ($this->filters) {
  57275. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  57276. }
  57277. if ($this->paths || $this->notPaths) {
  57278. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  57279. }
  57280. if ($this->sort) {
  57281. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  57282. $iterator = $iteratorAggregate->getIterator();
  57283. }
  57284. return $iterator;
  57285. }
  57286. public function getName()
  57287. {
  57288. return 'php';
  57289. }
  57290. protected function canBeUsed()
  57291. {
  57292. return true;
  57293. }
  57294. }
  57295. <?php
  57296. namespace Symfony\Component\Finder\Comparator;
  57297. class Comparator
  57298. {
  57299. private $target;
  57300. private $operator = '==';
  57301. public function getTarget()
  57302. {
  57303. return $this->target;
  57304. }
  57305. public function setTarget($target)
  57306. {
  57307. $this->target = $target;
  57308. }
  57309. public function getOperator()
  57310. {
  57311. return $this->operator;
  57312. }
  57313. public function setOperator($operator)
  57314. {
  57315. if (!$operator) {
  57316. $operator = '==';
  57317. }
  57318. if (!\in_array($operator, array('>', '<', '>=', '<=', '==', '!='))) {
  57319. throw new \InvalidArgumentException(sprintf('Invalid operator "%s".', $operator));
  57320. }
  57321. $this->operator = $operator;
  57322. }
  57323. public function test($test)
  57324. {
  57325. switch ($this->operator) {
  57326. case '>':
  57327. return $test > $this->target;
  57328. case '>=':
  57329. return $test >= $this->target;
  57330. case '<':
  57331. return $test < $this->target;
  57332. case '<=':
  57333. return $test <= $this->target;
  57334. case '!=':
  57335. return $test != $this->target;
  57336. }
  57337. return $test == $this->target;
  57338. }
  57339. }
  57340. <?php
  57341. namespace Symfony\Component\Finder\Comparator;
  57342. class DateComparator extends Comparator
  57343. {
  57344. public function __construct($test)
  57345. {
  57346. if (!preg_match('#^\s*(==|!=|[<>]=?|after|since|before|until)?\s*(.+?)\s*$#i', $test, $matches)) {
  57347. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a date test.', $test));
  57348. }
  57349. try {
  57350. $date = new \DateTime($matches[2]);
  57351. $target = $date->format('U');
  57352. } catch (\Exception $e) {
  57353. throw new \InvalidArgumentException(sprintf('"%s" is not a valid date.', $matches[2]));
  57354. }
  57355. $operator = isset($matches[1]) ? $matches[1] : '==';
  57356. if ('since' === $operator || 'after' === $operator) {
  57357. $operator = '>';
  57358. }
  57359. if ('until' === $operator || 'before' === $operator) {
  57360. $operator = '<';
  57361. }
  57362. $this->setOperator($operator);
  57363. $this->setTarget($target);
  57364. }
  57365. }
  57366. <?php
  57367. namespace Symfony\Component\Finder\Comparator;
  57368. class NumberComparator extends Comparator
  57369. {
  57370. public function __construct($test)
  57371. {
  57372. if (!preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) {
  57373. throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test));
  57374. }
  57375. $target = $matches[2];
  57376. if (!is_numeric($target)) {
  57377. throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target));
  57378. }
  57379. if (isset($matches[3])) {
  57380. switch (strtolower($matches[3])) {
  57381. case 'k':
  57382. $target *= 1000;
  57383. break;
  57384. case 'ki':
  57385. $target *= 1024;
  57386. break;
  57387. case 'm':
  57388. $target *= 1000000;
  57389. break;
  57390. case 'mi':
  57391. $target *= 1024 * 1024;
  57392. break;
  57393. case 'g':
  57394. $target *= 1000000000;
  57395. break;
  57396. case 'gi':
  57397. $target *= 1024 * 1024 * 1024;
  57398. break;
  57399. }
  57400. }
  57401. $this->setTarget($target);
  57402. $this->setOperator(isset($matches[1]) ? $matches[1] : '==');
  57403. }
  57404. }
  57405. <?php
  57406. namespace Symfony\Component\Finder\Exception;
  57407. class AccessDeniedException extends \UnexpectedValueException
  57408. {
  57409. }
  57410. <?php
  57411. namespace Symfony\Component\Finder\Exception;
  57412. @trigger_error('The '.__NAMESPACE__.'\AdapterFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57413. use Symfony\Component\Finder\Adapter\AdapterInterface;
  57414. class AdapterFailureException extends \RuntimeException implements ExceptionInterface
  57415. {
  57416. private $adapter;
  57417. public function __construct(AdapterInterface $adapter, $message = null, \Exception $previous = null)
  57418. {
  57419. $this->adapter = $adapter;
  57420. parent::__construct($message ?: 'Search failed with "'.$adapter->getName().'" adapter.', $previous);
  57421. }
  57422. public function getAdapter()
  57423. {
  57424. return $this->adapter;
  57425. }
  57426. }
  57427. <?php
  57428. namespace Symfony\Component\Finder\Exception;
  57429. interface ExceptionInterface
  57430. {
  57431. public function getAdapter();
  57432. }
  57433. <?php
  57434. namespace Symfony\Component\Finder\Exception;
  57435. @trigger_error('The '.__NAMESPACE__.'\OperationNotPermitedException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57436. class OperationNotPermitedException extends AdapterFailureException
  57437. {
  57438. }
  57439. <?php
  57440. namespace Symfony\Component\Finder\Exception;
  57441. @trigger_error('The '.__NAMESPACE__.'\ShellCommandFailureException class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57442. use Symfony\Component\Finder\Adapter\AdapterInterface;
  57443. use Symfony\Component\Finder\Shell\Command;
  57444. class ShellCommandFailureException extends AdapterFailureException
  57445. {
  57446. private $command;
  57447. public function __construct(AdapterInterface $adapter, Command $command, \Exception $previous = null)
  57448. {
  57449. $this->command = $command;
  57450. parent::__construct($adapter, 'Shell command failed: "'.$command->join().'".', $previous);
  57451. }
  57452. public function getCommand()
  57453. {
  57454. return $this->command;
  57455. }
  57456. }
  57457. <?php
  57458. namespace Symfony\Component\Finder\Expression;
  57459. @trigger_error('The '.__NAMESPACE__.'\Expression class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57460. class Expression implements ValueInterface
  57461. {
  57462. const TYPE_REGEX = 1;
  57463. const TYPE_GLOB = 2;
  57464. private $value;
  57465. public static function create($expr)
  57466. {
  57467. return new self($expr);
  57468. }
  57469. public function __construct($expr)
  57470. {
  57471. try {
  57472. $this->value = Regex::create($expr);
  57473. } catch (\InvalidArgumentException $e) {
  57474. $this->value = new Glob($expr);
  57475. }
  57476. }
  57477. public function __toString()
  57478. {
  57479. return $this->render();
  57480. }
  57481. public function render()
  57482. {
  57483. return $this->value->render();
  57484. }
  57485. public function renderPattern()
  57486. {
  57487. return $this->value->renderPattern();
  57488. }
  57489. public function isCaseSensitive()
  57490. {
  57491. return $this->value->isCaseSensitive();
  57492. }
  57493. public function getType()
  57494. {
  57495. return $this->value->getType();
  57496. }
  57497. public function prepend($expr)
  57498. {
  57499. $this->value->prepend($expr);
  57500. return $this;
  57501. }
  57502. public function append($expr)
  57503. {
  57504. $this->value->append($expr);
  57505. return $this;
  57506. }
  57507. public function isRegex()
  57508. {
  57509. return self::TYPE_REGEX === $this->value->getType();
  57510. }
  57511. public function isGlob()
  57512. {
  57513. return self::TYPE_GLOB === $this->value->getType();
  57514. }
  57515. public function getGlob()
  57516. {
  57517. if (self::TYPE_GLOB !== $this->value->getType()) {
  57518. throw new \LogicException('Regex can\'t be transformed to glob.');
  57519. }
  57520. return $this->value;
  57521. }
  57522. public function getRegex()
  57523. {
  57524. return self::TYPE_REGEX === $this->value->getType() ? $this->value : $this->value->toRegex();
  57525. }
  57526. }
  57527. <?php
  57528. namespace Symfony\Component\Finder\Expression;
  57529. @trigger_error('The '.__NAMESPACE__.'\Glob class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57530. use Symfony\Component\Finder\Glob as FinderGlob;
  57531. class Glob implements ValueInterface
  57532. {
  57533. private $pattern;
  57534. public function __construct($pattern)
  57535. {
  57536. $this->pattern = $pattern;
  57537. }
  57538. public function render()
  57539. {
  57540. return $this->pattern;
  57541. }
  57542. public function renderPattern()
  57543. {
  57544. return $this->pattern;
  57545. }
  57546. public function getType()
  57547. {
  57548. return Expression::TYPE_GLOB;
  57549. }
  57550. public function isCaseSensitive()
  57551. {
  57552. return true;
  57553. }
  57554. public function prepend($expr)
  57555. {
  57556. $this->pattern = $expr.$this->pattern;
  57557. return $this;
  57558. }
  57559. public function append($expr)
  57560. {
  57561. $this->pattern .= $expr;
  57562. return $this;
  57563. }
  57564. public function isExpandable()
  57565. {
  57566. return false !== strpos($this->pattern, '{')
  57567. && false !== strpos($this->pattern, '}');
  57568. }
  57569. public function toRegex($strictLeadingDot = true, $strictWildcardSlash = true)
  57570. {
  57571. $regex = FinderGlob::toRegex($this->pattern, $strictLeadingDot, $strictWildcardSlash, '');
  57572. return new Regex($regex);
  57573. }
  57574. }
  57575. <?php
  57576. namespace Symfony\Component\Finder\Expression;
  57577. @trigger_error('The '.__NAMESPACE__.'\Regex class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57578. class Regex implements ValueInterface
  57579. {
  57580. const START_FLAG = '^';
  57581. const END_FLAG = '$';
  57582. const BOUNDARY = '~';
  57583. const JOKER = '.*';
  57584. const ESCAPING = '\\';
  57585. private $pattern;
  57586. private $options;
  57587. private $startFlag;
  57588. private $endFlag;
  57589. private $startJoker;
  57590. private $endJoker;
  57591. public static function create($expr)
  57592. {
  57593. if (preg_match('/^(.{3,}?)([imsxuADU]*)$/', $expr, $m)) {
  57594. $start = substr($m[1], 0, 1);
  57595. $end = substr($m[1], -1);
  57596. if (
  57597. ($start === $end && !preg_match('/[*?[:alnum:] \\\\]/', $start))
  57598. || ('{' === $start && '}' === $end)
  57599. || ('(' === $start && ')' === $end)
  57600. ) {
  57601. return new self(substr($m[1], 1, -1), $m[2], $end);
  57602. }
  57603. }
  57604. throw new \InvalidArgumentException('Given expression is not a regex.');
  57605. }
  57606. public function __construct($pattern, $options = '', $delimiter = null)
  57607. {
  57608. if (null !== $delimiter) {
  57609. $pattern = str_replace('\\'.$delimiter, $delimiter, $pattern);
  57610. }
  57611. $this->parsePattern($pattern);
  57612. $this->options = $options;
  57613. }
  57614. public function __toString()
  57615. {
  57616. return $this->render();
  57617. }
  57618. public function render()
  57619. {
  57620. return self::BOUNDARY
  57621. .$this->renderPattern()
  57622. .self::BOUNDARY
  57623. .$this->options;
  57624. }
  57625. public function renderPattern()
  57626. {
  57627. return ($this->startFlag ? self::START_FLAG : '')
  57628. .($this->startJoker ? self::JOKER : '')
  57629. .str_replace(self::BOUNDARY, '\\'.self::BOUNDARY, $this->pattern)
  57630. .($this->endJoker ? self::JOKER : '')
  57631. .($this->endFlag ? self::END_FLAG : '');
  57632. }
  57633. public function isCaseSensitive()
  57634. {
  57635. return !$this->hasOption('i');
  57636. }
  57637. public function getType()
  57638. {
  57639. return Expression::TYPE_REGEX;
  57640. }
  57641. public function prepend($expr)
  57642. {
  57643. $this->pattern = $expr.$this->pattern;
  57644. return $this;
  57645. }
  57646. public function append($expr)
  57647. {
  57648. $this->pattern .= $expr;
  57649. return $this;
  57650. }
  57651. public function hasOption($option)
  57652. {
  57653. return false !== strpos($this->options, $option);
  57654. }
  57655. public function addOption($option)
  57656. {
  57657. if (!$this->hasOption($option)) {
  57658. $this->options .= $option;
  57659. }
  57660. return $this;
  57661. }
  57662. public function removeOption($option)
  57663. {
  57664. $this->options = str_replace($option, '', $this->options);
  57665. return $this;
  57666. }
  57667. public function setStartFlag($startFlag)
  57668. {
  57669. $this->startFlag = $startFlag;
  57670. return $this;
  57671. }
  57672. public function hasStartFlag()
  57673. {
  57674. return $this->startFlag;
  57675. }
  57676. public function setEndFlag($endFlag)
  57677. {
  57678. $this->endFlag = (bool) $endFlag;
  57679. return $this;
  57680. }
  57681. public function hasEndFlag()
  57682. {
  57683. return $this->endFlag;
  57684. }
  57685. public function setStartJoker($startJoker)
  57686. {
  57687. $this->startJoker = $startJoker;
  57688. return $this;
  57689. }
  57690. public function hasStartJoker()
  57691. {
  57692. return $this->startJoker;
  57693. }
  57694. public function setEndJoker($endJoker)
  57695. {
  57696. $this->endJoker = (bool) $endJoker;
  57697. return $this;
  57698. }
  57699. public function hasEndJoker()
  57700. {
  57701. return $this->endJoker;
  57702. }
  57703. public function replaceJokers($replacement)
  57704. {
  57705. $replace = function ($subject) use ($replacement) {
  57706. $subject = $subject[0];
  57707. $replace = 0 === substr_count($subject, '\\') % 2;
  57708. return $replace ? str_replace('.', $replacement, $subject) : $subject;
  57709. };
  57710. $this->pattern = preg_replace_callback('~[\\\\]*\\.~', $replace, $this->pattern);
  57711. return $this;
  57712. }
  57713. private function parsePattern($pattern)
  57714. {
  57715. if ($this->startFlag = self::START_FLAG === substr($pattern, 0, 1)) {
  57716. $pattern = substr($pattern, 1);
  57717. }
  57718. if ($this->startJoker = self::JOKER === substr($pattern, 0, 2)) {
  57719. $pattern = substr($pattern, 2);
  57720. }
  57721. if ($this->endFlag = (self::END_FLAG === substr($pattern, -1) && self::ESCAPING !== substr($pattern, -2, -1))) {
  57722. $pattern = substr($pattern, 0, -1);
  57723. }
  57724. if ($this->endJoker = (self::JOKER === substr($pattern, -2) && self::ESCAPING !== substr($pattern, -3, -2))) {
  57725. $pattern = substr($pattern, 0, -2);
  57726. }
  57727. $this->pattern = $pattern;
  57728. }
  57729. }
  57730. <?php
  57731. namespace Symfony\Component\Finder\Expression;
  57732. @trigger_error('The '.__NAMESPACE__.'\ValueInterface interface is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57733. interface ValueInterface
  57734. {
  57735. public function render();
  57736. public function renderPattern();
  57737. public function isCaseSensitive();
  57738. public function getType();
  57739. public function prepend($expr);
  57740. public function append($expr);
  57741. }
  57742. <?php
  57743. namespace Symfony\Component\Finder;
  57744. use Symfony\Component\Finder\Adapter\AdapterInterface;
  57745. use Symfony\Component\Finder\Adapter\BsdFindAdapter;
  57746. use Symfony\Component\Finder\Adapter\GnuFindAdapter;
  57747. use Symfony\Component\Finder\Adapter\PhpAdapter;
  57748. use Symfony\Component\Finder\Comparator\DateComparator;
  57749. use Symfony\Component\Finder\Comparator\NumberComparator;
  57750. use Symfony\Component\Finder\Exception\ExceptionInterface;
  57751. use Symfony\Component\Finder\Iterator\CustomFilterIterator;
  57752. use Symfony\Component\Finder\Iterator\DateRangeFilterIterator;
  57753. use Symfony\Component\Finder\Iterator\DepthRangeFilterIterator;
  57754. use Symfony\Component\Finder\Iterator\ExcludeDirectoryFilterIterator;
  57755. use Symfony\Component\Finder\Iterator\FilecontentFilterIterator;
  57756. use Symfony\Component\Finder\Iterator\FilenameFilterIterator;
  57757. use Symfony\Component\Finder\Iterator\SizeRangeFilterIterator;
  57758. use Symfony\Component\Finder\Iterator\SortableIterator;
  57759. class Finder implements \IteratorAggregate, \Countable
  57760. {
  57761. const IGNORE_VCS_FILES = 1;
  57762. const IGNORE_DOT_FILES = 2;
  57763. private $mode = 0;
  57764. private $names = array();
  57765. private $notNames = array();
  57766. private $exclude = array();
  57767. private $filters = array();
  57768. private $depths = array();
  57769. private $sizes = array();
  57770. private $followLinks = false;
  57771. private $sort = false;
  57772. private $ignore = 0;
  57773. private $dirs = array();
  57774. private $dates = array();
  57775. private $iterators = array();
  57776. private $contains = array();
  57777. private $notContains = array();
  57778. private $adapters = null;
  57779. private $paths = array();
  57780. private $notPaths = array();
  57781. private $ignoreUnreadableDirs = false;
  57782. private static $vcsPatterns = array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg');
  57783. public function __construct()
  57784. {
  57785. $this->ignore = static::IGNORE_VCS_FILES | static::IGNORE_DOT_FILES;
  57786. }
  57787. public static function create()
  57788. {
  57789. return new static();
  57790. }
  57791. public function addAdapter(AdapterInterface $adapter, $priority = 0)
  57792. {
  57793. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57794. $this->initDefaultAdapters();
  57795. $this->adapters[$adapter->getName()] = array(
  57796. 'adapter' => $adapter,
  57797. 'priority' => $priority,
  57798. 'selected' => false,
  57799. );
  57800. return $this->sortAdapters();
  57801. }
  57802. public function useBestAdapter()
  57803. {
  57804. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57805. $this->initDefaultAdapters();
  57806. $this->resetAdapterSelection();
  57807. return $this->sortAdapters();
  57808. }
  57809. public function setAdapter($name)
  57810. {
  57811. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57812. $this->initDefaultAdapters();
  57813. if (!isset($this->adapters[$name])) {
  57814. throw new \InvalidArgumentException(sprintf('Adapter "%s" does not exist.', $name));
  57815. }
  57816. $this->resetAdapterSelection();
  57817. $this->adapters[$name]['selected'] = true;
  57818. return $this->sortAdapters();
  57819. }
  57820. public function removeAdapters()
  57821. {
  57822. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57823. $this->adapters = array();
  57824. return $this;
  57825. }
  57826. public function getAdapters()
  57827. {
  57828. @trigger_error('The '.__METHOD__.' method is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  57829. $this->initDefaultAdapters();
  57830. return array_values(array_map(function (array $adapter) {
  57831. return $adapter['adapter'];
  57832. }, $this->adapters));
  57833. }
  57834. public function directories()
  57835. {
  57836. $this->mode = Iterator\FileTypeFilterIterator::ONLY_DIRECTORIES;
  57837. return $this;
  57838. }
  57839. public function files()
  57840. {
  57841. $this->mode = Iterator\FileTypeFilterIterator::ONLY_FILES;
  57842. return $this;
  57843. }
  57844. public function depth($level)
  57845. {
  57846. $this->depths[] = new Comparator\NumberComparator($level);
  57847. return $this;
  57848. }
  57849. public function date($date)
  57850. {
  57851. $this->dates[] = new Comparator\DateComparator($date);
  57852. return $this;
  57853. }
  57854. public function name($pattern)
  57855. {
  57856. $this->names[] = $pattern;
  57857. return $this;
  57858. }
  57859. public function notName($pattern)
  57860. {
  57861. $this->notNames[] = $pattern;
  57862. return $this;
  57863. }
  57864. public function contains($pattern)
  57865. {
  57866. $this->contains[] = $pattern;
  57867. return $this;
  57868. }
  57869. public function notContains($pattern)
  57870. {
  57871. $this->notContains[] = $pattern;
  57872. return $this;
  57873. }
  57874. public function path($pattern)
  57875. {
  57876. $this->paths[] = $pattern;
  57877. return $this;
  57878. }
  57879. public function notPath($pattern)
  57880. {
  57881. $this->notPaths[] = $pattern;
  57882. return $this;
  57883. }
  57884. public function size($size)
  57885. {
  57886. $this->sizes[] = new Comparator\NumberComparator($size);
  57887. return $this;
  57888. }
  57889. public function exclude($dirs)
  57890. {
  57891. $this->exclude = array_merge($this->exclude, (array) $dirs);
  57892. return $this;
  57893. }
  57894. public function ignoreDotFiles($ignoreDotFiles)
  57895. {
  57896. if ($ignoreDotFiles) {
  57897. $this->ignore |= static::IGNORE_DOT_FILES;
  57898. } else {
  57899. $this->ignore &= ~static::IGNORE_DOT_FILES;
  57900. }
  57901. return $this;
  57902. }
  57903. public function ignoreVCS($ignoreVCS)
  57904. {
  57905. if ($ignoreVCS) {
  57906. $this->ignore |= static::IGNORE_VCS_FILES;
  57907. } else {
  57908. $this->ignore &= ~static::IGNORE_VCS_FILES;
  57909. }
  57910. return $this;
  57911. }
  57912. public static function addVCSPattern($pattern)
  57913. {
  57914. foreach ((array) $pattern as $p) {
  57915. self::$vcsPatterns[] = $p;
  57916. }
  57917. self::$vcsPatterns = array_unique(self::$vcsPatterns);
  57918. }
  57919. public function sort(\Closure $closure)
  57920. {
  57921. $this->sort = $closure;
  57922. return $this;
  57923. }
  57924. public function sortByName()
  57925. {
  57926. $this->sort = Iterator\SortableIterator::SORT_BY_NAME;
  57927. return $this;
  57928. }
  57929. public function sortByType()
  57930. {
  57931. $this->sort = Iterator\SortableIterator::SORT_BY_TYPE;
  57932. return $this;
  57933. }
  57934. public function sortByAccessedTime()
  57935. {
  57936. $this->sort = Iterator\SortableIterator::SORT_BY_ACCESSED_TIME;
  57937. return $this;
  57938. }
  57939. public function sortByChangedTime()
  57940. {
  57941. $this->sort = Iterator\SortableIterator::SORT_BY_CHANGED_TIME;
  57942. return $this;
  57943. }
  57944. public function sortByModifiedTime()
  57945. {
  57946. $this->sort = Iterator\SortableIterator::SORT_BY_MODIFIED_TIME;
  57947. return $this;
  57948. }
  57949. public function filter(\Closure $closure)
  57950. {
  57951. $this->filters[] = $closure;
  57952. return $this;
  57953. }
  57954. public function followLinks()
  57955. {
  57956. $this->followLinks = true;
  57957. return $this;
  57958. }
  57959. public function ignoreUnreadableDirs($ignore = true)
  57960. {
  57961. $this->ignoreUnreadableDirs = (bool) $ignore;
  57962. return $this;
  57963. }
  57964. public function in($dirs)
  57965. {
  57966. $resolvedDirs = array();
  57967. foreach ((array) $dirs as $dir) {
  57968. if (is_dir($dir)) {
  57969. $resolvedDirs[] = $this->normalizeDir($dir);
  57970. } elseif ($glob = glob($dir, (\defined('GLOB_BRACE') ? GLOB_BRACE : 0) | GLOB_ONLYDIR)) {
  57971. $resolvedDirs = array_merge($resolvedDirs, array_map(array($this, 'normalizeDir'), $glob));
  57972. } else {
  57973. throw new \InvalidArgumentException(sprintf('The "%s" directory does not exist.', $dir));
  57974. }
  57975. }
  57976. $this->dirs = array_merge($this->dirs, $resolvedDirs);
  57977. return $this;
  57978. }
  57979. public function getIterator()
  57980. {
  57981. if (0 === \count($this->dirs) && 0 === \count($this->iterators)) {
  57982. throw new \LogicException('You must call one of in() or append() methods before iterating over a Finder.');
  57983. }
  57984. if (1 === \count($this->dirs) && 0 === \count($this->iterators)) {
  57985. return $this->searchInDirectory($this->dirs[0]);
  57986. }
  57987. $iterator = new \AppendIterator();
  57988. foreach ($this->dirs as $dir) {
  57989. $iterator->append($this->searchInDirectory($dir));
  57990. }
  57991. foreach ($this->iterators as $it) {
  57992. $iterator->append($it);
  57993. }
  57994. return $iterator;
  57995. }
  57996. public function append($iterator)
  57997. {
  57998. if ($iterator instanceof \IteratorAggregate) {
  57999. $this->iterators[] = $iterator->getIterator();
  58000. } elseif ($iterator instanceof \Iterator) {
  58001. $this->iterators[] = $iterator;
  58002. } elseif ($iterator instanceof \Traversable || \is_array($iterator)) {
  58003. $it = new \ArrayIterator();
  58004. foreach ($iterator as $file) {
  58005. $it->append($file instanceof \SplFileInfo ? $file : new \SplFileInfo($file));
  58006. }
  58007. $this->iterators[] = $it;
  58008. } else {
  58009. throw new \InvalidArgumentException('Finder::append() method wrong argument type.');
  58010. }
  58011. return $this;
  58012. }
  58013. public function count()
  58014. {
  58015. return iterator_count($this->getIterator());
  58016. }
  58017. private function sortAdapters()
  58018. {
  58019. uasort($this->adapters, function (array $a, array $b) {
  58020. if ($a['selected'] || $b['selected']) {
  58021. return $a['selected'] ? -1 : 1;
  58022. }
  58023. return $a['priority'] > $b['priority'] ? -1 : 1;
  58024. });
  58025. return $this;
  58026. }
  58027. private function searchInDirectory($dir)
  58028. {
  58029. if (static::IGNORE_VCS_FILES === (static::IGNORE_VCS_FILES & $this->ignore)) {
  58030. $this->exclude = array_merge($this->exclude, self::$vcsPatterns);
  58031. }
  58032. if (static::IGNORE_DOT_FILES === (static::IGNORE_DOT_FILES & $this->ignore)) {
  58033. $this->notPaths[] = '#(^|/)\..+(/|$)#';
  58034. }
  58035. if ($this->adapters) {
  58036. foreach ($this->adapters as $adapter) {
  58037. if ($adapter['adapter']->isSupported()) {
  58038. try {
  58039. return $this
  58040. ->buildAdapter($adapter['adapter'])
  58041. ->searchInDirectory($dir);
  58042. } catch (ExceptionInterface $e) {
  58043. }
  58044. }
  58045. }
  58046. }
  58047. $minDepth = 0;
  58048. $maxDepth = PHP_INT_MAX;
  58049. foreach ($this->depths as $comparator) {
  58050. switch ($comparator->getOperator()) {
  58051. case '>':
  58052. $minDepth = $comparator->getTarget() + 1;
  58053. break;
  58054. case '>=':
  58055. $minDepth = $comparator->getTarget();
  58056. break;
  58057. case '<':
  58058. $maxDepth = $comparator->getTarget() - 1;
  58059. break;
  58060. case '<=':
  58061. $maxDepth = $comparator->getTarget();
  58062. break;
  58063. default:
  58064. $minDepth = $maxDepth = $comparator->getTarget();
  58065. }
  58066. }
  58067. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  58068. if ($this->followLinks) {
  58069. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  58070. }
  58071. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  58072. if ($this->exclude) {
  58073. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  58074. }
  58075. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  58076. if ($minDepth > 0 || $maxDepth < PHP_INT_MAX) {
  58077. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $minDepth, $maxDepth);
  58078. }
  58079. if ($this->mode) {
  58080. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  58081. }
  58082. if ($this->names || $this->notNames) {
  58083. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  58084. }
  58085. if ($this->contains || $this->notContains) {
  58086. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  58087. }
  58088. if ($this->sizes) {
  58089. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  58090. }
  58091. if ($this->dates) {
  58092. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  58093. }
  58094. if ($this->filters) {
  58095. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  58096. }
  58097. if ($this->paths || $this->notPaths) {
  58098. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  58099. }
  58100. if ($this->sort) {
  58101. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  58102. $iterator = $iteratorAggregate->getIterator();
  58103. }
  58104. return $iterator;
  58105. }
  58106. private function buildAdapter(AdapterInterface $adapter)
  58107. {
  58108. return $adapter
  58109. ->setFollowLinks($this->followLinks)
  58110. ->setDepths($this->depths)
  58111. ->setMode($this->mode)
  58112. ->setExclude($this->exclude)
  58113. ->setNames($this->names)
  58114. ->setNotNames($this->notNames)
  58115. ->setContains($this->contains)
  58116. ->setNotContains($this->notContains)
  58117. ->setSizes($this->sizes)
  58118. ->setDates($this->dates)
  58119. ->setFilters($this->filters)
  58120. ->setSort($this->sort)
  58121. ->setPath($this->paths)
  58122. ->setNotPath($this->notPaths)
  58123. ->ignoreUnreadableDirs($this->ignoreUnreadableDirs);
  58124. }
  58125. private function resetAdapterSelection()
  58126. {
  58127. $this->adapters = array_map(function (array $properties) {
  58128. $properties['selected'] = false;
  58129. return $properties;
  58130. }, $this->adapters);
  58131. }
  58132. private function initDefaultAdapters()
  58133. {
  58134. if (null === $this->adapters) {
  58135. $this->adapters = array();
  58136. $this
  58137. ->addAdapter(new GnuFindAdapter())
  58138. ->addAdapter(new BsdFindAdapter())
  58139. ->addAdapter(new PhpAdapter(), -50)
  58140. ->setAdapter('php')
  58141. ;
  58142. }
  58143. }
  58144. private function normalizeDir($dir)
  58145. {
  58146. return rtrim($dir, '/'.\DIRECTORY_SEPARATOR);
  58147. }
  58148. }
  58149. <?php
  58150. namespace Symfony\Component\Finder;
  58151. class Glob
  58152. {
  58153. public static function toRegex($glob, $strictLeadingDot = true, $strictWildcardSlash = true, $delimiter = '#')
  58154. {
  58155. $firstByte = true;
  58156. $escaping = false;
  58157. $inCurlies = 0;
  58158. $regex = '';
  58159. $sizeGlob = \strlen($glob);
  58160. for ($i = 0; $i < $sizeGlob; ++$i) {
  58161. $car = $glob[$i];
  58162. if ($firstByte) {
  58163. if ($strictLeadingDot && '.' !== $car) {
  58164. $regex .= '(?=[^\.])';
  58165. }
  58166. $firstByte = false;
  58167. }
  58168. if ('/' === $car) {
  58169. $firstByte = true;
  58170. }
  58171. if ($delimiter === $car || '.' === $car || '(' === $car || ')' === $car || '|' === $car || '+' === $car || '^' === $car || '$' === $car) {
  58172. $regex .= "\\$car";
  58173. } elseif ('*' === $car) {
  58174. $regex .= $escaping ? '\\*' : ($strictWildcardSlash ? '[^/]*' : '.*');
  58175. } elseif ('?' === $car) {
  58176. $regex .= $escaping ? '\\?' : ($strictWildcardSlash ? '[^/]' : '.');
  58177. } elseif ('{' === $car) {
  58178. $regex .= $escaping ? '\\{' : '(';
  58179. if (!$escaping) {
  58180. ++$inCurlies;
  58181. }
  58182. } elseif ('}' === $car && $inCurlies) {
  58183. $regex .= $escaping ? '}' : ')';
  58184. if (!$escaping) {
  58185. --$inCurlies;
  58186. }
  58187. } elseif (',' === $car && $inCurlies) {
  58188. $regex .= $escaping ? ',' : '|';
  58189. } elseif ('\\' === $car) {
  58190. if ($escaping) {
  58191. $regex .= '\\\\';
  58192. $escaping = false;
  58193. } else {
  58194. $escaping = true;
  58195. }
  58196. continue;
  58197. } else {
  58198. $regex .= $car;
  58199. }
  58200. $escaping = false;
  58201. }
  58202. return $delimiter.'^'.$regex.'$'.$delimiter;
  58203. }
  58204. }
  58205. <?php
  58206. namespace Symfony\Component\Finder\Iterator;
  58207. class CustomFilterIterator extends FilterIterator
  58208. {
  58209. private $filters = array();
  58210. public function __construct(\Iterator $iterator, array $filters)
  58211. {
  58212. foreach ($filters as $filter) {
  58213. if (!\is_callable($filter)) {
  58214. throw new \InvalidArgumentException('Invalid PHP callback.');
  58215. }
  58216. }
  58217. $this->filters = $filters;
  58218. parent::__construct($iterator);
  58219. }
  58220. public function accept()
  58221. {
  58222. $fileinfo = $this->current();
  58223. foreach ($this->filters as $filter) {
  58224. if (false === \call_user_func($filter, $fileinfo)) {
  58225. return false;
  58226. }
  58227. }
  58228. return true;
  58229. }
  58230. }
  58231. <?php
  58232. namespace Symfony\Component\Finder\Iterator;
  58233. use Symfony\Component\Finder\Comparator\DateComparator;
  58234. class DateRangeFilterIterator extends FilterIterator
  58235. {
  58236. private $comparators = array();
  58237. public function __construct(\Iterator $iterator, array $comparators)
  58238. {
  58239. $this->comparators = $comparators;
  58240. parent::__construct($iterator);
  58241. }
  58242. public function accept()
  58243. {
  58244. $fileinfo = $this->current();
  58245. if (!file_exists($fileinfo->getPathname())) {
  58246. return false;
  58247. }
  58248. $filedate = $fileinfo->getMTime();
  58249. foreach ($this->comparators as $compare) {
  58250. if (!$compare->test($filedate)) {
  58251. return false;
  58252. }
  58253. }
  58254. return true;
  58255. }
  58256. }
  58257. <?php
  58258. namespace Symfony\Component\Finder\Iterator;
  58259. class DepthRangeFilterIterator extends FilterIterator
  58260. {
  58261. private $minDepth = 0;
  58262. public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = PHP_INT_MAX)
  58263. {
  58264. $this->minDepth = $minDepth;
  58265. $iterator->setMaxDepth(PHP_INT_MAX === $maxDepth ? -1 : $maxDepth);
  58266. parent::__construct($iterator);
  58267. }
  58268. public function accept()
  58269. {
  58270. return $this->getInnerIterator()->getDepth() >= $this->minDepth;
  58271. }
  58272. }
  58273. <?php
  58274. namespace Symfony\Component\Finder\Iterator;
  58275. class ExcludeDirectoryFilterIterator extends FilterIterator implements \RecursiveIterator
  58276. {
  58277. private $iterator;
  58278. private $isRecursive;
  58279. private $excludedDirs = array();
  58280. private $excludedPattern;
  58281. public function __construct(\Iterator $iterator, array $directories)
  58282. {
  58283. $this->iterator = $iterator;
  58284. $this->isRecursive = $iterator instanceof \RecursiveIterator;
  58285. $patterns = array();
  58286. foreach ($directories as $directory) {
  58287. $directory = rtrim($directory, '/');
  58288. if (!$this->isRecursive || false !== strpos($directory, '/')) {
  58289. $patterns[] = preg_quote($directory, '#');
  58290. } else {
  58291. $this->excludedDirs[$directory] = true;
  58292. }
  58293. }
  58294. if ($patterns) {
  58295. $this->excludedPattern = '#(?:^|/)(?:'.implode('|', $patterns).')(?:/|$)#';
  58296. }
  58297. parent::__construct($iterator);
  58298. }
  58299. public function accept()
  58300. {
  58301. if ($this->isRecursive && isset($this->excludedDirs[$this->getFilename()]) && $this->isDir()) {
  58302. return false;
  58303. }
  58304. if ($this->excludedPattern) {
  58305. $path = $this->isDir() ? $this->current()->getRelativePathname() : $this->current()->getRelativePath();
  58306. $path = str_replace('\\', '/', $path);
  58307. return !preg_match($this->excludedPattern, $path);
  58308. }
  58309. return true;
  58310. }
  58311. public function hasChildren()
  58312. {
  58313. return $this->isRecursive && $this->iterator->hasChildren();
  58314. }
  58315. public function getChildren()
  58316. {
  58317. $children = new self($this->iterator->getChildren(), array());
  58318. $children->excludedDirs = $this->excludedDirs;
  58319. $children->excludedPattern = $this->excludedPattern;
  58320. return $children;
  58321. }
  58322. }
  58323. <?php
  58324. namespace Symfony\Component\Finder\Iterator;
  58325. @trigger_error('The '.__NAMESPACE__.'\FilePathsIterator class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58326. use Symfony\Component\Finder\SplFileInfo;
  58327. class FilePathsIterator extends \ArrayIterator
  58328. {
  58329. private $baseDir;
  58330. private $baseDirLength;
  58331. private $subPath;
  58332. private $subPathname;
  58333. private $current;
  58334. public function __construct(array $paths, $baseDir)
  58335. {
  58336. $this->baseDir = $baseDir;
  58337. $this->baseDirLength = \strlen($baseDir);
  58338. parent::__construct($paths);
  58339. }
  58340. public function __call($name, array $arguments)
  58341. {
  58342. return \call_user_func_array(array($this->current(), $name), $arguments);
  58343. }
  58344. public function current()
  58345. {
  58346. return $this->current;
  58347. }
  58348. public function key()
  58349. {
  58350. return $this->current->getPathname();
  58351. }
  58352. public function next()
  58353. {
  58354. parent::next();
  58355. $this->buildProperties();
  58356. }
  58357. public function rewind()
  58358. {
  58359. parent::rewind();
  58360. $this->buildProperties();
  58361. }
  58362. public function getSubPath()
  58363. {
  58364. return $this->subPath;
  58365. }
  58366. public function getSubPathname()
  58367. {
  58368. return $this->subPathname;
  58369. }
  58370. private function buildProperties()
  58371. {
  58372. $absolutePath = parent::current();
  58373. if ($this->baseDir === substr($absolutePath, 0, $this->baseDirLength)) {
  58374. $this->subPathname = ltrim(substr($absolutePath, $this->baseDirLength), '/\\');
  58375. $dir = \dirname($this->subPathname);
  58376. $this->subPath = '.' === $dir ? '' : $dir;
  58377. } else {
  58378. $this->subPath = $this->subPathname = '';
  58379. }
  58380. $this->current = new SplFileInfo(parent::current(), $this->subPath, $this->subPathname);
  58381. }
  58382. }
  58383. <?php
  58384. namespace Symfony\Component\Finder\Iterator;
  58385. class FileTypeFilterIterator extends FilterIterator
  58386. {
  58387. const ONLY_FILES = 1;
  58388. const ONLY_DIRECTORIES = 2;
  58389. private $mode;
  58390. public function __construct(\Iterator $iterator, $mode)
  58391. {
  58392. $this->mode = $mode;
  58393. parent::__construct($iterator);
  58394. }
  58395. public function accept()
  58396. {
  58397. $fileinfo = $this->current();
  58398. if (self::ONLY_DIRECTORIES === (self::ONLY_DIRECTORIES & $this->mode) && $fileinfo->isFile()) {
  58399. return false;
  58400. } elseif (self::ONLY_FILES === (self::ONLY_FILES & $this->mode) && $fileinfo->isDir()) {
  58401. return false;
  58402. }
  58403. return true;
  58404. }
  58405. }
  58406. <?php
  58407. namespace Symfony\Component\Finder\Iterator;
  58408. class FilecontentFilterIterator extends MultiplePcreFilterIterator
  58409. {
  58410. public function accept()
  58411. {
  58412. if (!$this->matchRegexps && !$this->noMatchRegexps) {
  58413. return true;
  58414. }
  58415. $fileinfo = $this->current();
  58416. if ($fileinfo->isDir() || !$fileinfo->isReadable()) {
  58417. return false;
  58418. }
  58419. $content = $fileinfo->getContents();
  58420. if (!$content) {
  58421. return false;
  58422. }
  58423. return $this->isAccepted($content);
  58424. }
  58425. protected function toRegex($str)
  58426. {
  58427. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  58428. }
  58429. }
  58430. <?php
  58431. namespace Symfony\Component\Finder\Iterator;
  58432. use Symfony\Component\Finder\Glob;
  58433. class FilenameFilterIterator extends MultiplePcreFilterIterator
  58434. {
  58435. public function accept()
  58436. {
  58437. return $this->isAccepted($this->current()->getFilename());
  58438. }
  58439. protected function toRegex($str)
  58440. {
  58441. return $this->isRegex($str) ? $str : Glob::toRegex($str);
  58442. }
  58443. }
  58444. <?php
  58445. namespace Symfony\Component\Finder\Iterator;
  58446. abstract class FilterIterator extends \FilterIterator
  58447. {
  58448. public function rewind()
  58449. {
  58450. if (\PHP_VERSION_ID > 50607 || (\PHP_VERSION_ID > 50523 && \PHP_VERSION_ID < 50600)) {
  58451. parent::rewind();
  58452. return;
  58453. }
  58454. $iterator = $this;
  58455. while ($iterator instanceof \OuterIterator) {
  58456. $innerIterator = $iterator->getInnerIterator();
  58457. if ($innerIterator instanceof RecursiveDirectoryIterator) {
  58458. if ($innerIterator->isRewindable()) {
  58459. $innerIterator->next();
  58460. $innerIterator->rewind();
  58461. }
  58462. } elseif ($innerIterator instanceof \FilesystemIterator) {
  58463. $innerIterator->next();
  58464. $innerIterator->rewind();
  58465. }
  58466. $iterator = $innerIterator;
  58467. }
  58468. parent::rewind();
  58469. }
  58470. }
  58471. <?php
  58472. namespace Symfony\Component\Finder\Iterator;
  58473. abstract class MultiplePcreFilterIterator extends FilterIterator
  58474. {
  58475. protected $matchRegexps = array();
  58476. protected $noMatchRegexps = array();
  58477. public function __construct(\Iterator $iterator, array $matchPatterns, array $noMatchPatterns)
  58478. {
  58479. foreach ($matchPatterns as $pattern) {
  58480. $this->matchRegexps[] = $this->toRegex($pattern);
  58481. }
  58482. foreach ($noMatchPatterns as $pattern) {
  58483. $this->noMatchRegexps[] = $this->toRegex($pattern);
  58484. }
  58485. parent::__construct($iterator);
  58486. }
  58487. protected function isAccepted($string)
  58488. {
  58489. foreach ($this->noMatchRegexps as $regex) {
  58490. if (preg_match($regex, $string)) {
  58491. return false;
  58492. }
  58493. }
  58494. if ($this->matchRegexps) {
  58495. foreach ($this->matchRegexps as $regex) {
  58496. if (preg_match($regex, $string)) {
  58497. return true;
  58498. }
  58499. }
  58500. return false;
  58501. }
  58502. return true;
  58503. }
  58504. protected function isRegex($str)
  58505. {
  58506. if (preg_match('/^(.{3,}?)[imsxuADU]*$/', $str, $m)) {
  58507. $start = substr($m[1], 0, 1);
  58508. $end = substr($m[1], -1);
  58509. if ($start === $end) {
  58510. return !preg_match('/[*?[:alnum:] \\\\]/', $start);
  58511. }
  58512. foreach (array(array('{', '}'), array('(', ')'), array('[', ']'), array('<', '>')) as $delimiters) {
  58513. if ($start === $delimiters[0] && $end === $delimiters[1]) {
  58514. return true;
  58515. }
  58516. }
  58517. }
  58518. return false;
  58519. }
  58520. abstract protected function toRegex($str);
  58521. }
  58522. <?php
  58523. namespace Symfony\Component\Finder\Iterator;
  58524. class PathFilterIterator extends MultiplePcreFilterIterator
  58525. {
  58526. public function accept()
  58527. {
  58528. $filename = $this->current()->getRelativePathname();
  58529. if ('\\' === \DIRECTORY_SEPARATOR) {
  58530. $filename = str_replace('\\', '/', $filename);
  58531. }
  58532. return $this->isAccepted($filename);
  58533. }
  58534. protected function toRegex($str)
  58535. {
  58536. return $this->isRegex($str) ? $str : '/'.preg_quote($str, '/').'/';
  58537. }
  58538. }
  58539. <?php
  58540. namespace Symfony\Component\Finder\Iterator;
  58541. use Symfony\Component\Finder\Exception\AccessDeniedException;
  58542. use Symfony\Component\Finder\SplFileInfo;
  58543. class RecursiveDirectoryIterator extends \RecursiveDirectoryIterator
  58544. {
  58545. private $ignoreUnreadableDirs;
  58546. private $rewindable;
  58547. private $rootPath;
  58548. private $subPath;
  58549. private $directorySeparator = '/';
  58550. public function __construct($path, $flags, $ignoreUnreadableDirs = false)
  58551. {
  58552. if ($flags & (self::CURRENT_AS_PATHNAME | self::CURRENT_AS_SELF)) {
  58553. throw new \RuntimeException('This iterator only support returning current as fileinfo.');
  58554. }
  58555. parent::__construct($path, $flags);
  58556. $this->ignoreUnreadableDirs = $ignoreUnreadableDirs;
  58557. $this->rootPath = (string) $path;
  58558. if ('/' !== \DIRECTORY_SEPARATOR && !($flags & self::UNIX_PATHS)) {
  58559. $this->directorySeparator = \DIRECTORY_SEPARATOR;
  58560. }
  58561. }
  58562. public function current()
  58563. {
  58564. if (null === $subPathname = $this->subPath) {
  58565. $subPathname = $this->subPath = (string) $this->getSubPath();
  58566. }
  58567. if ('' !== $subPathname) {
  58568. $subPathname .= $this->directorySeparator;
  58569. }
  58570. $subPathname .= $this->getFilename();
  58571. return new SplFileInfo($this->rootPath.$this->directorySeparator.$subPathname, $this->subPath, $subPathname);
  58572. }
  58573. public function getChildren()
  58574. {
  58575. try {
  58576. $children = parent::getChildren();
  58577. if ($children instanceof self) {
  58578. $children->ignoreUnreadableDirs = $this->ignoreUnreadableDirs;
  58579. $children->rewindable = &$this->rewindable;
  58580. $children->rootPath = $this->rootPath;
  58581. }
  58582. return $children;
  58583. } catch (\UnexpectedValueException $e) {
  58584. if ($this->ignoreUnreadableDirs) {
  58585. return new \RecursiveArrayIterator(array());
  58586. } else {
  58587. throw new AccessDeniedException($e->getMessage(), $e->getCode(), $e);
  58588. }
  58589. }
  58590. }
  58591. public function rewind()
  58592. {
  58593. if (false === $this->isRewindable()) {
  58594. return;
  58595. }
  58596. if (\PHP_VERSION_ID < 50523 || \PHP_VERSION_ID >= 50600 && \PHP_VERSION_ID < 50607) {
  58597. parent::next();
  58598. }
  58599. parent::rewind();
  58600. }
  58601. public function isRewindable()
  58602. {
  58603. if (null !== $this->rewindable) {
  58604. return $this->rewindable;
  58605. }
  58606. if ('' === $this->getPath()) {
  58607. return $this->rewindable = false;
  58608. }
  58609. if (false !== $stream = @opendir($this->getPath())) {
  58610. $infos = stream_get_meta_data($stream);
  58611. closedir($stream);
  58612. if ($infos['seekable']) {
  58613. return $this->rewindable = true;
  58614. }
  58615. }
  58616. return $this->rewindable = false;
  58617. }
  58618. }
  58619. <?php
  58620. namespace Symfony\Component\Finder\Iterator;
  58621. use Symfony\Component\Finder\Comparator\NumberComparator;
  58622. class SizeRangeFilterIterator extends FilterIterator
  58623. {
  58624. private $comparators = array();
  58625. public function __construct(\Iterator $iterator, array $comparators)
  58626. {
  58627. $this->comparators = $comparators;
  58628. parent::__construct($iterator);
  58629. }
  58630. public function accept()
  58631. {
  58632. $fileinfo = $this->current();
  58633. if (!$fileinfo->isFile()) {
  58634. return true;
  58635. }
  58636. $filesize = $fileinfo->getSize();
  58637. foreach ($this->comparators as $compare) {
  58638. if (!$compare->test($filesize)) {
  58639. return false;
  58640. }
  58641. }
  58642. return true;
  58643. }
  58644. }
  58645. <?php
  58646. namespace Symfony\Component\Finder\Iterator;
  58647. class SortableIterator implements \IteratorAggregate
  58648. {
  58649. const SORT_BY_NAME = 1;
  58650. const SORT_BY_TYPE = 2;
  58651. const SORT_BY_ACCESSED_TIME = 3;
  58652. const SORT_BY_CHANGED_TIME = 4;
  58653. const SORT_BY_MODIFIED_TIME = 5;
  58654. private $iterator;
  58655. private $sort;
  58656. public function __construct(\Traversable $iterator, $sort)
  58657. {
  58658. $this->iterator = $iterator;
  58659. if (self::SORT_BY_NAME === $sort) {
  58660. $this->sort = function ($a, $b) {
  58661. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  58662. };
  58663. } elseif (self::SORT_BY_TYPE === $sort) {
  58664. $this->sort = function ($a, $b) {
  58665. if ($a->isDir() && $b->isFile()) {
  58666. return -1;
  58667. } elseif ($a->isFile() && $b->isDir()) {
  58668. return 1;
  58669. }
  58670. return strcmp($a->getRealpath() ?: $a->getPathname(), $b->getRealpath() ?: $b->getPathname());
  58671. };
  58672. } elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
  58673. $this->sort = function ($a, $b) {
  58674. return $a->getATime() - $b->getATime();
  58675. };
  58676. } elseif (self::SORT_BY_CHANGED_TIME === $sort) {
  58677. $this->sort = function ($a, $b) {
  58678. return $a->getCTime() - $b->getCTime();
  58679. };
  58680. } elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
  58681. $this->sort = function ($a, $b) {
  58682. return $a->getMTime() - $b->getMTime();
  58683. };
  58684. } elseif (\is_callable($sort)) {
  58685. $this->sort = $sort;
  58686. } else {
  58687. throw new \InvalidArgumentException('The SortableIterator takes a PHP callable or a valid built-in sort algorithm as an argument.');
  58688. }
  58689. }
  58690. public function getIterator()
  58691. {
  58692. $array = iterator_to_array($this->iterator, true);
  58693. uasort($array, $this->sort);
  58694. return new \ArrayIterator($array);
  58695. }
  58696. }
  58697. Copyright (c) 2004-2018 Fabien Potencier
  58698. Permission is hereby granted, free of charge, to any person obtaining a copy
  58699. of this software and associated documentation files (the "Software"), to deal
  58700. in the Software without restriction, including without limitation the rights
  58701. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58702. copies of the Software, and to permit persons to whom the Software is furnished
  58703. to do so, subject to the following conditions:
  58704. The above copyright notice and this permission notice shall be included in all
  58705. copies or substantial portions of the Software.
  58706. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58707. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58708. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58709. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  58710. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58711. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  58712. THE SOFTWARE.
  58713. <?php
  58714. namespace Symfony\Component\Finder\Shell;
  58715. @trigger_error('The '.__NAMESPACE__.'\Command class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58716. class Command
  58717. {
  58718. private $parent;
  58719. private $bits = array();
  58720. private $labels = array();
  58721. private $errorHandler;
  58722. public function __construct(Command $parent = null)
  58723. {
  58724. $this->parent = $parent;
  58725. }
  58726. public function __toString()
  58727. {
  58728. return $this->join();
  58729. }
  58730. public static function create(Command $parent = null)
  58731. {
  58732. return new self($parent);
  58733. }
  58734. public static function escape($input)
  58735. {
  58736. return escapeshellcmd($input);
  58737. }
  58738. public static function quote($input)
  58739. {
  58740. return escapeshellarg($input);
  58741. }
  58742. public function add($bit)
  58743. {
  58744. $this->bits[] = $bit;
  58745. return $this;
  58746. }
  58747. public function top($bit)
  58748. {
  58749. array_unshift($this->bits, $bit);
  58750. foreach ($this->labels as $label => $index) {
  58751. ++$this->labels[$label];
  58752. }
  58753. return $this;
  58754. }
  58755. public function arg($arg)
  58756. {
  58757. $this->bits[] = self::quote($arg);
  58758. return $this;
  58759. }
  58760. public function cmd($esc)
  58761. {
  58762. $this->bits[] = self::escape($esc);
  58763. return $this;
  58764. }
  58765. public function ins($label)
  58766. {
  58767. if (isset($this->labels[$label])) {
  58768. throw new \RuntimeException(sprintf('Label "%s" already exists.', $label));
  58769. }
  58770. $this->bits[] = self::create($this);
  58771. $this->labels[$label] = \count($this->bits) - 1;
  58772. return $this->bits[$this->labels[$label]];
  58773. }
  58774. public function get($label)
  58775. {
  58776. if (!isset($this->labels[$label])) {
  58777. throw new \RuntimeException(sprintf('Label "%s" does not exist.', $label));
  58778. }
  58779. return $this->bits[$this->labels[$label]];
  58780. }
  58781. public function end()
  58782. {
  58783. if (null === $this->parent) {
  58784. throw new \RuntimeException('Calling end on root command doesn\'t make sense.');
  58785. }
  58786. return $this->parent;
  58787. }
  58788. public function length()
  58789. {
  58790. return \count($this->bits);
  58791. }
  58792. public function setErrorHandler(\Closure $errorHandler)
  58793. {
  58794. $this->errorHandler = $errorHandler;
  58795. return $this;
  58796. }
  58797. public function getErrorHandler()
  58798. {
  58799. return $this->errorHandler;
  58800. }
  58801. public function execute()
  58802. {
  58803. if (null === $errorHandler = $this->errorHandler) {
  58804. exec($this->join(), $output);
  58805. } else {
  58806. $process = proc_open($this->join(), array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
  58807. $output = preg_split('~(\r\n|\r|\n)~', stream_get_contents($pipes[1]), -1, PREG_SPLIT_NO_EMPTY);
  58808. if ($error = stream_get_contents($pipes[2])) {
  58809. $errorHandler($error);
  58810. }
  58811. proc_close($process);
  58812. }
  58813. return $output ?: array();
  58814. }
  58815. public function join()
  58816. {
  58817. return implode(' ', array_filter(
  58818. array_map(function ($bit) {
  58819. return $bit instanceof Command ? $bit->join() : ($bit ?: null);
  58820. }, $this->bits),
  58821. function ($bit) { return null !== $bit; }
  58822. ));
  58823. }
  58824. public function addAtIndex($bit, $index)
  58825. {
  58826. array_splice($this->bits, $index, 0, $bit instanceof self ? array($bit) : $bit);
  58827. return $this;
  58828. }
  58829. }
  58830. <?php
  58831. namespace Symfony\Component\Finder\Shell;
  58832. @trigger_error('The '.__NAMESPACE__.'\Shell class is deprecated since Symfony 2.8 and will be removed in 3.0.', E_USER_DEPRECATED);
  58833. class Shell
  58834. {
  58835. const TYPE_UNIX = 1;
  58836. const TYPE_DARWIN = 2;
  58837. const TYPE_CYGWIN = 3;
  58838. const TYPE_WINDOWS = 4;
  58839. const TYPE_BSD = 5;
  58840. private $type;
  58841. public function getType()
  58842. {
  58843. if (null === $this->type) {
  58844. $this->type = $this->guessType();
  58845. }
  58846. return $this->type;
  58847. }
  58848. public function testCommand($command)
  58849. {
  58850. if (!\function_exists('exec')) {
  58851. return false;
  58852. }
  58853. $testCommand = 'which ';
  58854. if (self::TYPE_WINDOWS === $this->type) {
  58855. $testCommand = 'where ';
  58856. }
  58857. $command = escapeshellcmd($command);
  58858. exec($testCommand.$command, $output, $code);
  58859. return 0 === $code && \count($output) > 0;
  58860. }
  58861. private function guessType()
  58862. {
  58863. $os = strtolower(PHP_OS);
  58864. if (false !== strpos($os, 'cygwin')) {
  58865. return self::TYPE_CYGWIN;
  58866. }
  58867. if (false !== strpos($os, 'darwin')) {
  58868. return self::TYPE_DARWIN;
  58869. }
  58870. if (false !== strpos($os, 'bsd')) {
  58871. return self::TYPE_BSD;
  58872. }
  58873. if (0 === strpos($os, 'win')) {
  58874. return self::TYPE_WINDOWS;
  58875. }
  58876. return self::TYPE_UNIX;
  58877. }
  58878. }
  58879. <?php
  58880. namespace Symfony\Component\Finder;
  58881. class SplFileInfo extends \SplFileInfo
  58882. {
  58883. private $relativePath;
  58884. private $relativePathname;
  58885. public function __construct($file, $relativePath, $relativePathname)
  58886. {
  58887. parent::__construct($file);
  58888. $this->relativePath = $relativePath;
  58889. $this->relativePathname = $relativePathname;
  58890. }
  58891. public function getRelativePath()
  58892. {
  58893. return $this->relativePath;
  58894. }
  58895. public function getRelativePathname()
  58896. {
  58897. return $this->relativePathname;
  58898. }
  58899. public function getContents()
  58900. {
  58901. set_error_handler(function ($type, $msg) use (&$error) { $error = $msg; });
  58902. $content = file_get_contents($this->getPathname());
  58903. restore_error_handler();
  58904. if (false === $content) {
  58905. throw new \RuntimeException($error);
  58906. }
  58907. return $content;
  58908. }
  58909. }
  58910. <?php
  58911. namespace Symfony\Polyfill\Ctype;
  58912. final class Ctype
  58913. {
  58914. public static function ctype_alnum($text)
  58915. {
  58916. $text = self::convert_int_to_char_for_ctype($text);
  58917. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text);
  58918. }
  58919. public static function ctype_alpha($text)
  58920. {
  58921. $text = self::convert_int_to_char_for_ctype($text);
  58922. return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text);
  58923. }
  58924. public static function ctype_cntrl($text)
  58925. {
  58926. $text = self::convert_int_to_char_for_ctype($text);
  58927. return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text);
  58928. }
  58929. public static function ctype_digit($text)
  58930. {
  58931. $text = self::convert_int_to_char_for_ctype($text);
  58932. return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text);
  58933. }
  58934. public static function ctype_graph($text)
  58935. {
  58936. $text = self::convert_int_to_char_for_ctype($text);
  58937. return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text);
  58938. }
  58939. public static function ctype_lower($text)
  58940. {
  58941. $text = self::convert_int_to_char_for_ctype($text);
  58942. return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text);
  58943. }
  58944. public static function ctype_print($text)
  58945. {
  58946. $text = self::convert_int_to_char_for_ctype($text);
  58947. return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text);
  58948. }
  58949. public static function ctype_punct($text)
  58950. {
  58951. $text = self::convert_int_to_char_for_ctype($text);
  58952. return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text);
  58953. }
  58954. public static function ctype_space($text)
  58955. {
  58956. $text = self::convert_int_to_char_for_ctype($text);
  58957. return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text);
  58958. }
  58959. public static function ctype_upper($text)
  58960. {
  58961. $text = self::convert_int_to_char_for_ctype($text);
  58962. return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text);
  58963. }
  58964. public static function ctype_xdigit($text)
  58965. {
  58966. $text = self::convert_int_to_char_for_ctype($text);
  58967. return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text);
  58968. }
  58969. private static function convert_int_to_char_for_ctype($int)
  58970. {
  58971. if (!\is_int($int)) {
  58972. return $int;
  58973. }
  58974. if ($int < -128 || $int > 255) {
  58975. return (string) $int;
  58976. }
  58977. if ($int < 0) {
  58978. $int += 256;
  58979. }
  58980. return \chr($int);
  58981. }
  58982. }
  58983. Copyright (c) 2018-2019 Fabien Potencier
  58984. Permission is hereby granted, free of charge, to any person obtaining a copy
  58985. of this software and associated documentation files (the "Software"), to deal
  58986. in the Software without restriction, including without limitation the rights
  58987. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  58988. copies of the Software, and to permit persons to whom the Software is furnished
  58989. to do so, subject to the following conditions:
  58990. The above copyright notice and this permission notice shall be included in all
  58991. copies or substantial portions of the Software.
  58992. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  58993. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  58994. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58995. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  58996. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  58997. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  58998. THE SOFTWARE.
  58999. <?php
  59000. use Symfony\Polyfill\Ctype as p;
  59001. if (!function_exists('ctype_alnum')) {
  59002. function ctype_alnum($input) { return p\Ctype::ctype_alnum($input); }
  59003. }
  59004. if (!function_exists('ctype_alpha')) {
  59005. function ctype_alpha($input) { return p\Ctype::ctype_alpha($input); }
  59006. }
  59007. if (!function_exists('ctype_cntrl')) {
  59008. function ctype_cntrl($input) { return p\Ctype::ctype_cntrl($input); }
  59009. }
  59010. if (!function_exists('ctype_digit')) {
  59011. function ctype_digit($input) { return p\Ctype::ctype_digit($input); }
  59012. }
  59013. if (!function_exists('ctype_graph')) {
  59014. function ctype_graph($input) { return p\Ctype::ctype_graph($input); }
  59015. }
  59016. if (!function_exists('ctype_lower')) {
  59017. function ctype_lower($input) { return p\Ctype::ctype_lower($input); }
  59018. }
  59019. if (!function_exists('ctype_print')) {
  59020. function ctype_print($input) { return p\Ctype::ctype_print($input); }
  59021. }
  59022. if (!function_exists('ctype_punct')) {
  59023. function ctype_punct($input) { return p\Ctype::ctype_punct($input); }
  59024. }
  59025. if (!function_exists('ctype_space')) {
  59026. function ctype_space($input) { return p\Ctype::ctype_space($input); }
  59027. }
  59028. if (!function_exists('ctype_upper')) {
  59029. function ctype_upper($input) { return p\Ctype::ctype_upper($input); }
  59030. }
  59031. if (!function_exists('ctype_xdigit')) {
  59032. function ctype_xdigit($input) { return p\Ctype::ctype_xdigit($input); }
  59033. }
  59034. Copyright (c) 2015-2019 Fabien Potencier
  59035. Permission is hereby granted, free of charge, to any person obtaining a copy
  59036. of this software and associated documentation files (the "Software"), to deal
  59037. in the Software without restriction, including without limitation the rights
  59038. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  59039. copies of the Software, and to permit persons to whom the Software is furnished
  59040. to do so, subject to the following conditions:
  59041. The above copyright notice and this permission notice shall be included in all
  59042. copies or substantial portions of the Software.
  59043. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  59044. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  59045. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  59046. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  59047. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  59048. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  59049. THE SOFTWARE.
  59050. <?php
  59051. namespace Symfony\Polyfill\Mbstring;
  59052. final class Mbstring
  59053. {
  59054. const MB_CASE_FOLD = PHP_INT_MAX;
  59055. private static $encodingList = array('ASCII', 'UTF-8');
  59056. private static $language = 'neutral';
  59057. private static $internalEncoding = 'UTF-8';
  59058. private static $caseFold = array(
  59059. array('µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"),
  59060. array('μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', '�', 'ε', "\xE1\xB9\xA1", 'ι'),
  59061. );
  59062. public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
  59063. {
  59064. if (\is_array($fromEncoding) || false !== strpos($fromEncoding, ',')) {
  59065. $fromEncoding = self::mb_detect_encoding($s, $fromEncoding);
  59066. } else {
  59067. $fromEncoding = self::getEncoding($fromEncoding);
  59068. }
  59069. $toEncoding = self::getEncoding($toEncoding);
  59070. if ('BASE64' === $fromEncoding) {
  59071. $s = base64_decode($s);
  59072. $fromEncoding = $toEncoding;
  59073. }
  59074. if ('BASE64' === $toEncoding) {
  59075. return base64_encode($s);
  59076. }
  59077. if ('HTML-ENTITIES' === $toEncoding || 'HTML' === $toEncoding) {
  59078. if ('HTML-ENTITIES' === $fromEncoding || 'HTML' === $fromEncoding) {
  59079. $fromEncoding = 'Windows-1252';
  59080. }
  59081. if ('UTF-8' !== $fromEncoding) {
  59082. $s = iconv($fromEncoding, 'UTF-8//IGNORE', $s);
  59083. }
  59084. return preg_replace_callback('/[\x80-\xFF]+/', array(__CLASS__, 'html_encoding_callback'), $s);
  59085. }
  59086. if ('HTML-ENTITIES' === $fromEncoding) {
  59087. $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8');
  59088. $fromEncoding = 'UTF-8';
  59089. }
  59090. return iconv($fromEncoding, $toEncoding.'//IGNORE', $s);
  59091. }
  59092. public static function mb_convert_variables($toEncoding, $fromEncoding, &$a = null, &$b = null, &$c = null, &$d = null, &$e = null, &$f = null)
  59093. {
  59094. $vars = array(&$a, &$b, &$c, &$d, &$e, &$f);
  59095. $ok = true;
  59096. array_walk_recursive($vars, function (&$v) use (&$ok, $toEncoding, $fromEncoding) {
  59097. if (false === $v = Mbstring::mb_convert_encoding($v, $toEncoding, $fromEncoding)) {
  59098. $ok = false;
  59099. }
  59100. });
  59101. return $ok ? $fromEncoding : false;
  59102. }
  59103. public static function mb_decode_mimeheader($s)
  59104. {
  59105. return iconv_mime_decode($s, 2, self::$internalEncoding);
  59106. }
  59107. public static function mb_encode_mimeheader($s, $charset = null, $transferEncoding = null, $linefeed = null, $indent = null)
  59108. {
  59109. trigger_error('mb_encode_mimeheader() is bugged. Please use iconv_mime_encode() instead', E_USER_WARNING);
  59110. }
  59111. public static function mb_decode_numericentity($s, $convmap, $encoding = null)
  59112. {
  59113. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  59114. trigger_error('mb_decode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59115. return null;
  59116. }
  59117. if (!\is_array($convmap) || !$convmap) {
  59118. return false;
  59119. }
  59120. if (null !== $encoding && !\is_scalar($encoding)) {
  59121. trigger_error('mb_decode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59122. return '';
  59123. }
  59124. $s = (string) $s;
  59125. if ('' === $s) {
  59126. return '';
  59127. }
  59128. $encoding = self::getEncoding($encoding);
  59129. if ('UTF-8' === $encoding) {
  59130. $encoding = null;
  59131. if (!preg_match('//u', $s)) {
  59132. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  59133. }
  59134. } else {
  59135. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59136. }
  59137. $cnt = floor(\count($convmap) / 4) * 4;
  59138. for ($i = 0; $i < $cnt; $i += 4) {
  59139. $convmap[$i] += $convmap[$i + 2];
  59140. $convmap[$i + 1] += $convmap[$i + 2];
  59141. }
  59142. $s = preg_replace_callback('/&#(?:0*([0-9]+)|x0*([0-9a-fA-F]+))(?!&);?/', function (array $m) use ($cnt, $convmap) {
  59143. $c = isset($m[2]) ? (int) hexdec($m[2]) : $m[1];
  59144. for ($i = 0; $i < $cnt; $i += 4) {
  59145. if ($c >= $convmap[$i] && $c <= $convmap[$i + 1]) {
  59146. return Mbstring::mb_chr($c - $convmap[$i + 2]);
  59147. }
  59148. }
  59149. return $m[0];
  59150. }, $s);
  59151. if (null === $encoding) {
  59152. return $s;
  59153. }
  59154. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  59155. }
  59156. public static function mb_encode_numericentity($s, $convmap, $encoding = null, $is_hex = false)
  59157. {
  59158. if (null !== $s && !\is_scalar($s) && !(\is_object($s) && \method_exists($s, '__toString'))) {
  59159. trigger_error('mb_encode_numericentity() expects parameter 1 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59160. return null;
  59161. }
  59162. if (!\is_array($convmap) || !$convmap) {
  59163. return false;
  59164. }
  59165. if (null !== $encoding && !\is_scalar($encoding)) {
  59166. trigger_error('mb_encode_numericentity() expects parameter 3 to be string, '.\gettype($s).' given', E_USER_WARNING);
  59167. return null;
  59168. }
  59169. if (null !== $is_hex && !\is_scalar($is_hex)) {
  59170. trigger_error('mb_encode_numericentity() expects parameter 4 to be boolean, '.\gettype($s).' given', E_USER_WARNING);
  59171. return null;
  59172. }
  59173. $s = (string) $s;
  59174. if ('' === $s) {
  59175. return '';
  59176. }
  59177. $encoding = self::getEncoding($encoding);
  59178. if ('UTF-8' === $encoding) {
  59179. $encoding = null;
  59180. if (!preg_match('//u', $s)) {
  59181. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  59182. }
  59183. } else {
  59184. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59185. }
  59186. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  59187. $cnt = floor(\count($convmap) / 4) * 4;
  59188. $i = 0;
  59189. $len = \strlen($s);
  59190. $result = '';
  59191. while ($i < $len) {
  59192. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  59193. $uchr = substr($s, $i, $ulen);
  59194. $i += $ulen;
  59195. $c = self::mb_ord($uchr);
  59196. for ($j = 0; $j < $cnt; $j += 4) {
  59197. if ($c >= $convmap[$j] && $c <= $convmap[$j + 1]) {
  59198. $cOffset = ($c + $convmap[$j + 2]) & $convmap[$j + 3];
  59199. $result .= $is_hex ? sprintf('&#x%X;', $cOffset) : '&#'.$cOffset.';';
  59200. continue 2;
  59201. }
  59202. }
  59203. $result .= $uchr;
  59204. }
  59205. if (null === $encoding) {
  59206. return $result;
  59207. }
  59208. return iconv('UTF-8', $encoding.'//IGNORE', $result);
  59209. }
  59210. public static function mb_convert_case($s, $mode, $encoding = null)
  59211. {
  59212. $s = (string) $s;
  59213. if ('' === $s) {
  59214. return '';
  59215. }
  59216. $encoding = self::getEncoding($encoding);
  59217. if ('UTF-8' === $encoding) {
  59218. $encoding = null;
  59219. if (!preg_match('//u', $s)) {
  59220. $s = @iconv('UTF-8', 'UTF-8//IGNORE', $s);
  59221. }
  59222. } else {
  59223. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59224. }
  59225. if (MB_CASE_TITLE == $mode) {
  59226. static $titleRegexp = null;
  59227. if (null === $titleRegexp) {
  59228. $titleRegexp = self::getData('titleCaseRegexp');
  59229. }
  59230. $s = preg_replace_callback($titleRegexp, array(__CLASS__, 'title_case'), $s);
  59231. } else {
  59232. if (MB_CASE_UPPER == $mode) {
  59233. static $upper = null;
  59234. if (null === $upper) {
  59235. $upper = self::getData('upperCase');
  59236. }
  59237. $map = $upper;
  59238. } else {
  59239. if (self::MB_CASE_FOLD === $mode) {
  59240. $s = str_replace(self::$caseFold[0], self::$caseFold[1], $s);
  59241. }
  59242. static $lower = null;
  59243. if (null === $lower) {
  59244. $lower = self::getData('lowerCase');
  59245. }
  59246. $map = $lower;
  59247. }
  59248. static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4);
  59249. $i = 0;
  59250. $len = \strlen($s);
  59251. while ($i < $len) {
  59252. $ulen = $s[$i] < "\x80" ? 1 : $ulenMask[$s[$i] & "\xF0"];
  59253. $uchr = substr($s, $i, $ulen);
  59254. $i += $ulen;
  59255. if (isset($map[$uchr])) {
  59256. $uchr = $map[$uchr];
  59257. $nlen = \strlen($uchr);
  59258. if ($nlen == $ulen) {
  59259. $nlen = $i;
  59260. do {
  59261. $s[--$nlen] = $uchr[--$ulen];
  59262. } while ($ulen);
  59263. } else {
  59264. $s = substr_replace($s, $uchr, $i - $ulen, $ulen);
  59265. $len += $nlen - $ulen;
  59266. $i += $nlen - $ulen;
  59267. }
  59268. }
  59269. }
  59270. }
  59271. if (null === $encoding) {
  59272. return $s;
  59273. }
  59274. return iconv('UTF-8', $encoding.'//IGNORE', $s);
  59275. }
  59276. public static function mb_internal_encoding($encoding = null)
  59277. {
  59278. if (null === $encoding) {
  59279. return self::$internalEncoding;
  59280. }
  59281. $encoding = self::getEncoding($encoding);
  59282. if ('UTF-8' === $encoding || false !== @iconv($encoding, $encoding, ' ')) {
  59283. self::$internalEncoding = $encoding;
  59284. return true;
  59285. }
  59286. return false;
  59287. }
  59288. public static function mb_language($lang = null)
  59289. {
  59290. if (null === $lang) {
  59291. return self::$language;
  59292. }
  59293. switch ($lang = strtolower($lang)) {
  59294. case 'uni':
  59295. case 'neutral':
  59296. self::$language = $lang;
  59297. return true;
  59298. }
  59299. return false;
  59300. }
  59301. public static function mb_list_encodings()
  59302. {
  59303. return array('UTF-8');
  59304. }
  59305. public static function mb_encoding_aliases($encoding)
  59306. {
  59307. switch (strtoupper($encoding)) {
  59308. case 'UTF8':
  59309. case 'UTF-8':
  59310. return array('utf8');
  59311. }
  59312. return false;
  59313. }
  59314. public static function mb_check_encoding($var = null, $encoding = null)
  59315. {
  59316. if (null === $encoding) {
  59317. if (null === $var) {
  59318. return false;
  59319. }
  59320. $encoding = self::$internalEncoding;
  59321. }
  59322. return self::mb_detect_encoding($var, array($encoding)) || false !== @iconv($encoding, $encoding, $var);
  59323. }
  59324. public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
  59325. {
  59326. if (null === $encodingList) {
  59327. $encodingList = self::$encodingList;
  59328. } else {
  59329. if (!\is_array($encodingList)) {
  59330. $encodingList = array_map('trim', explode(',', $encodingList));
  59331. }
  59332. $encodingList = array_map('strtoupper', $encodingList);
  59333. }
  59334. foreach ($encodingList as $enc) {
  59335. switch ($enc) {
  59336. case 'ASCII':
  59337. if (!preg_match('/[\x80-\xFF]/', $str)) {
  59338. return $enc;
  59339. }
  59340. break;
  59341. case 'UTF8':
  59342. case 'UTF-8':
  59343. if (preg_match('//u', $str)) {
  59344. return 'UTF-8';
  59345. }
  59346. break;
  59347. default:
  59348. if (0 === strncmp($enc, 'ISO-8859-', 9)) {
  59349. return $enc;
  59350. }
  59351. }
  59352. }
  59353. return false;
  59354. }
  59355. public static function mb_detect_order($encodingList = null)
  59356. {
  59357. if (null === $encodingList) {
  59358. return self::$encodingList;
  59359. }
  59360. if (!\is_array($encodingList)) {
  59361. $encodingList = array_map('trim', explode(',', $encodingList));
  59362. }
  59363. $encodingList = array_map('strtoupper', $encodingList);
  59364. foreach ($encodingList as $enc) {
  59365. switch ($enc) {
  59366. default:
  59367. if (strncmp($enc, 'ISO-8859-', 9)) {
  59368. return false;
  59369. }
  59370. case 'ASCII':
  59371. case 'UTF8':
  59372. case 'UTF-8':
  59373. }
  59374. }
  59375. self::$encodingList = $encodingList;
  59376. return true;
  59377. }
  59378. public static function mb_strlen($s, $encoding = null)
  59379. {
  59380. $encoding = self::getEncoding($encoding);
  59381. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59382. return \strlen($s);
  59383. }
  59384. return @iconv_strlen($s, $encoding);
  59385. }
  59386. public static function mb_strpos($haystack, $needle, $offset = 0, $encoding = null)
  59387. {
  59388. $encoding = self::getEncoding($encoding);
  59389. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59390. return strpos($haystack, $needle, $offset);
  59391. }
  59392. $needle = (string) $needle;
  59393. if ('' === $needle) {
  59394. trigger_error(__METHOD__.': Empty delimiter', E_USER_WARNING);
  59395. return false;
  59396. }
  59397. return iconv_strpos($haystack, $needle, $offset, $encoding);
  59398. }
  59399. public static function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null)
  59400. {
  59401. $encoding = self::getEncoding($encoding);
  59402. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59403. return strrpos($haystack, $needle, $offset);
  59404. }
  59405. if ($offset != (int) $offset) {
  59406. $offset = 0;
  59407. } elseif ($offset = (int) $offset) {
  59408. if ($offset < 0) {
  59409. if (0 > $offset += self::mb_strlen($needle)) {
  59410. $haystack = self::mb_substr($haystack, 0, $offset, $encoding);
  59411. }
  59412. $offset = 0;
  59413. } else {
  59414. $haystack = self::mb_substr($haystack, $offset, 2147483647, $encoding);
  59415. }
  59416. }
  59417. $pos = iconv_strrpos($haystack, $needle, $encoding);
  59418. return false !== $pos ? $offset + $pos : false;
  59419. }
  59420. public static function mb_str_split($string, $split_length = 1, $encoding = null)
  59421. {
  59422. if (null !== $string && !\is_scalar($string) && !(\is_object($string) && \method_exists($string, '__toString'))) {
  59423. trigger_error('mb_str_split() expects parameter 1 to be string, '.\gettype($string).' given', E_USER_WARNING);
  59424. return null;
  59425. }
  59426. if (1 > $split_length = (int) $split_length) {
  59427. trigger_error('The length of each segment must be greater than zero', E_USER_WARNING);
  59428. return false;
  59429. }
  59430. if (null === $encoding) {
  59431. $encoding = mb_internal_encoding();
  59432. }
  59433. if ('UTF-8' === $encoding = self::getEncoding($encoding)) {
  59434. $rx = '/(';
  59435. while (65535 < $split_length) {
  59436. $rx .= '.{65535}';
  59437. $split_length -= 65535;
  59438. }
  59439. $rx .= '.{'.$split_length.'})/us';
  59440. return preg_split($rx, $string, null, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
  59441. }
  59442. $result = array();
  59443. $length = mb_strlen($string, $encoding);
  59444. for ($i = 0; $i < $length; $i += $split_length) {
  59445. $result[] = mb_substr($string, $i, $split_length, $encoding);
  59446. }
  59447. return $result;
  59448. }
  59449. public static function mb_strtolower($s, $encoding = null)
  59450. {
  59451. return self::mb_convert_case($s, MB_CASE_LOWER, $encoding);
  59452. }
  59453. public static function mb_strtoupper($s, $encoding = null)
  59454. {
  59455. return self::mb_convert_case($s, MB_CASE_UPPER, $encoding);
  59456. }
  59457. public static function mb_substitute_character($c = null)
  59458. {
  59459. if (0 === strcasecmp($c, 'none')) {
  59460. return true;
  59461. }
  59462. return null !== $c ? false : 'none';
  59463. }
  59464. public static function mb_substr($s, $start, $length = null, $encoding = null)
  59465. {
  59466. $encoding = self::getEncoding($encoding);
  59467. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59468. return (string) substr($s, $start, null === $length ? 2147483647 : $length);
  59469. }
  59470. if ($start < 0) {
  59471. $start = iconv_strlen($s, $encoding) + $start;
  59472. if ($start < 0) {
  59473. $start = 0;
  59474. }
  59475. }
  59476. if (null === $length) {
  59477. $length = 2147483647;
  59478. } elseif ($length < 0) {
  59479. $length = iconv_strlen($s, $encoding) + $length - $start;
  59480. if ($length < 0) {
  59481. return '';
  59482. }
  59483. }
  59484. return (string) iconv_substr($s, $start, $length, $encoding);
  59485. }
  59486. public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
  59487. {
  59488. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  59489. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  59490. return self::mb_strpos($haystack, $needle, $offset, $encoding);
  59491. }
  59492. public static function mb_stristr($haystack, $needle, $part = false, $encoding = null)
  59493. {
  59494. $pos = self::mb_stripos($haystack, $needle, 0, $encoding);
  59495. return self::getSubpart($pos, $part, $haystack, $encoding);
  59496. }
  59497. public static function mb_strrchr($haystack, $needle, $part = false, $encoding = null)
  59498. {
  59499. $encoding = self::getEncoding($encoding);
  59500. if ('CP850' === $encoding || 'ASCII' === $encoding) {
  59501. $pos = strrpos($haystack, $needle);
  59502. } else {
  59503. $needle = self::mb_substr($needle, 0, 1, $encoding);
  59504. $pos = iconv_strrpos($haystack, $needle, $encoding);
  59505. }
  59506. return self::getSubpart($pos, $part, $haystack, $encoding);
  59507. }
  59508. public static function mb_strrichr($haystack, $needle, $part = false, $encoding = null)
  59509. {
  59510. $needle = self::mb_substr($needle, 0, 1, $encoding);
  59511. $pos = self::mb_strripos($haystack, $needle, $encoding);
  59512. return self::getSubpart($pos, $part, $haystack, $encoding);
  59513. }
  59514. public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
  59515. {
  59516. $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
  59517. $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
  59518. return self::mb_strrpos($haystack, $needle, $offset, $encoding);
  59519. }
  59520. public static function mb_strstr($haystack, $needle, $part = false, $encoding = null)
  59521. {
  59522. $pos = strpos($haystack, $needle);
  59523. if (false === $pos) {
  59524. return false;
  59525. }
  59526. if ($part) {
  59527. return substr($haystack, 0, $pos);
  59528. }
  59529. return substr($haystack, $pos);
  59530. }
  59531. public static function mb_get_info($type = 'all')
  59532. {
  59533. $info = array(
  59534. 'internal_encoding' => self::$internalEncoding,
  59535. 'http_output' => 'pass',
  59536. 'http_output_conv_mimetypes' => '^(text/|application/xhtml\+xml)',
  59537. 'func_overload' => 0,
  59538. 'func_overload_list' => 'no overload',
  59539. 'mail_charset' => 'UTF-8',
  59540. 'mail_header_encoding' => 'BASE64',
  59541. 'mail_body_encoding' => 'BASE64',
  59542. 'illegal_chars' => 0,
  59543. 'encoding_translation' => 'Off',
  59544. 'language' => self::$language,
  59545. 'detect_order' => self::$encodingList,
  59546. 'substitute_character' => 'none',
  59547. 'strict_detection' => 'Off',
  59548. );
  59549. if ('all' === $type) {
  59550. return $info;
  59551. }
  59552. if (isset($info[$type])) {
  59553. return $info[$type];
  59554. }
  59555. return false;
  59556. }
  59557. public static function mb_http_input($type = '')
  59558. {
  59559. return false;
  59560. }
  59561. public static function mb_http_output($encoding = null)
  59562. {
  59563. return null !== $encoding ? 'pass' === $encoding : 'pass';
  59564. }
  59565. public static function mb_strwidth($s, $encoding = null)
  59566. {
  59567. $encoding = self::getEncoding($encoding);
  59568. if ('UTF-8' !== $encoding) {
  59569. $s = iconv($encoding, 'UTF-8//IGNORE', $s);
  59570. }
  59571. $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);
  59572. return ($wide << 1) + iconv_strlen($s, 'UTF-8');
  59573. }
  59574. public static function mb_substr_count($haystack, $needle, $encoding = null)
  59575. {
  59576. return substr_count($haystack, $needle);
  59577. }
  59578. public static function mb_output_handler($contents, $status)
  59579. {
  59580. return $contents;
  59581. }
  59582. public static function mb_chr($code, $encoding = null)
  59583. {
  59584. if (0x80 > $code %= 0x200000) {
  59585. $s = \chr($code);
  59586. } elseif (0x800 > $code) {
  59587. $s = \chr(0xC0 | $code >> 6).\chr(0x80 | $code & 0x3F);
  59588. } elseif (0x10000 > $code) {
  59589. $s = \chr(0xE0 | $code >> 12).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  59590. } else {
  59591. $s = \chr(0xF0 | $code >> 18).\chr(0x80 | $code >> 12 & 0x3F).\chr(0x80 | $code >> 6 & 0x3F).\chr(0x80 | $code & 0x3F);
  59592. }
  59593. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  59594. $s = mb_convert_encoding($s, $encoding, 'UTF-8');
  59595. }
  59596. return $s;
  59597. }
  59598. public static function mb_ord($s, $encoding = null)
  59599. {
  59600. if ('UTF-8' !== $encoding = self::getEncoding($encoding)) {
  59601. $s = mb_convert_encoding($s, 'UTF-8', $encoding);
  59602. }
  59603. if (1 === \strlen($s)) {
  59604. return \ord($s);
  59605. }
  59606. $code = ($s = unpack('C*', substr($s, 0, 4))) ? $s[1] : 0;
  59607. if (0xF0 <= $code) {
  59608. return (($code - 0xF0) << 18) + (($s[2] - 0x80) << 12) + (($s[3] - 0x80) << 6) + $s[4] - 0x80;
  59609. }
  59610. if (0xE0 <= $code) {
  59611. return (($code - 0xE0) << 12) + (($s[2] - 0x80) << 6) + $s[3] - 0x80;
  59612. }
  59613. if (0xC0 <= $code) {
  59614. return (($code - 0xC0) << 6) + $s[2] - 0x80;
  59615. }
  59616. return $code;
  59617. }
  59618. private static function getSubpart($pos, $part, $haystack, $encoding)
  59619. {
  59620. if (false === $pos) {
  59621. return false;
  59622. }
  59623. if ($part) {
  59624. return self::mb_substr($haystack, 0, $pos, $encoding);
  59625. }
  59626. return self::mb_substr($haystack, $pos, null, $encoding);
  59627. }
  59628. private static function html_encoding_callback(array $m)
  59629. {
  59630. $i = 1;
  59631. $entities = '';
  59632. $m = unpack('C*', htmlentities($m[0], ENT_COMPAT, 'UTF-8'));
  59633. while (isset($m[$i])) {
  59634. if (0x80 > $m[$i]) {
  59635. $entities .= \chr($m[$i++]);
  59636. continue;
  59637. }
  59638. if (0xF0 <= $m[$i]) {
  59639. $c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  59640. } elseif (0xE0 <= $m[$i]) {
  59641. $c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
  59642. } else {
  59643. $c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
  59644. }
  59645. $entities .= '&#'.$c.';';
  59646. }
  59647. return $entities;
  59648. }
  59649. private static function title_case(array $s)
  59650. {
  59651. return self::mb_convert_case($s[1], MB_CASE_UPPER, 'UTF-8').self::mb_convert_case($s[2], MB_CASE_LOWER, 'UTF-8');
  59652. }
  59653. private static function getData($file)
  59654. {
  59655. if (file_exists($file = __DIR__.'/Resources/unidata/'.$file.'.php')) {
  59656. return require $file;
  59657. }
  59658. return false;
  59659. }
  59660. private static function getEncoding($encoding)
  59661. {
  59662. if (null === $encoding) {
  59663. return self::$internalEncoding;
  59664. }
  59665. if ('UTF-8' === $encoding) {
  59666. return 'UTF-8';
  59667. }
  59668. $encoding = strtoupper($encoding);
  59669. if ('8BIT' === $encoding || 'BINARY' === $encoding) {
  59670. return 'CP850';
  59671. }
  59672. if ('UTF8' === $encoding) {
  59673. return 'UTF-8';
  59674. }
  59675. return $encoding;
  59676. }
  59677. }
  59678. <?php
  59679. use Symfony\Polyfill\Mbstring as p;
  59680. if (!function_exists('mb_convert_variables')) {
  59681. function mb_convert_variables($to_encoding, $from_encoding, &$var, &...$vars)
  59682. {
  59683. $vars = [&$var, ...$vars];
  59684. $ok = true;
  59685. array_walk_recursive($vars, function (&$v) use (&$ok, $to_encoding, $from_encoding) {
  59686. if (false === $v = p\Mbstring::mb_convert_encoding($v, $to_encoding, $from_encoding)) {
  59687. $ok = false;
  59688. }
  59689. });
  59690. return $ok ? $from_encoding : false;
  59691. }
  59692. }
  59693. <?php
  59694. return array (
  59695. 'A' => 'a',
  59696. 'B' => 'b',
  59697. 'C' => 'c',
  59698. 'D' => 'd',
  59699. 'E' => 'e',
  59700. 'F' => 'f',
  59701. 'G' => 'g',
  59702. 'H' => 'h',
  59703. 'I' => 'i',
  59704. 'J' => 'j',
  59705. 'K' => 'k',
  59706. 'L' => 'l',
  59707. 'M' => 'm',
  59708. 'N' => 'n',
  59709. 'O' => 'o',
  59710. 'P' => 'p',
  59711. 'Q' => 'q',
  59712. 'R' => 'r',
  59713. 'S' => 's',
  59714. 'T' => 't',
  59715. 'U' => 'u',
  59716. 'V' => 'v',
  59717. 'W' => 'w',
  59718. 'X' => 'x',
  59719. 'Y' => 'y',
  59720. 'Z' => 'z',
  59721. 'À' => 'à',
  59722. '�' => 'á',
  59723. 'Â' => 'â',
  59724. 'Ã' => 'ã',
  59725. 'Ä' => 'ä',
  59726. 'Ã…' => 'Ã¥',
  59727. 'Æ' => 'æ',
  59728. 'Ç' => 'ç',
  59729. 'È' => 'è',
  59730. 'É' => 'é',
  59731. 'Ê' => 'ê',
  59732. 'Ë' => 'ë',
  59733. 'Ì' => 'ì',
  59734. '�' => 'í',
  59735. 'Î' => 'î',
  59736. '�' => 'ï',
  59737. '�' => 'ð',
  59738. 'Ñ' => 'ñ',
  59739. 'Ò' => 'ò',
  59740. 'Ó' => 'ó',
  59741. 'Ô' => 'ô',
  59742. 'Õ' => 'õ',
  59743. 'Ö' => 'ö',
  59744. 'Ø' => 'ø',
  59745. 'Ù' => 'ù',
  59746. 'Ú' => 'ú',
  59747. 'Û' => 'û',
  59748. 'Ü' => 'ü',
  59749. '�' => 'ý',
  59750. 'Þ' => 'þ',
  59751. 'Ā' => '�',
  59752. 'Ă' => 'ă',
  59753. 'Ä„' => 'Ä…',
  59754. 'Ć' => 'ć',
  59755. 'Ĉ' => 'ĉ',
  59756. 'ÄŠ' => 'Ä‹',
  59757. 'Č' => '�',
  59758. 'Ď' => '�',
  59759. '�' => 'đ',
  59760. 'Ä’' => 'Ä“',
  59761. 'Ä”' => 'Ä•',
  59762. 'Ä–' => 'Ä—',
  59763. 'Ę' => 'ę',
  59764. 'Äš' => 'Ä›',
  59765. 'Ĝ' => '�',
  59766. 'Äž' => 'ÄŸ',
  59767. 'Ä ' => 'Ä¡',
  59768. 'Ä¢' => 'Ä£',
  59769. 'Ĥ' => 'ĥ',
  59770. 'Ħ' => 'ħ',
  59771. 'Ĩ' => 'ĩ',
  59772. 'Ī' => 'ī',
  59773. 'Ĭ' => 'ĭ',
  59774. 'Į' => 'į',
  59775. 'Ä°' => 'i',
  59776. 'IJ' => 'ij',
  59777. 'Ĵ' => 'ĵ',
  59778. 'Ķ' => 'ķ',
  59779. 'Ĺ' => 'ĺ',
  59780. 'Ļ' => 'ļ',
  59781. 'Ľ' => 'ľ',
  59782. 'Ä¿' => 'Å€',
  59783. '�' => 'ł',
  59784. 'Ń' => 'ń',
  59785. 'Ņ' => 'ņ',
  59786. 'Ň' => 'ň',
  59787. 'ÅŠ' => 'Å‹',
  59788. 'Ō' => '�',
  59789. 'Ŏ' => '�',
  59790. '�' => 'ő',
  59791. 'Å’' => 'Å“',
  59792. 'Å”' => 'Å•',
  59793. 'Å–' => 'Å—',
  59794. 'Ř' => 'ř',
  59795. 'Åš' => 'Å›',
  59796. 'Ŝ' => '�',
  59797. 'Åž' => 'ÅŸ',
  59798. 'Å ' => 'Å¡',
  59799. 'Å¢' => 'Å£',
  59800. 'Ť' => 'ť',
  59801. 'Ŧ' => 'ŧ',
  59802. 'Ũ' => 'ũ',
  59803. 'Ū' => 'ū',
  59804. 'Ŭ' => 'ŭ',
  59805. 'Ů' => 'ů',
  59806. 'Ű' => 'ű',
  59807. 'Ų' => 'ų',
  59808. 'Ŵ' => 'ŵ',
  59809. 'Ŷ' => 'ŷ',
  59810. 'Ÿ' => 'ÿ',
  59811. 'Ź' => 'ź',
  59812. 'Ż' => 'ż',
  59813. 'Ž' => 'ž',
  59814. '�' => 'ɓ',
  59815. 'Ƃ' => 'ƃ',
  59816. 'Æ„' => 'Æ…',
  59817. 'Ɔ' => 'ɔ',
  59818. 'Ƈ' => 'ƈ',
  59819. 'Ɖ' => 'ɖ',
  59820. 'ÆŠ' => 'É—',
  59821. 'Ƌ' => 'ƌ',
  59822. 'Ǝ' => '�',
  59823. '�' => 'ə',
  59824. '�' => 'ɛ',
  59825. 'Æ‘' => 'Æ’',
  59826. 'Æ“' => 'É ',
  59827. 'Æ”' => 'É£',
  59828. 'Æ–' => 'É©',
  59829. 'Ɨ' => 'ɨ',
  59830. 'Ƙ' => 'ƙ',
  59831. 'Ɯ' => 'ɯ',
  59832. '�' => 'ɲ',
  59833. 'Ɵ' => 'ɵ',
  59834. 'Æ ' => 'Æ¡',
  59835. 'Æ¢' => 'Æ£',
  59836. 'Ƥ' => 'ƥ',
  59837. 'Ʀ' => 'ʀ',
  59838. 'Ƨ' => 'ƨ',
  59839. 'Ʃ' => 'ʃ',
  59840. 'Ƭ' => 'ƭ',
  59841. 'Ʈ' => 'ʈ',
  59842. 'Ư' => 'ư',
  59843. 'Ʊ' => 'ʊ',
  59844. 'Ʋ' => 'ʋ',
  59845. 'Ƴ' => 'ƴ',
  59846. 'Ƶ' => 'ƶ',
  59847. 'Æ·' => 'Ê’',
  59848. 'Ƹ' => 'ƹ',
  59849. 'Ƽ' => 'ƽ',
  59850. 'DŽ' => 'dž',
  59851. 'Dž' => 'dž',
  59852. 'LJ' => 'lj',
  59853. 'Lj' => 'lj',
  59854. 'NJ' => 'nj',
  59855. 'Nj' => 'nj',
  59856. '�' => 'ǎ',
  59857. '�' => '�',
  59858. 'Ç‘' => 'Ç’',
  59859. 'Ç“' => 'Ç”',
  59860. 'Ç•' => 'Ç–',
  59861. 'Ǘ' => 'ǘ',
  59862. 'Ç™' => 'Çš',
  59863. 'Ǜ' => 'ǜ',
  59864. 'Çž' => 'ÇŸ',
  59865. 'Ç ' => 'Ç¡',
  59866. 'Ç¢' => 'Ç£',
  59867. 'Ǥ' => 'ǥ',
  59868. 'Ǧ' => 'ǧ',
  59869. 'Ǩ' => 'ǩ',
  59870. 'Ǫ' => 'ǫ',
  59871. 'Ǭ' => 'ǭ',
  59872. 'Ǯ' => 'ǯ',
  59873. 'DZ' => 'dz',
  59874. 'Dz' => 'dz',
  59875. 'Ǵ' => 'ǵ',
  59876. 'Ƕ' => 'ƕ',
  59877. 'Ç·' => 'Æ¿',
  59878. 'Ǹ' => 'ǹ',
  59879. 'Ǻ' => 'ǻ',
  59880. 'Ǽ' => 'ǽ',
  59881. 'Ǿ' => 'ǿ',
  59882. 'Ȁ' => '�',
  59883. 'Ȃ' => 'ȃ',
  59884. 'È„' => 'È…',
  59885. 'Ȇ' => 'ȇ',
  59886. 'Ȉ' => 'ȉ',
  59887. 'ÈŠ' => 'È‹',
  59888. 'Ȍ' => '�',
  59889. 'Ȏ' => '�',
  59890. '�' => 'ȑ',
  59891. 'È’' => 'È“',
  59892. 'È”' => 'È•',
  59893. 'È–' => 'È—',
  59894. 'Ș' => 'ș',
  59895. 'Èš' => 'È›',
  59896. 'Ȝ' => '�',
  59897. 'Èž' => 'ÈŸ',
  59898. 'È ' => 'Æž',
  59899. 'È¢' => 'È£',
  59900. 'Ȥ' => 'ȥ',
  59901. 'Ȧ' => 'ȧ',
  59902. 'Ȩ' => 'ȩ',
  59903. 'Ȫ' => 'ȫ',
  59904. 'Ȭ' => 'ȭ',
  59905. 'Ȯ' => 'ȯ',
  59906. 'Ȱ' => 'ȱ',
  59907. 'Ȳ' => 'ȳ',
  59908. 'Ⱥ' => 'ⱥ',
  59909. 'Ȼ' => 'ȼ',
  59910. 'Ƚ' => 'ƚ',
  59911. 'Ⱦ' => 'ⱦ',
  59912. '�' => 'ɂ',
  59913. 'Ƀ' => 'ƀ',
  59914. 'Ʉ' => 'ʉ',
  59915. 'Ʌ' => 'ʌ',
  59916. 'Ɇ' => 'ɇ',
  59917. 'Ɉ' => 'ɉ',
  59918. 'ÉŠ' => 'É‹',
  59919. 'Ɍ' => '�',
  59920. 'Ɏ' => '�',
  59921. 'Ͱ' => 'ͱ',
  59922. 'Ͳ' => 'ͳ',
  59923. 'Ͷ' => 'ͷ',
  59924. 'Ϳ' => 'ϳ',
  59925. 'Ά' => 'ά',
  59926. 'Έ' => 'έ',
  59927. 'Ή' => 'ή',
  59928. 'Ί' => 'ί',
  59929. 'Ό' => 'ό',
  59930. 'Ύ' => '�',
  59931. '�' => 'ώ',
  59932. 'Α' => 'α',
  59933. 'Β' => 'β',
  59934. 'Γ' => 'γ',
  59935. 'Δ' => 'δ',
  59936. 'Ε' => 'ε',
  59937. 'Ζ' => 'ζ',
  59938. 'Η' => 'η',
  59939. 'Θ' => 'θ',
  59940. 'Ι' => 'ι',
  59941. 'Κ' => 'κ',
  59942. 'Λ' => 'λ',
  59943. 'Μ' => 'μ',
  59944. '�' => 'ν',
  59945. 'Ξ' => 'ξ',
  59946. 'Ο' => 'ο',
  59947. 'Π' => 'π',
  59948. 'Ρ' => '�',
  59949. 'Σ' => 'σ',
  59950. 'Τ' => 'τ',
  59951. 'Î¥' => 'Ï…',
  59952. 'Φ' => 'φ',
  59953. 'Χ' => 'χ',
  59954. 'Ψ' => 'ψ',
  59955. 'Ω' => 'ω',
  59956. 'Ϊ' => 'ϊ',
  59957. 'Ϋ' => 'ϋ',
  59958. '�' => 'ϗ',
  59959. 'Ϙ' => 'ϙ',
  59960. 'Ïš' => 'Ï›',
  59961. 'Ϝ' => '�',
  59962. 'Ïž' => 'ÏŸ',
  59963. 'Ï ' => 'Ï¡',
  59964. 'Ï¢' => 'Ï£',
  59965. 'Ϥ' => 'ϥ',
  59966. 'Ϧ' => 'ϧ',
  59967. 'Ϩ' => 'ϩ',
  59968. 'Ϫ' => 'ϫ',
  59969. 'Ϭ' => 'ϭ',
  59970. 'Ϯ' => 'ϯ',
  59971. 'ϴ' => 'θ',
  59972. 'Ϸ' => 'ϸ',
  59973. 'Ϲ' => 'ϲ',
  59974. 'Ϻ' => 'ϻ',
  59975. 'Ͻ' => 'ͻ',
  59976. 'Ͼ' => 'ͼ',
  59977. 'Ͽ' => 'ͽ',
  59978. 'Ѐ' => '�',
  59979. '�' => 'ё',
  59980. 'Ђ' => 'ђ',
  59981. 'Ѓ' => 'ѓ',
  59982. 'Є' => 'є',
  59983. 'Ð…' => 'Ñ•',
  59984. 'І' => 'і',
  59985. 'Ї' => 'ї',
  59986. 'Ј' => 'ј',
  59987. 'Љ' => 'љ',
  59988. 'Њ' => 'њ',
  59989. 'Ћ' => 'ћ',
  59990. 'Ќ' => 'ќ',
  59991. '�' => '�',
  59992. 'ÐŽ' => 'Ñž',
  59993. '�' => 'џ',
  59994. '�' => 'а',
  59995. 'Б' => 'б',
  59996. 'В' => 'в',
  59997. 'Г' => 'г',
  59998. 'Д' => 'д',
  59999. 'Е' => 'е',
  60000. 'Ж' => 'ж',
  60001. 'З' => 'з',
  60002. 'И' => 'и',
  60003. 'Й' => 'й',
  60004. 'К' => 'к',
  60005. 'Л' => 'л',
  60006. 'М' => 'м',
  60007. '�' => 'н',
  60008. 'О' => 'о',
  60009. 'П' => 'п',
  60010. 'Р' => 'р',
  60011. 'С' => '�',
  60012. 'Т' => 'т',
  60013. 'У' => 'у',
  60014. 'Ф' => 'ф',
  60015. 'Ð¥' => 'Ñ…',
  60016. 'Ц' => 'ц',
  60017. 'Ч' => 'ч',
  60018. 'Ш' => 'ш',
  60019. 'Щ' => 'щ',
  60020. 'Ъ' => 'ъ',
  60021. 'Ы' => 'ы',
  60022. 'Ь' => 'ь',
  60023. 'Э' => '�',
  60024. 'Ю' => 'ю',
  60025. 'Я' => '�',
  60026. 'Ñ ' => 'Ñ¡',
  60027. 'Ñ¢' => 'Ñ£',
  60028. 'Ѥ' => 'ѥ',
  60029. 'Ѧ' => 'ѧ',
  60030. 'Ѩ' => 'ѩ',
  60031. 'Ѫ' => 'ѫ',
  60032. 'Ѭ' => 'ѭ',
  60033. 'Ѯ' => 'ѯ',
  60034. 'Ѱ' => 'ѱ',
  60035. 'Ѳ' => 'ѳ',
  60036. 'Ѵ' => 'ѵ',
  60037. 'Ѷ' => 'ѷ',
  60038. 'Ѹ' => 'ѹ',
  60039. 'Ѻ' => 'ѻ',
  60040. 'Ѽ' => 'ѽ',
  60041. 'Ѿ' => 'ѿ',
  60042. 'Ò€' => 'Ò�',
  60043. 'ÒŠ' => 'Ò‹',
  60044. 'Ҍ' => '�',
  60045. 'ÒŽ' => 'Ò�',
  60046. 'Ò�' => 'Ò‘',
  60047. 'Ò’' => 'Ò“',
  60048. 'Ò”' => 'Ò•',
  60049. 'Ò–' => 'Ò—',
  60050. 'Ò˜' => 'Ò™',
  60051. 'Òš' => 'Ò›',
  60052. 'Ҝ' => '�',
  60053. 'Òž' => 'ÒŸ',
  60054. 'Ò ' => 'Ò¡',
  60055. 'Ò¢' => 'Ò£',
  60056. 'Ò¤' => 'Ò¥',
  60057. 'Ò¦' => 'Ò§',
  60058. 'Ò¨' => 'Ò©',
  60059. 'Òª' => 'Ò«',
  60060. 'Ò¬' => 'Ò­',
  60061. 'Ò®' => 'Ò¯',
  60062. 'Ò°' => 'Ò±',
  60063. 'Ò²' => 'Ò³',
  60064. 'Ò´' => 'Òµ',
  60065. 'Ò¶' => 'Ò·',
  60066. 'Ò¸' => 'Ò¹',
  60067. 'Òº' => 'Ò»',
  60068. 'Ò¼' => 'Ò½',
  60069. 'Ò¾' => 'Ò¿',
  60070. 'Ó€' => 'Ó�',
  60071. 'Ó�' => 'Ó‚',
  60072. 'Óƒ' => 'Ó„',
  60073. 'Ó…' => 'Ó†',
  60074. 'Ó‡' => 'Óˆ',
  60075. 'Ó‰' => 'ÓŠ',
  60076. 'Ӌ' => 'ӌ',
  60077. 'Ó�' => 'ÓŽ',
  60078. 'Ó�' => 'Ó‘',
  60079. 'Ó’' => 'Ó“',
  60080. 'Ó”' => 'Ó•',
  60081. 'Ó–' => 'Ó—',
  60082. 'Ó˜' => 'Ó™',
  60083. 'Óš' => 'Ó›',
  60084. 'Ӝ' => '�',
  60085. 'Óž' => 'ÓŸ',
  60086. 'Ó ' => 'Ó¡',
  60087. 'Ó¢' => 'Ó£',
  60088. 'Ó¤' => 'Ó¥',
  60089. 'Ó¦' => 'Ó§',
  60090. 'Ó¨' => 'Ó©',
  60091. 'Óª' => 'Ó«',
  60092. 'Ó¬' => 'Ó­',
  60093. 'Ó®' => 'Ó¯',
  60094. 'Ó°' => 'Ó±',
  60095. 'Ó²' => 'Ó³',
  60096. 'Ó´' => 'Óµ',
  60097. 'Ó¶' => 'Ó·',
  60098. 'Ó¸' => 'Ó¹',
  60099. 'Óº' => 'Ó»',
  60100. 'Ó¼' => 'Ó½',
  60101. 'Ó¾' => 'Ó¿',
  60102. 'Ô€' => 'Ô�',
  60103. 'Ô‚' => 'Ôƒ',
  60104. 'Ô„' => 'Ô…',
  60105. 'Ô†' => 'Ô‡',
  60106. 'Ôˆ' => 'Ô‰',
  60107. 'ÔŠ' => 'Ô‹',
  60108. 'Ԍ' => '�',
  60109. 'ÔŽ' => 'Ô�',
  60110. 'Ô�' => 'Ô‘',
  60111. 'Ô’' => 'Ô“',
  60112. 'Ô”' => 'Ô•',
  60113. 'Ô–' => 'Ô—',
  60114. 'Ô˜' => 'Ô™',
  60115. 'Ôš' => 'Ô›',
  60116. 'Ԝ' => '�',
  60117. 'Ôž' => 'ÔŸ',
  60118. 'Ô ' => 'Ô¡',
  60119. 'Ô¢' => 'Ô£',
  60120. 'Ô¤' => 'Ô¥',
  60121. 'Ô¦' => 'Ô§',
  60122. 'Ô¨' => 'Ô©',
  60123. 'Ôª' => 'Ô«',
  60124. 'Ô¬' => 'Ô­',
  60125. 'Ô®' => 'Ô¯',
  60126. 'Ô±' => 'Õ¡',
  60127. 'Ô²' => 'Õ¢',
  60128. 'Ô³' => 'Õ£',
  60129. 'Ô´' => 'Õ¤',
  60130. 'Ôµ' => 'Õ¥',
  60131. 'Ô¶' => 'Õ¦',
  60132. 'Ô·' => 'Õ§',
  60133. 'Ô¸' => 'Õ¨',
  60134. 'Ô¹' => 'Õ©',
  60135. 'Ôº' => 'Õª',
  60136. 'Ô»' => 'Õ«',
  60137. 'Ô¼' => 'Õ¬',
  60138. 'Ô½' => 'Õ­',
  60139. 'Ô¾' => 'Õ®',
  60140. 'Ô¿' => 'Õ¯',
  60141. 'Õ€' => 'Õ°',
  60142. 'Õ�' => 'Õ±',
  60143. 'Õ‚' => 'Õ²',
  60144. 'Õƒ' => 'Õ³',
  60145. 'Õ„' => 'Õ´',
  60146. 'Õ…' => 'Õµ',
  60147. 'Õ†' => 'Õ¶',
  60148. 'Õ‡' => 'Õ·',
  60149. 'Õˆ' => 'Õ¸',
  60150. 'Õ‰' => 'Õ¹',
  60151. 'ÕŠ' => 'Õº',
  60152. 'Õ‹' => 'Õ»',
  60153. 'Ռ' => 'ռ',
  60154. 'Õ�' => 'Õ½',
  60155. 'ÕŽ' => 'Õ¾',
  60156. 'Õ�' => 'Õ¿',
  60157. 'Õ�' => 'Ö€',
  60158. 'Õ‘' => 'Ö�',
  60159. 'Õ’' => 'Ö‚',
  60160. 'Õ“' => 'Öƒ',
  60161. 'Õ”' => 'Ö„',
  60162. 'Õ•' => 'Ö…',
  60163. 'Õ–' => 'Ö†',
  60164. 'á‚ ' => 'â´€',
  60165. 'á‚¡' => 'â´�',
  60166. 'á‚¢' => 'â´‚',
  60167. 'á‚£' => 'â´ƒ',
  60168. 'Ⴄ' => 'ⴄ',
  60169. 'á‚¥' => 'â´…',
  60170. 'Ⴆ' => 'ⴆ',
  60171. 'Ⴇ' => 'ⴇ',
  60172. 'Ⴈ' => 'ⴈ',
  60173. 'á‚©' => 'â´‰',
  60174. 'Ⴊ' => 'ⴊ',
  60175. 'á‚«' => 'â´‹',
  60176. 'Ⴌ' => 'ⴌ',
  60177. 'á‚­' => 'â´�',
  60178. 'á‚®' => 'â´Ž',
  60179. 'Ⴏ' => '�',
  60180. 'á‚°' => 'â´�',
  60181. 'Ⴑ' => 'ⴑ',
  60182. 'Ⴒ' => 'ⴒ',
  60183. 'Ⴓ' => 'ⴓ',
  60184. 'á‚´' => 'â´”',
  60185. 'Ⴕ' => 'ⴕ',
  60186. 'Ⴖ' => 'ⴖ',
  60187. 'á‚·' => 'â´—',
  60188. 'Ⴘ' => 'ⴘ',
  60189. 'Ⴙ' => 'ⴙ',
  60190. 'Ⴚ' => 'ⴚ',
  60191. 'á‚»' => 'â´›',
  60192. 'Ⴜ' => 'ⴜ',
  60193. 'Ⴝ' => '�',
  60194. 'Ⴞ' => 'ⴞ',
  60195. 'á‚¿' => 'â´Ÿ',
  60196. 'Ⴠ' => 'ⴠ',
  60197. '�' => 'ⴡ',
  60198. 'Ⴢ' => 'ⴢ',
  60199. 'Ⴣ' => 'ⴣ',
  60200. 'Ⴤ' => 'ⴤ',
  60201. 'Ⴥ' => 'ⴥ',
  60202. 'Ⴧ' => 'ⴧ',
  60203. '�' => 'ⴭ',
  60204. 'Ꭰ' => 'ꭰ',
  60205. 'Ꭱ' => 'ꭱ',
  60206. 'Ꭲ' => 'ꭲ',
  60207. 'Ꭳ' => 'ꭳ',
  60208. 'Ꭴ' => 'ꭴ',
  60209. 'Ꭵ' => 'ꭵ',
  60210. 'Ꭶ' => 'ꭶ',
  60211. 'Ꭷ' => 'ꭷ',
  60212. 'Ꭸ' => 'ꭸ',
  60213. 'Ꭹ' => 'ꭹ',
  60214. 'Ꭺ' => 'ꭺ',
  60215. 'Ꭻ' => 'ꭻ',
  60216. 'Ꭼ' => 'ꭼ',
  60217. 'Ꭽ' => 'ꭽ',
  60218. 'Ꭾ' => 'ꭾ',
  60219. 'Ꭿ' => 'ꭿ',
  60220. 'Ꮀ' => 'ꮀ',
  60221. 'Ꮁ' => '�',
  60222. 'Ꮂ' => 'ꮂ',
  60223. 'Ꮃ' => 'ꮃ',
  60224. 'Ꮄ' => 'ꮄ',
  60225. 'Ꮅ' => 'ꮅ',
  60226. 'Ꮆ' => 'ꮆ',
  60227. 'Ꮇ' => 'ꮇ',
  60228. 'Ꮈ' => 'ꮈ',
  60229. 'Ꮉ' => 'ꮉ',
  60230. 'Ꮊ' => 'ꮊ',
  60231. 'Ꮋ' => 'ꮋ',
  60232. 'Ꮌ' => 'ꮌ',
  60233. 'Ꮍ' => '�',
  60234. 'Ꮎ' => 'ꮎ',
  60235. 'Ꮏ' => '�',
  60236. '�' => '�',
  60237. '�' => 'ꮑ',
  60238. '�' => 'ꮒ',
  60239. '�' => 'ꮓ',
  60240. '�' => 'ꮔ',
  60241. '�' => 'ꮕ',
  60242. '�' => 'ꮖ',
  60243. '�' => 'ꮗ',
  60244. '�' => 'ꮘ',
  60245. '�' => 'ꮙ',
  60246. '�' => 'ꮚ',
  60247. '�' => 'ꮛ',
  60248. '�' => 'ꮜ',
  60249. '�' => '�',
  60250. '�' => 'ꮞ',
  60251. '�' => 'ꮟ',
  60252. '�' => 'ꮠ',
  60253. '�' => 'ꮡ',
  60254. '�' => 'ꮢ',
  60255. '�' => 'ꮣ',
  60256. '�' => 'ꮤ',
  60257. '�' => 'ꮥ',
  60258. '�' => 'ꮦ',
  60259. '�' => 'ꮧ',
  60260. '�' => 'ꮨ',
  60261. '�' => 'ꮩ',
  60262. '�' => 'ꮪ',
  60263. '�' => 'ꮫ',
  60264. '�' => 'ꮬ',
  60265. '�' => 'ꮭ',
  60266. '�' => 'ꮮ',
  60267. '�' => 'ꮯ',
  60268. '�' => 'ꮰ',
  60269. '�' => 'ꮱ',
  60270. '�' => 'ꮲ',
  60271. '�' => 'ꮳ',
  60272. '�' => 'ꮴ',
  60273. '�' => 'ꮵ',
  60274. '�' => 'ꮶ',
  60275. '�' => 'ꮷ',
  60276. '�' => 'ꮸ',
  60277. '�' => 'ꮹ',
  60278. '�' => 'ꮺ',
  60279. '�' => 'ꮻ',
  60280. '�' => 'ꮼ',
  60281. '�' => 'ꮽ',
  60282. '�' => 'ꮾ',
  60283. '�' => 'ꮿ',
  60284. '�' => '�',
  60285. '�' => '�',
  60286. '�' => '�',
  60287. '�' => '�',
  60288. '�' => '�',
  60289. '�' => '�',
  60290. '�' => '�',
  60291. 'Ბ' => 'ბ',
  60292. 'Გ' => 'გ',
  60293. 'Დ' => 'დ',
  60294. 'Ე' => 'ე',
  60295. 'Ვ' => 'ვ',
  60296. 'Ზ' => 'ზ',
  60297. 'Თ' => 'თ',
  60298. 'Ი' => 'ი',
  60299. 'Კ' => 'კ',
  60300. 'Ლ' => 'ლ',
  60301. 'Მ' => 'მ',
  60302. 'Ნ' => 'ნ',
  60303. '�' => '�',
  60304. 'Პ' => 'პ',
  60305. 'Ჟ' => 'ჟ',
  60306. 'Რ' => 'რ',
  60307. 'Ს' => 'ს',
  60308. 'Ტ' => 'ტ',
  60309. 'Უ' => 'უ',
  60310. 'Ფ' => 'ფ',
  60311. 'Ქ' => 'ქ',
  60312. 'Ღ' => 'ღ',
  60313. 'Ყ' => 'ყ',
  60314. 'Შ' => 'შ',
  60315. 'Ჩ' => 'ჩ',
  60316. 'Ც' => 'ც',
  60317. 'Ძ' => 'ძ',
  60318. 'Წ' => 'წ',
  60319. 'Ჭ' => 'ჭ',
  60320. 'Ხ' => 'ხ',
  60321. 'Ჯ' => 'ჯ',
  60322. 'Ჰ' => 'ჰ',
  60323. 'Ჱ' => 'ჱ',
  60324. 'Ჲ' => 'ჲ',
  60325. 'Ჳ' => 'ჳ',
  60326. 'Ჴ' => 'ჴ',
  60327. 'Ჵ' => 'ჵ',
  60328. 'Ჶ' => 'ჶ',
  60329. 'Ჷ' => 'ჷ',
  60330. 'Ჸ' => 'ჸ',
  60331. 'Ჹ' => 'ჹ',
  60332. 'Ჺ' => 'ჺ',
  60333. 'Ჽ' => 'ჽ',
  60334. 'Ჾ' => 'ჾ',
  60335. 'Ჿ' => 'ჿ',
  60336. 'Ḁ' => '�',
  60337. 'Ḃ' => 'ḃ',
  60338. 'Ḅ' => 'ḅ',
  60339. 'Ḇ' => 'ḇ',
  60340. 'Ḉ' => 'ḉ',
  60341. 'Ḋ' => 'ḋ',
  60342. 'Ḍ' => '�',
  60343. 'Ḏ' => '�',
  60344. '�' => 'ḑ',
  60345. 'Ḓ' => 'ḓ',
  60346. 'Ḕ' => 'ḕ',
  60347. 'Ḗ' => 'ḗ',
  60348. 'Ḙ' => 'ḙ',
  60349. 'Ḛ' => 'ḛ',
  60350. 'Ḝ' => '�',
  60351. 'Ḟ' => 'ḟ',
  60352. 'Ḡ' => 'ḡ',
  60353. 'Ḣ' => 'ḣ',
  60354. 'Ḥ' => 'ḥ',
  60355. 'Ḧ' => 'ḧ',
  60356. 'Ḩ' => 'ḩ',
  60357. 'Ḫ' => 'ḫ',
  60358. 'Ḭ' => 'ḭ',
  60359. 'Ḯ' => 'ḯ',
  60360. 'Ḱ' => 'ḱ',
  60361. 'Ḳ' => 'ḳ',
  60362. 'Ḵ' => 'ḵ',
  60363. 'Ḷ' => 'ḷ',
  60364. 'Ḹ' => 'ḹ',
  60365. 'Ḻ' => 'ḻ',
  60366. 'Ḽ' => 'ḽ',
  60367. 'Ḿ' => 'ḿ',
  60368. 'Ṁ' => '�',
  60369. 'Ṃ' => 'ṃ',
  60370. 'Ṅ' => 'ṅ',
  60371. 'Ṇ' => 'ṇ',
  60372. 'Ṉ' => 'ṉ',
  60373. 'Ṋ' => 'ṋ',
  60374. 'Ṍ' => '�',
  60375. 'Ṏ' => '�',
  60376. '�' => 'ṑ',
  60377. 'Ṓ' => 'ṓ',
  60378. 'Ṕ' => 'ṕ',
  60379. 'á¹–' => 'á¹—',
  60380. 'Ṙ' => 'ṙ',
  60381. 'Ṛ' => 'ṛ',
  60382. 'Ṝ' => '�',
  60383. 'Ṟ' => 'ṟ',
  60384. 'Ṡ' => 'ṡ',
  60385. 'á¹¢' => 'á¹£',
  60386. 'Ṥ' => 'ṥ',
  60387. 'Ṧ' => 'ṧ',
  60388. 'Ṩ' => 'ṩ',
  60389. 'Ṫ' => 'ṫ',
  60390. 'Ṭ' => 'ṭ',
  60391. 'Ṯ' => 'ṯ',
  60392. 'á¹°' => 'á¹±',
  60393. 'á¹²' => 'á¹³',
  60394. 'á¹´' => 'á¹µ',
  60395. 'Ṷ' => 'ṷ',
  60396. 'Ṹ' => 'ṹ',
  60397. 'Ṻ' => 'ṻ',
  60398. 'á¹¼' => 'á¹½',
  60399. 'Ṿ' => 'ṿ',
  60400. 'Ẁ' => '�',
  60401. 'Ẃ' => 'ẃ',
  60402. 'Ẅ' => 'ẅ',
  60403. 'Ẇ' => 'ẇ',
  60404. 'Ẉ' => 'ẉ',
  60405. 'Ẋ' => 'ẋ',
  60406. 'Ẍ' => '�',
  60407. 'Ẏ' => '�',
  60408. '�' => 'ẑ',
  60409. 'Ẓ' => 'ẓ',
  60410. 'Ẕ' => 'ẕ',
  60411. 'ẞ' => 'ß',
  60412. 'Ạ' => 'ạ',
  60413. 'Ả' => 'ả',
  60414. 'Ấ' => 'ấ',
  60415. 'Ầ' => 'ầ',
  60416. 'Ẩ' => 'ẩ',
  60417. 'Ẫ' => 'ẫ',
  60418. 'Ậ' => 'ậ',
  60419. 'Ắ' => 'ắ',
  60420. 'Ằ' => 'ằ',
  60421. 'Ẳ' => 'ẳ',
  60422. 'Ẵ' => 'ẵ',
  60423. 'Ặ' => 'ặ',
  60424. 'Ẹ' => 'ẹ',
  60425. 'Ẻ' => 'ẻ',
  60426. 'Ẽ' => 'ẽ',
  60427. 'Ế' => 'ế',
  60428. 'Ề' => '�',
  60429. 'Ể' => 'ể',
  60430. 'Ễ' => 'ễ',
  60431. 'Ệ' => 'ệ',
  60432. 'Ỉ' => 'ỉ',
  60433. 'Ị' => 'ị',
  60434. 'Ọ' => '�',
  60435. 'Ỏ' => '�',
  60436. '�' => 'ố',
  60437. 'Ồ' => 'ồ',
  60438. 'Ổ' => 'ổ',
  60439. 'á»–' => 'á»—',
  60440. 'Ộ' => 'ộ',
  60441. 'Ớ' => 'ớ',
  60442. 'Ờ' => '�',
  60443. 'Ở' => 'ở',
  60444. 'Ỡ' => 'ỡ',
  60445. 'Ợ' => 'ợ',
  60446. 'Ụ' => 'ụ',
  60447. 'Ủ' => 'ủ',
  60448. 'Ứ' => 'ứ',
  60449. 'Ừ' => 'ừ',
  60450. 'Ử' => 'ử',
  60451. 'Ữ' => 'ữ',
  60452. 'á»°' => 'á»±',
  60453. 'Ỳ' => 'ỳ',
  60454. 'Ỵ' => 'ỵ',
  60455. 'Ỷ' => 'ỷ',
  60456. 'Ỹ' => 'ỹ',
  60457. 'Ỻ' => 'ỻ',
  60458. 'Ỽ' => 'ỽ',
  60459. 'Ỿ' => 'ỿ',
  60460. 'Ἀ' => 'ἀ',
  60461. 'Ἁ' => '�',
  60462. 'Ἂ' => 'ἂ',
  60463. 'Ἃ' => 'ἃ',
  60464. 'Ἄ' => 'ἄ',
  60465. '�' => 'ἅ',
  60466. 'Ἆ' => 'ἆ',
  60467. '�' => 'ἇ',
  60468. 'Ἐ' => '�',
  60469. 'Ἑ' => 'ἑ',
  60470. 'Ἒ' => 'ἒ',
  60471. 'Ἓ' => 'ἓ',
  60472. 'Ἔ' => 'ἔ',
  60473. '�' => 'ἕ',
  60474. 'Ἠ' => 'ἠ',
  60475. 'Ἡ' => 'ἡ',
  60476. 'Ἢ' => 'ἢ',
  60477. 'Ἣ' => 'ἣ',
  60478. 'Ἤ' => 'ἤ',
  60479. 'á¼­' => 'á¼¥',
  60480. 'Ἦ' => 'ἦ',
  60481. 'Ἧ' => 'ἧ',
  60482. 'Ἰ' => 'ἰ',
  60483. 'á¼¹' => 'á¼±',
  60484. 'Ἲ' => 'ἲ',
  60485. 'á¼»' => 'á¼³',
  60486. 'á¼¼' => 'á¼´',
  60487. 'á¼½' => 'á¼µ',
  60488. 'Ἶ' => 'ἶ',
  60489. 'Ἷ' => 'ἷ',
  60490. 'Ὀ' => 'ὀ',
  60491. 'Ὁ' => '�',
  60492. 'Ὂ' => 'ὂ',
  60493. 'Ὃ' => 'ὃ',
  60494. 'Ὄ' => 'ὄ',
  60495. '�' => 'ὅ',
  60496. 'Ὑ' => 'ὑ',
  60497. 'Ὓ' => 'ὓ',
  60498. '�' => 'ὕ',
  60499. 'Ὗ' => 'ὗ',
  60500. 'Ὠ' => 'ὠ',
  60501. 'Ὡ' => 'ὡ',
  60502. 'Ὢ' => 'ὢ',
  60503. 'Ὣ' => 'ὣ',
  60504. 'Ὤ' => 'ὤ',
  60505. 'á½­' => 'á½¥',
  60506. 'Ὦ' => 'ὦ',
  60507. 'Ὧ' => 'ὧ',
  60508. 'ᾈ' => 'ᾀ',
  60509. 'ᾉ' => '�',
  60510. 'ᾊ' => 'ᾂ',
  60511. 'ᾋ' => 'ᾃ',
  60512. 'ᾌ' => 'ᾄ',
  60513. '�' => 'ᾅ',
  60514. 'ᾎ' => 'ᾆ',
  60515. '�' => 'ᾇ',
  60516. 'ᾘ' => '�',
  60517. 'ᾙ' => 'ᾑ',
  60518. 'ᾚ' => 'ᾒ',
  60519. 'ᾛ' => 'ᾓ',
  60520. 'ᾜ' => 'ᾔ',
  60521. '�' => 'ᾕ',
  60522. 'ᾞ' => 'ᾖ',
  60523. 'ᾟ' => 'ᾗ',
  60524. 'ᾨ' => 'ᾠ',
  60525. 'ᾩ' => 'ᾡ',
  60526. 'ᾪ' => 'ᾢ',
  60527. 'ᾫ' => 'ᾣ',
  60528. 'ᾬ' => 'ᾤ',
  60529. 'á¾­' => 'á¾¥',
  60530. 'ᾮ' => 'ᾦ',
  60531. 'ᾯ' => 'ᾧ',
  60532. 'Ᾰ' => 'ᾰ',
  60533. 'á¾¹' => 'á¾±',
  60534. 'Ὰ' => 'ὰ',
  60535. 'á¾»' => 'á½±',
  60536. 'á¾¼' => 'á¾³',
  60537. 'Ὲ' => 'ὲ',
  60538. 'Έ' => 'έ',
  60539. 'á¿Š' => 'á½´',
  60540. 'á¿‹' => 'á½µ',
  60541. 'ῌ' => 'ῃ',
  60542. 'Ῐ' => '�',
  60543. 'á¿™' => 'á¿‘',
  60544. 'Ὶ' => 'ὶ',
  60545. 'á¿›' => 'á½·',
  60546. 'Ῠ' => 'ῠ',
  60547. 'á¿©' => 'á¿¡',
  60548. 'Ὺ' => 'ὺ',
  60549. 'á¿«' => 'á½»',
  60550. 'Ῥ' => 'ῥ',
  60551. 'Ὸ' => 'ὸ',
  60552. 'Ό' => 'ό',
  60553. 'Ὼ' => 'ὼ',
  60554. 'á¿»' => 'á½½',
  60555. 'ῼ' => 'ῳ',
  60556. 'Ω' => 'ω',
  60557. 'K' => 'k',
  60558. 'â„«' => 'Ã¥',
  60559. 'Ⅎ' => 'ⅎ',
  60560. 'â… ' => 'â…°',
  60561. 'â…¡' => 'â…±',
  60562. 'â…¢' => 'â…²',
  60563. 'â…£' => 'â…³',
  60564. 'â…¤' => 'â…´',
  60565. 'â…¥' => 'â…µ',
  60566. 'â…¦' => 'â…¶',
  60567. 'â…§' => 'â…·',
  60568. 'â…¨' => 'â…¸',
  60569. 'â…©' => 'â…¹',
  60570. 'â…ª' => 'â…º',
  60571. 'â…«' => 'â…»',
  60572. 'â…¬' => 'â…¼',
  60573. 'â…­' => 'â…½',
  60574. 'â…®' => 'â…¾',
  60575. 'â…¯' => 'â…¿',
  60576. 'Ↄ' => 'ↄ',
  60577. 'Ⓐ' => '�',
  60578. 'â’·' => 'â“‘',
  60579. 'â’¸' => 'â“’',
  60580. 'â’¹' => 'â““',
  60581. 'â’º' => 'â“”',
  60582. 'â’»' => 'â“•',
  60583. 'â’¼' => 'â“–',
  60584. 'â’½' => 'â“—',
  60585. 'Ⓘ' => 'ⓘ',
  60586. 'â’¿' => 'â“™',
  60587. 'â“€' => 'â“š',
  60588. '�' => 'ⓛ',
  60589. 'Ⓜ' => 'ⓜ',
  60590. 'Ⓝ' => '�',
  60591. 'â“„' => 'â“ž',
  60592. 'â“…' => 'â“Ÿ',
  60593. 'Ⓠ' => 'ⓠ',
  60594. 'Ⓡ' => 'ⓡ',
  60595. 'Ⓢ' => 'ⓢ',
  60596. 'Ⓣ' => 'ⓣ',
  60597. 'Ⓤ' => 'ⓤ',
  60598. 'â“‹' => 'â“¥',
  60599. 'Ⓦ' => 'ⓦ',
  60600. '�' => 'ⓧ',
  60601. 'Ⓨ' => 'ⓨ',
  60602. '�' => 'ⓩ',
  60603. 'â°€' => 'â°°',
  60604. 'â°�' => 'â°±',
  60605. 'â°‚' => 'â°²',
  60606. 'â°ƒ' => 'â°³',
  60607. 'â°„' => 'â°´',
  60608. 'â°…' => 'â°µ',
  60609. 'â°†' => 'â°¶',
  60610. 'â°‡' => 'â°·',
  60611. 'â°ˆ' => 'â°¸',
  60612. 'â°‰' => 'â°¹',
  60613. 'â°Š' => 'â°º',
  60614. 'â°‹' => 'â°»',
  60615. 'Ⰼ' => 'ⰼ',
  60616. 'â°�' => 'â°½',
  60617. 'â°Ž' => 'â°¾',
  60618. 'â°�' => 'â°¿',
  60619. 'â°�' => 'â±€',
  60620. 'Ⱁ' => '�',
  60621. 'Ⱂ' => 'ⱂ',
  60622. 'Ⱃ' => 'ⱃ',
  60623. 'Ⱄ' => 'ⱄ',
  60624. 'â°•' => 'â±…',
  60625. 'Ⱆ' => 'ⱆ',
  60626. 'Ⱇ' => 'ⱇ',
  60627. 'Ⱈ' => 'ⱈ',
  60628. 'Ⱉ' => 'ⱉ',
  60629. 'Ⱊ' => 'ⱊ',
  60630. 'Ⱋ' => 'ⱋ',
  60631. 'Ⱌ' => 'ⱌ',
  60632. '�' => '�',
  60633. 'Ⱎ' => 'ⱎ',
  60634. 'Ⱏ' => '�',
  60635. 'Ⱐ' => '�',
  60636. 'Ⱑ' => 'ⱑ',
  60637. 'â°¢' => 'â±’',
  60638. 'Ⱓ' => 'ⱓ',
  60639. 'â°¤' => 'â±”',
  60640. 'Ⱕ' => 'ⱕ',
  60641. 'â°¦' => 'â±–',
  60642. 'â°§' => 'â±—',
  60643. 'Ⱘ' => 'ⱘ',
  60644. 'â°©' => 'â±™',
  60645. 'Ⱚ' => 'ⱚ',
  60646. 'â°«' => 'â±›',
  60647. 'Ⱜ' => 'ⱜ',
  60648. 'Ⱝ' => '�',
  60649. 'Ⱞ' => 'ⱞ',
  60650. 'Ⱡ' => 'ⱡ',
  60651. 'â±¢' => 'É«',
  60652. 'â±£' => 'áµ½',
  60653. 'Ɽ' => 'ɽ',
  60654. 'Ⱨ' => 'ⱨ',
  60655. 'Ⱪ' => 'ⱪ',
  60656. 'Ⱬ' => 'ⱬ',
  60657. 'â±­' => 'É‘',
  60658. 'Ɱ' => 'ɱ',
  60659. 'Ɐ' => '�',
  60660. 'â±°' => 'É’',
  60661. 'â±²' => 'â±³',
  60662. 'Ⱶ' => 'ⱶ',
  60663. 'â±¾' => 'È¿',
  60664. 'Ɀ' => 'ɀ',
  60665. 'Ⲁ' => '�',
  60666. 'Ⲃ' => 'ⲃ',
  60667. 'Ⲅ' => 'ⲅ',
  60668. 'Ⲇ' => 'ⲇ',
  60669. 'Ⲉ' => 'ⲉ',
  60670. 'Ⲋ' => 'ⲋ',
  60671. 'Ⲍ' => '�',
  60672. 'Ⲏ' => '�',
  60673. '�' => 'ⲑ',
  60674. 'Ⲓ' => 'ⲓ',
  60675. 'Ⲕ' => 'ⲕ',
  60676. 'â²–' => 'â²—',
  60677. 'Ⲙ' => 'ⲙ',
  60678. 'Ⲛ' => 'ⲛ',
  60679. 'Ⲝ' => '�',
  60680. 'Ⲟ' => 'ⲟ',
  60681. 'Ⲡ' => 'ⲡ',
  60682. 'â²¢' => 'â²£',
  60683. 'Ⲥ' => 'ⲥ',
  60684. 'Ⲧ' => 'ⲧ',
  60685. 'Ⲩ' => 'ⲩ',
  60686. 'Ⲫ' => 'ⲫ',
  60687. 'Ⲭ' => 'ⲭ',
  60688. 'Ⲯ' => 'ⲯ',
  60689. 'â²°' => 'â²±',
  60690. 'â²²' => 'â²³',
  60691. 'â²´' => 'â²µ',
  60692. 'Ⲷ' => 'ⲷ',
  60693. 'Ⲹ' => 'ⲹ',
  60694. 'Ⲻ' => 'ⲻ',
  60695. 'â²¼' => 'â²½',
  60696. 'Ⲿ' => 'ⲿ',
  60697. 'Ⳁ' => '�',
  60698. 'Ⳃ' => 'ⳃ',
  60699. 'Ⳅ' => 'ⳅ',
  60700. 'Ⳇ' => 'ⳇ',
  60701. 'Ⳉ' => 'ⳉ',
  60702. 'Ⳋ' => 'ⳋ',
  60703. 'Ⳍ' => '�',
  60704. 'Ⳏ' => '�',
  60705. '�' => 'ⳑ',
  60706. 'Ⳓ' => 'ⳓ',
  60707. 'Ⳕ' => 'ⳕ',
  60708. 'â³–' => 'â³—',
  60709. 'Ⳙ' => 'ⳙ',
  60710. 'Ⳛ' => 'ⳛ',
  60711. 'Ⳝ' => '�',
  60712. 'Ⳟ' => 'ⳟ',
  60713. 'Ⳡ' => 'ⳡ',
  60714. 'â³¢' => 'â³£',
  60715. 'Ⳬ' => 'ⳬ',
  60716. 'â³­' => 'â³®',
  60717. 'â³²' => 'â³³',
  60718. 'Ꙁ' => '�',
  60719. 'Ꙃ' => 'ꙃ',
  60720. 'Ꙅ' => 'ꙅ',
  60721. 'Ꙇ' => 'ꙇ',
  60722. 'Ꙉ' => 'ꙉ',
  60723. 'Ꙋ' => 'ꙋ',
  60724. 'Ꙍ' => '�',
  60725. 'Ꙏ' => '�',
  60726. '�' => 'ꙑ',
  60727. 'Ꙓ' => 'ꙓ',
  60728. 'Ꙕ' => 'ꙕ',
  60729. 'ê™–' => 'ê™—',
  60730. 'Ꙙ' => 'ꙙ',
  60731. 'Ꙛ' => 'ꙛ',
  60732. 'Ꙝ' => '�',
  60733. 'Ꙟ' => 'ꙟ',
  60734. 'Ꙡ' => 'ꙡ',
  60735. 'Ꙣ' => 'ꙣ',
  60736. 'Ꙥ' => 'ꙥ',
  60737. 'Ꙧ' => 'ꙧ',
  60738. 'Ꙩ' => 'ꙩ',
  60739. 'Ꙫ' => 'ꙫ',
  60740. 'Ꙭ' => 'ꙭ',
  60741. 'Ꚁ' => '�',
  60742. 'Ꚃ' => 'ꚃ',
  60743. 'êš„' => 'êš…',
  60744. 'Ꚇ' => 'ꚇ',
  60745. 'Ꚉ' => 'ꚉ',
  60746. 'Ꚋ' => 'ꚋ',
  60747. 'Ꚍ' => '�',
  60748. 'Ꚏ' => '�',
  60749. '�' => 'ꚑ',
  60750. 'êš’' => 'êš“',
  60751. 'êš”' => 'êš•',
  60752. 'êš–' => 'êš—',
  60753. 'Ꚙ' => 'ꚙ',
  60754. 'êšš' => 'êš›',
  60755. 'Ꜣ' => 'ꜣ',
  60756. 'Ꜥ' => 'ꜥ',
  60757. 'Ꜧ' => 'ꜧ',
  60758. 'Ꜩ' => 'ꜩ',
  60759. 'Ꜫ' => 'ꜫ',
  60760. 'Ꜭ' => 'ꜭ',
  60761. 'Ꜯ' => 'ꜯ',
  60762. 'Ꜳ' => 'ꜳ',
  60763. 'Ꜵ' => 'ꜵ',
  60764. 'Ꜷ' => 'ꜷ',
  60765. 'Ꜹ' => 'ꜹ',
  60766. 'Ꜻ' => 'ꜻ',
  60767. 'Ꜽ' => 'ꜽ',
  60768. 'Ꜿ' => 'ꜿ',
  60769. '�' => '�',
  60770. '�' => '�',
  60771. '�' => '�',
  60772. '�' => '�',
  60773. '�' => '�',
  60774. '�' => '�',
  60775. '�' => '�',
  60776. '�' => '�',
  60777. '�' => '�',
  60778. '�' => '�',
  60779. '�' => '�',
  60780. '�' => '�',
  60781. '�' => '�',
  60782. '�' => '�',
  60783. '�' => '�',
  60784. '�' => '�',
  60785. '�' => '�',
  60786. '�' => '�',
  60787. '�' => '�',
  60788. '�' => '�',
  60789. '�' => '�',
  60790. '�' => '�',
  60791. '�' => '�',
  60792. '�' => '�',
  60793. '�' => '�',
  60794. '�' => '�',
  60795. '�' => 'ᵹ',
  60796. '�' => '�',
  60797. 'Ꞁ' => '�',
  60798. 'Ꞃ' => 'ꞃ',
  60799. 'êž„' => 'êž…',
  60800. 'Ꞇ' => 'ꞇ',
  60801. 'Ꞌ' => 'ꞌ',
  60802. '�' => 'ɥ',
  60803. '�' => 'ꞑ',
  60804. 'êž’' => 'êž“',
  60805. 'êž–' => 'êž—',
  60806. 'Ꞙ' => 'ꞙ',
  60807. 'êžš' => 'êž›',
  60808. 'Ꞝ' => '�',
  60809. 'Ꞟ' => 'ꞟ',
  60810. 'êž ' => 'êž¡',
  60811. 'Ꞣ' => 'ꞣ',
  60812. 'Ꞥ' => 'ꞥ',
  60813. 'Ꞧ' => 'ꞧ',
  60814. 'Ꞩ' => 'ꞩ',
  60815. 'Ɦ' => 'ɦ',
  60816. 'Ɜ' => 'ɜ',
  60817. 'Ɡ' => 'ɡ',
  60818. 'Ɬ' => 'ɬ',
  60819. 'Ɪ' => 'ɪ',
  60820. 'êž°' => 'Êž',
  60821. 'Ʇ' => 'ʇ',
  60822. 'Ʝ' => '�',
  60823. 'êž³' => 'ê­“',
  60824. 'êž´' => 'êžµ',
  60825. 'Ꞷ' => 'ꞷ',
  60826. 'Ꞹ' => 'ꞹ',
  60827. 'Ꞻ' => 'ꞻ',
  60828. 'êž¼' => 'êž½',
  60829. 'êž¾' => 'êž¿',
  60830. 'Ꟃ' => 'ꟃ',
  60831. 'Ꞔ' => 'ꞔ',
  60832. 'Ʂ' => 'ʂ',
  60833. 'Ᶎ' => 'ᶎ',
  60834. 'Ꟈ' => 'ꟈ',
  60835. 'Ꟊ' => 'ꟊ',
  60836. 'Ꟶ' => 'ꟶ',
  60837. 'A' => '�',
  60838. 'B' => 'b',
  60839. 'C' => 'c',
  60840. 'D' => 'd',
  60841. 'ï¼¥' => 'ï½…',
  60842. 'F' => 'f',
  60843. 'G' => 'g',
  60844. 'H' => 'h',
  60845. 'I' => 'i',
  60846. 'J' => 'j',
  60847. 'K' => 'k',
  60848. 'L' => 'l',
  60849. 'M' => '�',
  60850. 'N' => 'n',
  60851. 'O' => '�',
  60852. 'P' => '�',
  60853. 'Q' => 'q',
  60854. 'ï¼²' => 'ï½’',
  60855. 'S' => 's',
  60856. 'ï¼´' => 'ï½”',
  60857. 'U' => 'u',
  60858. 'V' => 'v',
  60859. 'ï¼·' => 'ï½—',
  60860. 'X' => 'x',
  60861. 'ï¼¹' => 'ï½™',
  60862. 'Z' => 'z',
  60863. '�' => '�',
  60864. '�' => '�',
  60865. '�' => '�',
  60866. '�' => '�',
  60867. '�' => '�',
  60868. '�' => '�',
  60869. '�' => '�',
  60870. '�' => '�',
  60871. '�' => '�',
  60872. '�' => '�',
  60873. '�' => '�',
  60874. '�' => '�',
  60875. '�' => '�',
  60876. '�' => '�',
  60877. '�' => '�',
  60878. '�' => '�',
  60879. '�' => '�',
  60880. '�' => '�',
  60881. '�' => '�',
  60882. '�' => '�',
  60883. '�' => '�',
  60884. '�' => '�',
  60885. '�' => '�',
  60886. '�' => '�',
  60887. '�' => '�',
  60888. '�' => '�',
  60889. '�' => '�',
  60890. '�' => '�',
  60891. '�' => '�',
  60892. '�' => '�',
  60893. '�' => '�',
  60894. '�' => '�',
  60895. '�' => '�',
  60896. '�' => '�',
  60897. '�' => '�',
  60898. '�' => '�',
  60899. '�' => '�',
  60900. '�' => '�',
  60901. '�' => '�',
  60902. '�' => '�',
  60903. '�' => '�',
  60904. '�' => '�',
  60905. '�' => '�',
  60906. '�' => '�',
  60907. '�' => '�',
  60908. '�' => '�',
  60909. '�' => '�',
  60910. '�' => '�',
  60911. '�' => '�',
  60912. '�' => '�',
  60913. '�' => '�',
  60914. '�' => '�',
  60915. '�' => '�',
  60916. '�' => '�',
  60917. '�' => '�',
  60918. '�' => '�',
  60919. '�' => '�',
  60920. '�' => '�',
  60921. '�' => '�',
  60922. '�' => '�',
  60923. '�' => '�',
  60924. '�' => '�',
  60925. '�' => '�',
  60926. '�' => '�',
  60927. '�' => '�',
  60928. '�' => '�',
  60929. '�' => '�',
  60930. '�' => '�',
  60931. '�' => '�',
  60932. '�' => '�',
  60933. '�' => '�',
  60934. '�' => '�',
  60935. '�' => '�',
  60936. '�' => '�',
  60937. '�' => '�',
  60938. '�' => '�',
  60939. '�' => '�',
  60940. '�' => '�',
  60941. '�' => '�',
  60942. '�' => '�',
  60943. '�' => '�',
  60944. '�' => '�',
  60945. '�' => '�',
  60946. '�' => '�',
  60947. '�' => '�',
  60948. '�' => '�',
  60949. '�' => '�',
  60950. '�' => '�',
  60951. '�' => '�',
  60952. '�' => '�',
  60953. '�' => '�',
  60954. '�' => '�',
  60955. '�' => '�',
  60956. '�' => '�',
  60957. '�' => '�',
  60958. '�' => '�',
  60959. '�' => '�',
  60960. '�' => '�',
  60961. '�' => '�',
  60962. '�' => '�',
  60963. '�' => '�',
  60964. '�' => '�',
  60965. '�' => '�',
  60966. '�' => '�',
  60967. '�' => '�',
  60968. '�' => '�',
  60969. '�' => '�',
  60970. '�' => '�',
  60971. '�' => '�',
  60972. '�' => '�',
  60973. '�' => '�',
  60974. '�' => '�',
  60975. '�' => '�',
  60976. '�' => '�',
  60977. '�' => '�',
  60978. '�' => '�',
  60979. '�' => '�',
  60980. '�' => '�',
  60981. '�' => '�',
  60982. '�' => '�',
  60983. '�' => '�',
  60984. '�' => '�',
  60985. '�' => '�',
  60986. '�' => '�',
  60987. '�' => '�',
  60988. '�' => '�',
  60989. '�' => '�',
  60990. 'ð‘¢ ' => 'ð‘£€',
  60991. '𑢡' => '�',
  60992. '𑢢' => '𑣂',
  60993. '𑢣' => '𑣃',
  60994. '𑢤' => '𑣄',
  60995. 'ð‘¢¥' => 'ð‘£…',
  60996. '𑢦' => '𑣆',
  60997. '𑢧' => '𑣇',
  60998. '𑢨' => '𑣈',
  60999. '𑢩' => '𑣉',
  61000. '𑢪' => '𑣊',
  61001. '𑢫' => '𑣋',
  61002. '𑢬' => '𑣌',
  61003. '𑢭' => '�',
  61004. '𑢮' => '𑣎',
  61005. '𑢯' => '�',
  61006. '𑢰' => '�',
  61007. '𑢱' => '𑣑',
  61008. 'ð‘¢²' => 'ð‘£’',
  61009. '𑢳' => '𑣓',
  61010. 'ð‘¢´' => 'ð‘£”',
  61011. '𑢵' => '𑣕',
  61012. '𑢶' => '𑣖',
  61013. 'ð‘¢·' => 'ð‘£—',
  61014. '𑢸' => '𑣘',
  61015. 'ð‘¢¹' => 'ð‘£™',
  61016. '𑢺' => '𑣚',
  61017. 'ð‘¢»' => 'ð‘£›',
  61018. '𑢼' => '𑣜',
  61019. '𑢽' => '�',
  61020. '𑢾' => '𑣞',
  61021. '𑢿' => '𑣟',
  61022. 'ð–¹€' => 'ð–¹ ',
  61023. '�' => '𖹡',
  61024. '𖹂' => '𖹢',
  61025. '𖹃' => '𖹣',
  61026. '𖹄' => '𖹤',
  61027. 'ð–¹…' => 'ð–¹¥',
  61028. '𖹆' => '𖹦',
  61029. '𖹇' => '𖹧',
  61030. '𖹈' => '𖹨',
  61031. '𖹉' => '𖹩',
  61032. '𖹊' => '𖹪',
  61033. '𖹋' => '𖹫',
  61034. '𖹌' => '𖹬',
  61035. '�' => '𖹭',
  61036. '𖹎' => '𖹮',
  61037. '�' => '𖹯',
  61038. '�' => '𖹰',
  61039. '𖹑' => '𖹱',
  61040. 'ð–¹’' => 'ð–¹²',
  61041. '𖹓' => '𖹳',
  61042. 'ð–¹”' => 'ð–¹´',
  61043. '𖹕' => '𖹵',
  61044. '𖹖' => '𖹶',
  61045. 'ð–¹—' => 'ð–¹·',
  61046. '𖹘' => '𖹸',
  61047. 'ð–¹™' => 'ð–¹¹',
  61048. '𖹚' => '𖹺',
  61049. 'ð–¹›' => 'ð–¹»',
  61050. '𖹜' => '𖹼',
  61051. '�' => '𖹽',
  61052. '𖹞' => '𖹾',
  61053. '𖹟' => '𖹿',
  61054. '𞤀' => '𞤢',
  61055. '�' => '𞤣',
  61056. '𞤂' => '𞤤',
  61057. '𞤃' => '𞤥',
  61058. '𞤄' => '𞤦',
  61059. '𞤅' => '𞤧',
  61060. '𞤆' => '𞤨',
  61061. '𞤇' => '𞤩',
  61062. '𞤈' => '𞤪',
  61063. '𞤉' => '𞤫',
  61064. '𞤊' => '𞤬',
  61065. '𞤋' => '𞤭',
  61066. '𞤌' => '𞤮',
  61067. '�' => '𞤯',
  61068. '𞤎' => '𞤰',
  61069. '�' => '𞤱',
  61070. '�' => '𞤲',
  61071. '𞤑' => '𞤳',
  61072. '𞤒' => '𞤴',
  61073. '𞤓' => '𞤵',
  61074. '𞤔' => '𞤶',
  61075. '𞤕' => '𞤷',
  61076. '𞤖' => '𞤸',
  61077. '𞤗' => '𞤹',
  61078. '𞤘' => '𞤺',
  61079. '𞤙' => '𞤻',
  61080. '𞤚' => '𞤼',
  61081. '𞤛' => '𞤽',
  61082. '𞤜' => '𞤾',
  61083. '�' => '𞤿',
  61084. '𞤞' => '𞥀',
  61085. '𞤟' => '�',
  61086. '𞤠' => '𞥂',
  61087. '𞤡' => '𞥃',
  61088. );
  61089. <?php
  61090. 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';
  61091. <?php
  61092. return array (
  61093. 'a' => 'A',
  61094. 'b' => 'B',
  61095. 'c' => 'C',
  61096. 'd' => 'D',
  61097. 'e' => 'E',
  61098. 'f' => 'F',
  61099. 'g' => 'G',
  61100. 'h' => 'H',
  61101. 'i' => 'I',
  61102. 'j' => 'J',
  61103. 'k' => 'K',
  61104. 'l' => 'L',
  61105. 'm' => 'M',
  61106. 'n' => 'N',
  61107. 'o' => 'O',
  61108. 'p' => 'P',
  61109. 'q' => 'Q',
  61110. 'r' => 'R',
  61111. 's' => 'S',
  61112. 't' => 'T',
  61113. 'u' => 'U',
  61114. 'v' => 'V',
  61115. 'w' => 'W',
  61116. 'x' => 'X',
  61117. 'y' => 'Y',
  61118. 'z' => 'Z',
  61119. 'µ' => 'Μ',
  61120. 'à' => 'À',
  61121. 'á' => '�',
  61122. 'â' => 'Â',
  61123. 'ã' => 'Ã',
  61124. 'ä' => 'Ä',
  61125. 'Ã¥' => 'Ã…',
  61126. 'æ' => 'Æ',
  61127. 'ç' => 'Ç',
  61128. 'è' => 'È',
  61129. 'é' => 'É',
  61130. 'ê' => 'Ê',
  61131. 'ë' => 'Ë',
  61132. 'ì' => 'Ì',
  61133. 'í' => '�',
  61134. 'î' => 'Î',
  61135. 'ï' => '�',
  61136. 'ð' => '�',
  61137. 'ñ' => 'Ñ',
  61138. 'ò' => 'Ò',
  61139. 'ó' => 'Ó',
  61140. 'ô' => 'Ô',
  61141. 'õ' => 'Õ',
  61142. 'ö' => 'Ö',
  61143. 'ø' => 'Ø',
  61144. 'ù' => 'Ù',
  61145. 'ú' => 'Ú',
  61146. 'û' => 'Û',
  61147. 'ü' => 'Ü',
  61148. 'ý' => '�',
  61149. 'þ' => 'Þ',
  61150. 'ÿ' => 'Ÿ',
  61151. '�' => 'Ā',
  61152. 'ă' => 'Ă',
  61153. 'Ä…' => 'Ä„',
  61154. 'ć' => 'Ć',
  61155. 'ĉ' => 'Ĉ',
  61156. 'Ä‹' => 'ÄŠ',
  61157. '�' => 'Č',
  61158. '�' => 'Ď',
  61159. 'đ' => '�',
  61160. 'Ä“' => 'Ä’',
  61161. 'Ä•' => 'Ä”',
  61162. 'Ä—' => 'Ä–',
  61163. 'ę' => 'Ę',
  61164. 'Ä›' => 'Äš',
  61165. '�' => 'Ĝ',
  61166. 'ÄŸ' => 'Äž',
  61167. 'Ä¡' => 'Ä ',
  61168. 'Ä£' => 'Ä¢',
  61169. 'ĥ' => 'Ĥ',
  61170. 'ħ' => 'Ħ',
  61171. 'ĩ' => 'Ĩ',
  61172. 'ī' => 'Ī',
  61173. 'ĭ' => 'Ĭ',
  61174. 'į' => 'Į',
  61175. 'ı' => 'I',
  61176. 'ij' => 'IJ',
  61177. 'ĵ' => 'Ĵ',
  61178. 'ķ' => 'Ķ',
  61179. 'ĺ' => 'Ĺ',
  61180. 'ļ' => 'Ļ',
  61181. 'ľ' => 'Ľ',
  61182. 'Å€' => 'Ä¿',
  61183. 'ł' => '�',
  61184. 'ń' => 'Ń',
  61185. 'ņ' => 'Ņ',
  61186. 'ň' => 'Ň',
  61187. 'Å‹' => 'ÅŠ',
  61188. '�' => 'Ō',
  61189. '�' => 'Ŏ',
  61190. 'ő' => '�',
  61191. 'Å“' => 'Å’',
  61192. 'Å•' => 'Å”',
  61193. 'Å—' => 'Å–',
  61194. 'ř' => 'Ř',
  61195. 'Å›' => 'Åš',
  61196. '�' => 'Ŝ',
  61197. 'ÅŸ' => 'Åž',
  61198. 'Å¡' => 'Å ',
  61199. 'Å£' => 'Å¢',
  61200. 'ť' => 'Ť',
  61201. 'ŧ' => 'Ŧ',
  61202. 'ũ' => 'Ũ',
  61203. 'ū' => 'Ū',
  61204. 'ŭ' => 'Ŭ',
  61205. 'ů' => 'Ů',
  61206. 'ű' => 'Ű',
  61207. 'ų' => 'Ų',
  61208. 'ŵ' => 'Ŵ',
  61209. 'ŷ' => 'Ŷ',
  61210. 'ź' => 'Ź',
  61211. 'ż' => 'Ż',
  61212. 'ž' => 'Ž',
  61213. 'Å¿' => 'S',
  61214. 'ƀ' => 'Ƀ',
  61215. 'ƃ' => 'Ƃ',
  61216. 'Æ…' => 'Æ„',
  61217. 'ƈ' => 'Ƈ',
  61218. 'ƌ' => 'Ƌ',
  61219. 'Æ’' => 'Æ‘',
  61220. 'ƕ' => 'Ƕ',
  61221. 'ƙ' => 'Ƙ',
  61222. 'ƚ' => 'Ƚ',
  61223. 'Æž' => 'È ',
  61224. 'Æ¡' => 'Æ ',
  61225. 'Æ£' => 'Æ¢',
  61226. 'ƥ' => 'Ƥ',
  61227. 'ƨ' => 'Ƨ',
  61228. 'ƭ' => 'Ƭ',
  61229. 'ư' => 'Ư',
  61230. 'ƴ' => 'Ƴ',
  61231. 'ƶ' => 'Ƶ',
  61232. 'ƹ' => 'Ƹ',
  61233. 'ƽ' => 'Ƽ',
  61234. 'Æ¿' => 'Ç·',
  61235. 'Ç…' => 'Ç„',
  61236. 'dž' => 'DŽ',
  61237. 'Lj' => 'LJ',
  61238. 'lj' => 'LJ',
  61239. 'Ç‹' => 'ÇŠ',
  61240. 'nj' => 'NJ',
  61241. 'ǎ' => '�',
  61242. '�' => '�',
  61243. 'Ç’' => 'Ç‘',
  61244. 'Ç”' => 'Ç“',
  61245. 'Ç–' => 'Ç•',
  61246. 'ǘ' => 'Ǘ',
  61247. 'Çš' => 'Ç™',
  61248. 'ǜ' => 'Ǜ',
  61249. '�' => 'Ǝ',
  61250. 'ÇŸ' => 'Çž',
  61251. 'Ç¡' => 'Ç ',
  61252. 'Ç£' => 'Ç¢',
  61253. 'ǥ' => 'Ǥ',
  61254. 'ǧ' => 'Ǧ',
  61255. 'ǩ' => 'Ǩ',
  61256. 'ǫ' => 'Ǫ',
  61257. 'ǭ' => 'Ǭ',
  61258. 'ǯ' => 'Ǯ',
  61259. 'Dz' => 'DZ',
  61260. 'dz' => 'DZ',
  61261. 'ǵ' => 'Ǵ',
  61262. 'ǹ' => 'Ǹ',
  61263. 'ǻ' => 'Ǻ',
  61264. 'ǽ' => 'Ǽ',
  61265. 'ǿ' => 'Ǿ',
  61266. '�' => 'Ȁ',
  61267. 'ȃ' => 'Ȃ',
  61268. 'È…' => 'È„',
  61269. 'ȇ' => 'Ȇ',
  61270. 'ȉ' => 'Ȉ',
  61271. 'È‹' => 'ÈŠ',
  61272. '�' => 'Ȍ',
  61273. '�' => 'Ȏ',
  61274. 'ȑ' => '�',
  61275. 'È“' => 'È’',
  61276. 'È•' => 'È”',
  61277. 'È—' => 'È–',
  61278. 'ș' => 'Ș',
  61279. 'È›' => 'Èš',
  61280. '�' => 'Ȝ',
  61281. 'ÈŸ' => 'Èž',
  61282. 'È£' => 'È¢',
  61283. 'ȥ' => 'Ȥ',
  61284. 'ȧ' => 'Ȧ',
  61285. 'ȩ' => 'Ȩ',
  61286. 'ȫ' => 'Ȫ',
  61287. 'ȭ' => 'Ȭ',
  61288. 'ȯ' => 'Ȯ',
  61289. 'ȱ' => 'Ȱ',
  61290. 'ȳ' => 'Ȳ',
  61291. 'ȼ' => 'Ȼ',
  61292. 'È¿' => 'â±¾',
  61293. 'ɀ' => 'Ɀ',
  61294. 'ɂ' => '�',
  61295. 'ɇ' => 'Ɇ',
  61296. 'ɉ' => 'Ɉ',
  61297. 'É‹' => 'ÉŠ',
  61298. '�' => 'Ɍ',
  61299. '�' => 'Ɏ',
  61300. '�' => 'Ɐ',
  61301. 'É‘' => 'â±­',
  61302. 'É’' => 'â±°',
  61303. 'ɓ' => '�',
  61304. 'ɔ' => 'Ɔ',
  61305. 'ɖ' => 'Ɖ',
  61306. 'É—' => 'ÆŠ',
  61307. 'ə' => '�',
  61308. 'ɛ' => '�',
  61309. 'ɜ' => 'Ɜ',
  61310. 'É ' => 'Æ“',
  61311. 'ɡ' => 'Ɡ',
  61312. 'É£' => 'Æ”',
  61313. 'ɥ' => '�',
  61314. 'ɦ' => 'Ɦ',
  61315. 'ɨ' => 'Ɨ',
  61316. 'É©' => 'Æ–',
  61317. 'ɪ' => 'Ɪ',
  61318. 'É«' => 'â±¢',
  61319. 'ɬ' => 'Ɬ',
  61320. 'ɯ' => 'Ɯ',
  61321. 'ɱ' => 'Ɱ',
  61322. 'ɲ' => '�',
  61323. 'ɵ' => 'Ɵ',
  61324. 'ɽ' => 'Ɽ',
  61325. 'ʀ' => 'Ʀ',
  61326. 'ʂ' => 'Ʂ',
  61327. 'ʃ' => 'Ʃ',
  61328. 'ʇ' => 'Ʇ',
  61329. 'ʈ' => 'Ʈ',
  61330. 'ʉ' => 'Ʉ',
  61331. 'ʊ' => 'Ʊ',
  61332. 'ʋ' => 'Ʋ',
  61333. 'ʌ' => 'Ʌ',
  61334. 'Ê’' => 'Æ·',
  61335. '�' => 'Ʝ',
  61336. 'Êž' => 'êž°',
  61337. 'ͅ' => 'Ι',
  61338. 'ͱ' => 'Ͱ',
  61339. 'ͳ' => 'Ͳ',
  61340. 'ͷ' => 'Ͷ',
  61341. 'ͻ' => 'Ͻ',
  61342. 'ͼ' => 'Ͼ',
  61343. 'ͽ' => 'Ͽ',
  61344. 'ά' => 'Ά',
  61345. 'έ' => 'Έ',
  61346. 'ή' => 'Ή',
  61347. 'ί' => 'Ί',
  61348. 'α' => 'Α',
  61349. 'β' => 'Β',
  61350. 'γ' => 'Γ',
  61351. 'δ' => 'Δ',
  61352. 'ε' => 'Ε',
  61353. 'ζ' => 'Ζ',
  61354. 'η' => 'Η',
  61355. 'θ' => 'Θ',
  61356. 'ι' => 'Ι',
  61357. 'κ' => 'Κ',
  61358. 'λ' => 'Λ',
  61359. 'μ' => 'Μ',
  61360. 'ν' => '�',
  61361. 'ξ' => 'Ξ',
  61362. 'ο' => 'Ο',
  61363. 'π' => 'Π',
  61364. '�' => 'Ρ',
  61365. 'ς' => 'Σ',
  61366. 'σ' => 'Σ',
  61367. 'τ' => 'Τ',
  61368. 'Ï…' => 'Î¥',
  61369. 'φ' => 'Φ',
  61370. 'χ' => 'Χ',
  61371. 'ψ' => 'Ψ',
  61372. 'ω' => 'Ω',
  61373. 'ϊ' => 'Ϊ',
  61374. 'ϋ' => 'Ϋ',
  61375. 'ό' => 'Ό',
  61376. '�' => 'Ύ',
  61377. 'ώ' => '�',
  61378. '�' => 'Β',
  61379. 'ϑ' => 'Θ',
  61380. 'ϕ' => 'Φ',
  61381. 'ϖ' => 'Π',
  61382. 'ϗ' => '�',
  61383. 'ϙ' => 'Ϙ',
  61384. 'Ï›' => 'Ïš',
  61385. '�' => 'Ϝ',
  61386. 'ÏŸ' => 'Ïž',
  61387. 'Ï¡' => 'Ï ',
  61388. 'Ï£' => 'Ï¢',
  61389. 'ϥ' => 'Ϥ',
  61390. 'ϧ' => 'Ϧ',
  61391. 'ϩ' => 'Ϩ',
  61392. 'ϫ' => 'Ϫ',
  61393. 'ϭ' => 'Ϭ',
  61394. 'ϯ' => 'Ϯ',
  61395. 'ϰ' => 'Κ',
  61396. 'ϱ' => 'Ρ',
  61397. 'ϲ' => 'Ϲ',
  61398. 'ϳ' => 'Ϳ',
  61399. 'ϵ' => 'Ε',
  61400. 'ϸ' => 'Ϸ',
  61401. 'ϻ' => 'Ϻ',
  61402. 'а' => '�',
  61403. 'б' => 'Б',
  61404. 'в' => 'В',
  61405. 'г' => 'Г',
  61406. 'д' => 'Д',
  61407. 'е' => 'Е',
  61408. 'ж' => 'Ж',
  61409. 'з' => 'З',
  61410. 'и' => 'И',
  61411. 'й' => 'Й',
  61412. 'к' => 'К',
  61413. 'л' => 'Л',
  61414. 'м' => 'М',
  61415. 'н' => '�',
  61416. 'о' => 'О',
  61417. 'п' => 'П',
  61418. 'р' => 'Р',
  61419. '�' => 'С',
  61420. 'т' => 'Т',
  61421. 'у' => 'У',
  61422. 'ф' => 'Ф',
  61423. 'Ñ…' => 'Ð¥',
  61424. 'ц' => 'Ц',
  61425. 'ч' => 'Ч',
  61426. 'ш' => 'Ш',
  61427. 'щ' => 'Щ',
  61428. 'ъ' => 'Ъ',
  61429. 'ы' => 'Ы',
  61430. 'ь' => 'Ь',
  61431. '�' => 'Э',
  61432. 'ю' => 'Ю',
  61433. '�' => 'Я',
  61434. '�' => 'Ѐ',
  61435. 'ё' => '�',
  61436. 'ђ' => 'Ђ',
  61437. 'ѓ' => 'Ѓ',
  61438. 'є' => 'Є',
  61439. 'Ñ•' => 'Ð…',
  61440. 'і' => 'І',
  61441. 'ї' => 'Ї',
  61442. 'ј' => 'Ј',
  61443. 'љ' => 'Љ',
  61444. 'њ' => 'Њ',
  61445. 'ћ' => 'Ћ',
  61446. 'ќ' => 'Ќ',
  61447. '�' => '�',
  61448. 'Ñž' => 'ÐŽ',
  61449. 'џ' => '�',
  61450. 'Ñ¡' => 'Ñ ',
  61451. 'Ñ£' => 'Ñ¢',
  61452. 'ѥ' => 'Ѥ',
  61453. 'ѧ' => 'Ѧ',
  61454. 'ѩ' => 'Ѩ',
  61455. 'ѫ' => 'Ѫ',
  61456. 'ѭ' => 'Ѭ',
  61457. 'ѯ' => 'Ѯ',
  61458. 'ѱ' => 'Ѱ',
  61459. 'ѳ' => 'Ѳ',
  61460. 'ѵ' => 'Ѵ',
  61461. 'ѷ' => 'Ѷ',
  61462. 'ѹ' => 'Ѹ',
  61463. 'ѻ' => 'Ѻ',
  61464. 'ѽ' => 'Ѽ',
  61465. 'ѿ' => 'Ѿ',
  61466. 'Ò�' => 'Ò€',
  61467. 'Ò‹' => 'ÒŠ',
  61468. '�' => 'Ҍ',
  61469. 'Ò�' => 'ÒŽ',
  61470. 'Ò‘' => 'Ò�',
  61471. 'Ò“' => 'Ò’',
  61472. 'Ò•' => 'Ò”',
  61473. 'Ò—' => 'Ò–',
  61474. 'Ò™' => 'Ò˜',
  61475. 'Ò›' => 'Òš',
  61476. '�' => 'Ҝ',
  61477. 'ÒŸ' => 'Òž',
  61478. 'Ò¡' => 'Ò ',
  61479. 'Ò£' => 'Ò¢',
  61480. 'Ò¥' => 'Ò¤',
  61481. 'Ò§' => 'Ò¦',
  61482. 'Ò©' => 'Ò¨',
  61483. 'Ò«' => 'Òª',
  61484. 'Ò­' => 'Ò¬',
  61485. 'Ò¯' => 'Ò®',
  61486. 'Ò±' => 'Ò°',
  61487. 'Ò³' => 'Ò²',
  61488. 'Òµ' => 'Ò´',
  61489. 'Ò·' => 'Ò¶',
  61490. 'Ò¹' => 'Ò¸',
  61491. 'Ò»' => 'Òº',
  61492. 'Ò½' => 'Ò¼',
  61493. 'Ò¿' => 'Ò¾',
  61494. 'Ó‚' => 'Ó�',
  61495. 'Ó„' => 'Óƒ',
  61496. 'Ó†' => 'Ó…',
  61497. 'Óˆ' => 'Ó‡',
  61498. 'ÓŠ' => 'Ó‰',
  61499. 'ӌ' => 'Ӌ',
  61500. 'ÓŽ' => 'Ó�',
  61501. 'Ó�' => 'Ó€',
  61502. 'Ó‘' => 'Ó�',
  61503. 'Ó“' => 'Ó’',
  61504. 'Ó•' => 'Ó”',
  61505. 'Ó—' => 'Ó–',
  61506. 'Ó™' => 'Ó˜',
  61507. 'Ó›' => 'Óš',
  61508. '�' => 'Ӝ',
  61509. 'ÓŸ' => 'Óž',
  61510. 'Ó¡' => 'Ó ',
  61511. 'Ó£' => 'Ó¢',
  61512. 'Ó¥' => 'Ó¤',
  61513. 'Ó§' => 'Ó¦',
  61514. 'Ó©' => 'Ó¨',
  61515. 'Ó«' => 'Óª',
  61516. 'Ó­' => 'Ó¬',
  61517. 'Ó¯' => 'Ó®',
  61518. 'Ó±' => 'Ó°',
  61519. 'Ó³' => 'Ó²',
  61520. 'Óµ' => 'Ó´',
  61521. 'Ó·' => 'Ó¶',
  61522. 'Ó¹' => 'Ó¸',
  61523. 'Ó»' => 'Óº',
  61524. 'Ó½' => 'Ó¼',
  61525. 'Ó¿' => 'Ó¾',
  61526. 'Ô�' => 'Ô€',
  61527. 'Ôƒ' => 'Ô‚',
  61528. 'Ô…' => 'Ô„',
  61529. 'Ô‡' => 'Ô†',
  61530. 'Ô‰' => 'Ôˆ',
  61531. 'Ô‹' => 'ÔŠ',
  61532. '�' => 'Ԍ',
  61533. 'Ô�' => 'ÔŽ',
  61534. 'Ô‘' => 'Ô�',
  61535. 'Ô“' => 'Ô’',
  61536. 'Ô•' => 'Ô”',
  61537. 'Ô—' => 'Ô–',
  61538. 'Ô™' => 'Ô˜',
  61539. 'Ô›' => 'Ôš',
  61540. '�' => 'Ԝ',
  61541. 'ÔŸ' => 'Ôž',
  61542. 'Ô¡' => 'Ô ',
  61543. 'Ô£' => 'Ô¢',
  61544. 'Ô¥' => 'Ô¤',
  61545. 'Ô§' => 'Ô¦',
  61546. 'Ô©' => 'Ô¨',
  61547. 'Ô«' => 'Ôª',
  61548. 'Ô­' => 'Ô¬',
  61549. 'Ô¯' => 'Ô®',
  61550. 'Õ¡' => 'Ô±',
  61551. 'Õ¢' => 'Ô²',
  61552. 'Õ£' => 'Ô³',
  61553. 'Õ¤' => 'Ô´',
  61554. 'Õ¥' => 'Ôµ',
  61555. 'Õ¦' => 'Ô¶',
  61556. 'Õ§' => 'Ô·',
  61557. 'Õ¨' => 'Ô¸',
  61558. 'Õ©' => 'Ô¹',
  61559. 'Õª' => 'Ôº',
  61560. 'Õ«' => 'Ô»',
  61561. 'Õ¬' => 'Ô¼',
  61562. 'Õ­' => 'Ô½',
  61563. 'Õ®' => 'Ô¾',
  61564. 'Õ¯' => 'Ô¿',
  61565. 'Õ°' => 'Õ€',
  61566. 'Õ±' => 'Õ�',
  61567. 'Õ²' => 'Õ‚',
  61568. 'Õ³' => 'Õƒ',
  61569. 'Õ´' => 'Õ„',
  61570. 'Õµ' => 'Õ…',
  61571. 'Õ¶' => 'Õ†',
  61572. 'Õ·' => 'Õ‡',
  61573. 'Õ¸' => 'Õˆ',
  61574. 'Õ¹' => 'Õ‰',
  61575. 'Õº' => 'ÕŠ',
  61576. 'Õ»' => 'Õ‹',
  61577. 'ռ' => 'Ռ',
  61578. 'Õ½' => 'Õ�',
  61579. 'Õ¾' => 'ÕŽ',
  61580. 'Õ¿' => 'Õ�',
  61581. 'Ö€' => 'Õ�',
  61582. 'Ö�' => 'Õ‘',
  61583. 'Ö‚' => 'Õ’',
  61584. 'Öƒ' => 'Õ“',
  61585. 'Ö„' => 'Õ”',
  61586. 'Ö…' => 'Õ•',
  61587. 'Ö†' => 'Õ–',
  61588. '�' => '�',
  61589. 'ბ' => 'Ბ',
  61590. 'გ' => 'Გ',
  61591. 'დ' => 'Დ',
  61592. 'ე' => 'Ე',
  61593. 'ვ' => 'Ვ',
  61594. 'ზ' => 'Ზ',
  61595. 'თ' => 'Თ',
  61596. 'ი' => 'Ი',
  61597. 'კ' => 'Კ',
  61598. 'ლ' => 'Ლ',
  61599. 'მ' => 'Მ',
  61600. 'ნ' => 'Ნ',
  61601. '�' => '�',
  61602. 'პ' => 'Პ',
  61603. 'ჟ' => 'Ჟ',
  61604. 'რ' => 'Რ',
  61605. 'ს' => 'Ს',
  61606. 'ტ' => 'Ტ',
  61607. 'უ' => 'Უ',
  61608. 'ფ' => 'Ფ',
  61609. 'ქ' => 'Ქ',
  61610. 'ღ' => 'Ღ',
  61611. 'ყ' => 'Ყ',
  61612. 'შ' => 'Შ',
  61613. 'ჩ' => 'Ჩ',
  61614. 'ც' => 'Ც',
  61615. 'ძ' => 'Ძ',
  61616. 'წ' => 'Წ',
  61617. 'ჭ' => 'Ჭ',
  61618. 'ხ' => 'Ხ',
  61619. 'ჯ' => 'Ჯ',
  61620. 'ჰ' => 'Ჰ',
  61621. 'ჱ' => 'Ჱ',
  61622. 'ჲ' => 'Ჲ',
  61623. 'ჳ' => 'Ჳ',
  61624. 'ჴ' => 'Ჴ',
  61625. 'ჵ' => 'Ჵ',
  61626. 'ჶ' => 'Ჶ',
  61627. 'ჷ' => 'Ჷ',
  61628. 'ჸ' => 'Ჸ',
  61629. 'ჹ' => 'Ჹ',
  61630. 'ჺ' => 'Ჺ',
  61631. 'ჽ' => 'Ჽ',
  61632. 'ჾ' => 'Ჾ',
  61633. 'ჿ' => 'Ჿ',
  61634. '�' => '�',
  61635. '�' => '�',
  61636. '�' => '�',
  61637. '�' => '�',
  61638. '�' => '�',
  61639. '�' => '�',
  61640. 'á²€' => 'Ð’',
  61641. '�' => 'Д',
  61642. 'ᲂ' => 'О',
  61643. 'ᲃ' => 'С',
  61644. 'ᲄ' => 'Т',
  61645. 'ᲅ' => 'Т',
  61646. 'ᲆ' => 'Ъ',
  61647. 'ᲇ' => 'Ѣ',
  61648. 'ᲈ' => 'Ꙋ',
  61649. 'ᵹ' => '�',
  61650. 'áµ½' => 'â±£',
  61651. 'ᶎ' => 'Ᶎ',
  61652. '�' => 'Ḁ',
  61653. 'ḃ' => 'Ḃ',
  61654. 'ḅ' => 'Ḅ',
  61655. 'ḇ' => 'Ḇ',
  61656. 'ḉ' => 'Ḉ',
  61657. 'ḋ' => 'Ḋ',
  61658. '�' => 'Ḍ',
  61659. '�' => 'Ḏ',
  61660. 'ḑ' => '�',
  61661. 'ḓ' => 'Ḓ',
  61662. 'ḕ' => 'Ḕ',
  61663. 'ḗ' => 'Ḗ',
  61664. 'ḙ' => 'Ḙ',
  61665. 'ḛ' => 'Ḛ',
  61666. '�' => 'Ḝ',
  61667. 'ḟ' => 'Ḟ',
  61668. 'ḡ' => 'Ḡ',
  61669. 'ḣ' => 'Ḣ',
  61670. 'ḥ' => 'Ḥ',
  61671. 'ḧ' => 'Ḧ',
  61672. 'ḩ' => 'Ḩ',
  61673. 'ḫ' => 'Ḫ',
  61674. 'ḭ' => 'Ḭ',
  61675. 'ḯ' => 'Ḯ',
  61676. 'ḱ' => 'Ḱ',
  61677. 'ḳ' => 'Ḳ',
  61678. 'ḵ' => 'Ḵ',
  61679. 'ḷ' => 'Ḷ',
  61680. 'ḹ' => 'Ḹ',
  61681. 'ḻ' => 'Ḻ',
  61682. 'ḽ' => 'Ḽ',
  61683. 'ḿ' => 'Ḿ',
  61684. '�' => 'Ṁ',
  61685. 'ṃ' => 'Ṃ',
  61686. 'ṅ' => 'Ṅ',
  61687. 'ṇ' => 'Ṇ',
  61688. 'ṉ' => 'Ṉ',
  61689. 'ṋ' => 'Ṋ',
  61690. '�' => 'Ṍ',
  61691. '�' => 'Ṏ',
  61692. 'ṑ' => '�',
  61693. 'ṓ' => 'Ṓ',
  61694. 'ṕ' => 'Ṕ',
  61695. 'á¹—' => 'á¹–',
  61696. 'ṙ' => 'Ṙ',
  61697. 'ṛ' => 'Ṛ',
  61698. '�' => 'Ṝ',
  61699. 'ṟ' => 'Ṟ',
  61700. 'ṡ' => 'Ṡ',
  61701. 'á¹£' => 'á¹¢',
  61702. 'ṥ' => 'Ṥ',
  61703. 'ṧ' => 'Ṧ',
  61704. 'ṩ' => 'Ṩ',
  61705. 'ṫ' => 'Ṫ',
  61706. 'ṭ' => 'Ṭ',
  61707. 'ṯ' => 'Ṯ',
  61708. 'á¹±' => 'á¹°',
  61709. 'á¹³' => 'á¹²',
  61710. 'á¹µ' => 'á¹´',
  61711. 'ṷ' => 'Ṷ',
  61712. 'ṹ' => 'Ṹ',
  61713. 'ṻ' => 'Ṻ',
  61714. 'á¹½' => 'á¹¼',
  61715. 'ṿ' => 'Ṿ',
  61716. '�' => 'Ẁ',
  61717. 'ẃ' => 'Ẃ',
  61718. 'ẅ' => 'Ẅ',
  61719. 'ẇ' => 'Ẇ',
  61720. 'ẉ' => 'Ẉ',
  61721. 'ẋ' => 'Ẋ',
  61722. '�' => 'Ẍ',
  61723. '�' => 'Ẏ',
  61724. 'ẑ' => '�',
  61725. 'ẓ' => 'Ẓ',
  61726. 'ẕ' => 'Ẕ',
  61727. 'ẛ' => 'Ṡ',
  61728. 'ạ' => 'Ạ',
  61729. 'ả' => 'Ả',
  61730. 'ấ' => 'Ấ',
  61731. 'ầ' => 'Ầ',
  61732. 'ẩ' => 'Ẩ',
  61733. 'ẫ' => 'Ẫ',
  61734. 'ậ' => 'Ậ',
  61735. 'ắ' => 'Ắ',
  61736. 'ằ' => 'Ằ',
  61737. 'ẳ' => 'Ẳ',
  61738. 'ẵ' => 'Ẵ',
  61739. 'ặ' => 'Ặ',
  61740. 'ẹ' => 'Ẹ',
  61741. 'ẻ' => 'Ẻ',
  61742. 'ẽ' => 'Ẽ',
  61743. 'ế' => 'Ế',
  61744. '�' => 'Ề',
  61745. 'ể' => 'Ể',
  61746. 'ễ' => 'Ễ',
  61747. 'ệ' => 'Ệ',
  61748. 'ỉ' => 'Ỉ',
  61749. 'ị' => 'Ị',
  61750. '�' => 'Ọ',
  61751. '�' => 'Ỏ',
  61752. 'ố' => '�',
  61753. 'ồ' => 'Ồ',
  61754. 'ổ' => 'Ổ',
  61755. 'á»—' => 'á»–',
  61756. 'ộ' => 'Ộ',
  61757. 'ớ' => 'Ớ',
  61758. '�' => 'Ờ',
  61759. 'ở' => 'Ở',
  61760. 'ỡ' => 'Ỡ',
  61761. 'ợ' => 'Ợ',
  61762. 'ụ' => 'Ụ',
  61763. 'ủ' => 'Ủ',
  61764. 'ứ' => 'Ứ',
  61765. 'ừ' => 'Ừ',
  61766. 'ử' => 'Ử',
  61767. 'ữ' => 'Ữ',
  61768. 'á»±' => 'á»°',
  61769. 'ỳ' => 'Ỳ',
  61770. 'ỵ' => 'Ỵ',
  61771. 'ỷ' => 'Ỷ',
  61772. 'ỹ' => 'Ỹ',
  61773. 'ỻ' => 'Ỻ',
  61774. 'ỽ' => 'Ỽ',
  61775. 'ỿ' => 'Ỿ',
  61776. 'ἀ' => 'Ἀ',
  61777. '�' => 'Ἁ',
  61778. 'ἂ' => 'Ἂ',
  61779. 'ἃ' => 'Ἃ',
  61780. 'ἄ' => 'Ἄ',
  61781. 'ἅ' => '�',
  61782. 'ἆ' => 'Ἆ',
  61783. 'ἇ' => '�',
  61784. '�' => 'Ἐ',
  61785. 'ἑ' => 'Ἑ',
  61786. 'ἒ' => 'Ἒ',
  61787. 'ἓ' => 'Ἓ',
  61788. 'ἔ' => 'Ἔ',
  61789. 'ἕ' => '�',
  61790. 'ἠ' => 'Ἠ',
  61791. 'ἡ' => 'Ἡ',
  61792. 'ἢ' => 'Ἢ',
  61793. 'ἣ' => 'Ἣ',
  61794. 'ἤ' => 'Ἤ',
  61795. 'á¼¥' => 'á¼­',
  61796. 'ἦ' => 'Ἦ',
  61797. 'ἧ' => 'Ἧ',
  61798. 'ἰ' => 'Ἰ',
  61799. 'á¼±' => 'á¼¹',
  61800. 'ἲ' => 'Ἲ',
  61801. 'á¼³' => 'á¼»',
  61802. 'á¼´' => 'á¼¼',
  61803. 'á¼µ' => 'á¼½',
  61804. 'ἶ' => 'Ἶ',
  61805. 'ἷ' => 'Ἷ',
  61806. 'ὀ' => 'Ὀ',
  61807. '�' => 'Ὁ',
  61808. 'ὂ' => 'Ὂ',
  61809. 'ὃ' => 'Ὃ',
  61810. 'ὄ' => 'Ὄ',
  61811. 'ὅ' => '�',
  61812. 'ὑ' => 'Ὑ',
  61813. 'ὓ' => 'Ὓ',
  61814. 'ὕ' => '�',
  61815. 'ὗ' => 'Ὗ',
  61816. 'ὠ' => 'Ὠ',
  61817. 'ὡ' => 'Ὡ',
  61818. 'ὢ' => 'Ὢ',
  61819. 'ὣ' => 'Ὣ',
  61820. 'ὤ' => 'Ὤ',
  61821. 'á½¥' => 'á½­',
  61822. 'ὦ' => 'Ὦ',
  61823. 'ὧ' => 'Ὧ',
  61824. 'ὰ' => 'Ὰ',
  61825. 'á½±' => 'á¾»',
  61826. 'ὲ' => 'Ὲ',
  61827. 'έ' => 'Έ',
  61828. 'á½´' => 'á¿Š',
  61829. 'á½µ' => 'á¿‹',
  61830. 'ὶ' => 'Ὶ',
  61831. 'á½·' => 'á¿›',
  61832. 'ὸ' => 'Ὸ',
  61833. 'ό' => 'Ό',
  61834. 'ὺ' => 'Ὺ',
  61835. 'á½»' => 'á¿«',
  61836. 'ὼ' => 'Ὼ',
  61837. 'á½½' => 'á¿»',
  61838. 'ᾀ' => 'ᾈ',
  61839. '�' => 'ᾉ',
  61840. 'ᾂ' => 'ᾊ',
  61841. 'ᾃ' => 'ᾋ',
  61842. 'ᾄ' => 'ᾌ',
  61843. 'ᾅ' => '�',
  61844. 'ᾆ' => 'ᾎ',
  61845. 'ᾇ' => '�',
  61846. '�' => 'ᾘ',
  61847. 'ᾑ' => 'ᾙ',
  61848. 'ᾒ' => 'ᾚ',
  61849. 'ᾓ' => 'ᾛ',
  61850. 'ᾔ' => 'ᾜ',
  61851. 'ᾕ' => '�',
  61852. 'ᾖ' => 'ᾞ',
  61853. 'ᾗ' => 'ᾟ',
  61854. 'ᾠ' => 'ᾨ',
  61855. 'ᾡ' => 'ᾩ',
  61856. 'ᾢ' => 'ᾪ',
  61857. 'ᾣ' => 'ᾫ',
  61858. 'ᾤ' => 'ᾬ',
  61859. 'á¾¥' => 'á¾­',
  61860. 'ᾦ' => 'ᾮ',
  61861. 'ᾧ' => 'ᾯ',
  61862. 'ᾰ' => 'Ᾰ',
  61863. 'á¾±' => 'á¾¹',
  61864. 'á¾³' => 'á¾¼',
  61865. 'ι' => 'Ι',
  61866. 'ῃ' => 'ῌ',
  61867. '�' => 'Ῐ',
  61868. 'á¿‘' => 'á¿™',
  61869. 'ῠ' => 'Ῠ',
  61870. 'á¿¡' => 'á¿©',
  61871. 'ῥ' => 'Ῥ',
  61872. 'ῳ' => 'ῼ',
  61873. 'ⅎ' => 'Ⅎ',
  61874. 'â…°' => 'â… ',
  61875. 'â…±' => 'â…¡',
  61876. 'â…²' => 'â…¢',
  61877. 'â…³' => 'â…£',
  61878. 'â…´' => 'â…¤',
  61879. 'â…µ' => 'â…¥',
  61880. 'â…¶' => 'â…¦',
  61881. 'â…·' => 'â…§',
  61882. 'â…¸' => 'â…¨',
  61883. 'â…¹' => 'â…©',
  61884. 'â…º' => 'â…ª',
  61885. 'â…»' => 'â…«',
  61886. 'â…¼' => 'â…¬',
  61887. 'â…½' => 'â…­',
  61888. 'â…¾' => 'â…®',
  61889. 'â…¿' => 'â…¯',
  61890. 'ↄ' => 'Ↄ',
  61891. '�' => 'Ⓐ',
  61892. 'â“‘' => 'â’·',
  61893. 'â“’' => 'â’¸',
  61894. 'â““' => 'â’¹',
  61895. 'â“”' => 'â’º',
  61896. 'â“•' => 'â’»',
  61897. 'â“–' => 'â’¼',
  61898. 'â“—' => 'â’½',
  61899. 'ⓘ' => 'Ⓘ',
  61900. 'â“™' => 'â’¿',
  61901. 'â“š' => 'â“€',
  61902. 'ⓛ' => '�',
  61903. 'ⓜ' => 'Ⓜ',
  61904. '�' => 'Ⓝ',
  61905. 'â“ž' => 'â“„',
  61906. 'â“Ÿ' => 'â“…',
  61907. 'ⓠ' => 'Ⓠ',
  61908. 'ⓡ' => 'Ⓡ',
  61909. 'ⓢ' => 'Ⓢ',
  61910. 'ⓣ' => 'Ⓣ',
  61911. 'ⓤ' => 'Ⓤ',
  61912. 'â“¥' => 'â“‹',
  61913. 'ⓦ' => 'Ⓦ',
  61914. 'ⓧ' => '�',
  61915. 'ⓨ' => 'Ⓨ',
  61916. 'ⓩ' => '�',
  61917. 'â°°' => 'â°€',
  61918. 'â°±' => 'â°�',
  61919. 'â°²' => 'â°‚',
  61920. 'â°³' => 'â°ƒ',
  61921. 'â°´' => 'â°„',
  61922. 'â°µ' => 'â°…',
  61923. 'â°¶' => 'â°†',
  61924. 'â°·' => 'â°‡',
  61925. 'â°¸' => 'â°ˆ',
  61926. 'â°¹' => 'â°‰',
  61927. 'â°º' => 'â°Š',
  61928. 'â°»' => 'â°‹',
  61929. 'ⰼ' => 'Ⰼ',
  61930. 'â°½' => 'â°�',
  61931. 'â°¾' => 'â°Ž',
  61932. 'â°¿' => 'â°�',
  61933. 'â±€' => 'â°�',
  61934. '�' => 'Ⱁ',
  61935. 'ⱂ' => 'Ⱂ',
  61936. 'ⱃ' => 'Ⱃ',
  61937. 'ⱄ' => 'Ⱄ',
  61938. 'â±…' => 'â°•',
  61939. 'ⱆ' => 'Ⱆ',
  61940. 'ⱇ' => 'Ⱇ',
  61941. 'ⱈ' => 'Ⱈ',
  61942. 'ⱉ' => 'Ⱉ',
  61943. 'ⱊ' => 'Ⱊ',
  61944. 'ⱋ' => 'Ⱋ',
  61945. 'ⱌ' => 'Ⱌ',
  61946. '�' => '�',
  61947. 'ⱎ' => 'Ⱎ',
  61948. '�' => 'Ⱏ',
  61949. '�' => 'Ⱐ',
  61950. 'ⱑ' => 'Ⱑ',
  61951. 'â±’' => 'â°¢',
  61952. 'ⱓ' => 'Ⱓ',
  61953. 'â±”' => 'â°¤',
  61954. 'ⱕ' => 'Ⱕ',
  61955. 'â±–' => 'â°¦',
  61956. 'â±—' => 'â°§',
  61957. 'ⱘ' => 'Ⱘ',
  61958. 'â±™' => 'â°©',
  61959. 'ⱚ' => 'Ⱚ',
  61960. 'â±›' => 'â°«',
  61961. 'ⱜ' => 'Ⱜ',
  61962. '�' => 'Ⱝ',
  61963. 'ⱞ' => 'Ⱞ',
  61964. 'ⱡ' => 'Ⱡ',
  61965. 'ⱥ' => 'Ⱥ',
  61966. 'ⱦ' => 'Ⱦ',
  61967. 'ⱨ' => 'Ⱨ',
  61968. 'ⱪ' => 'Ⱪ',
  61969. 'ⱬ' => 'Ⱬ',
  61970. 'â±³' => 'â±²',
  61971. 'ⱶ' => 'Ⱶ',
  61972. '�' => 'Ⲁ',
  61973. 'ⲃ' => 'Ⲃ',
  61974. 'ⲅ' => 'Ⲅ',
  61975. 'ⲇ' => 'Ⲇ',
  61976. 'ⲉ' => 'Ⲉ',
  61977. 'ⲋ' => 'Ⲋ',
  61978. '�' => 'Ⲍ',
  61979. '�' => 'Ⲏ',
  61980. 'ⲑ' => '�',
  61981. 'ⲓ' => 'Ⲓ',
  61982. 'ⲕ' => 'Ⲕ',
  61983. 'â²—' => 'â²–',
  61984. 'ⲙ' => 'Ⲙ',
  61985. 'ⲛ' => 'Ⲛ',
  61986. '�' => 'Ⲝ',
  61987. 'ⲟ' => 'Ⲟ',
  61988. 'ⲡ' => 'Ⲡ',
  61989. 'â²£' => 'â²¢',
  61990. 'ⲥ' => 'Ⲥ',
  61991. 'ⲧ' => 'Ⲧ',
  61992. 'ⲩ' => 'Ⲩ',
  61993. 'ⲫ' => 'Ⲫ',
  61994. 'ⲭ' => 'Ⲭ',
  61995. 'ⲯ' => 'Ⲯ',
  61996. 'â²±' => 'â²°',
  61997. 'â²³' => 'â²²',
  61998. 'â²µ' => 'â²´',
  61999. 'ⲷ' => 'Ⲷ',
  62000. 'ⲹ' => 'Ⲹ',
  62001. 'ⲻ' => 'Ⲻ',
  62002. 'â²½' => 'â²¼',
  62003. 'ⲿ' => 'Ⲿ',
  62004. '�' => 'Ⳁ',
  62005. 'ⳃ' => 'Ⳃ',
  62006. 'ⳅ' => 'Ⳅ',
  62007. 'ⳇ' => 'Ⳇ',
  62008. 'ⳉ' => 'Ⳉ',
  62009. 'ⳋ' => 'Ⳋ',
  62010. '�' => 'Ⳍ',
  62011. '�' => 'Ⳏ',
  62012. 'ⳑ' => '�',
  62013. 'ⳓ' => 'Ⳓ',
  62014. 'ⳕ' => 'Ⳕ',
  62015. 'â³—' => 'â³–',
  62016. 'ⳙ' => 'Ⳙ',
  62017. 'ⳛ' => 'Ⳛ',
  62018. '�' => 'Ⳝ',
  62019. 'ⳟ' => 'Ⳟ',
  62020. 'ⳡ' => 'Ⳡ',
  62021. 'â³£' => 'â³¢',
  62022. 'ⳬ' => 'Ⳬ',
  62023. 'â³®' => 'â³­',
  62024. 'â³³' => 'â³²',
  62025. 'â´€' => 'á‚ ',
  62026. 'â´�' => 'á‚¡',
  62027. 'â´‚' => 'á‚¢',
  62028. 'â´ƒ' => 'á‚£',
  62029. 'ⴄ' => 'Ⴄ',
  62030. 'â´…' => 'á‚¥',
  62031. 'ⴆ' => 'Ⴆ',
  62032. 'ⴇ' => 'Ⴇ',
  62033. 'ⴈ' => 'Ⴈ',
  62034. 'â´‰' => 'á‚©',
  62035. 'ⴊ' => 'Ⴊ',
  62036. 'â´‹' => 'á‚«',
  62037. 'ⴌ' => 'Ⴌ',
  62038. 'â´�' => 'á‚­',
  62039. 'â´Ž' => 'á‚®',
  62040. '�' => 'Ⴏ',
  62041. 'â´�' => 'á‚°',
  62042. 'ⴑ' => 'Ⴑ',
  62043. 'ⴒ' => 'Ⴒ',
  62044. 'ⴓ' => 'Ⴓ',
  62045. 'â´”' => 'á‚´',
  62046. 'ⴕ' => 'Ⴕ',
  62047. 'ⴖ' => 'Ⴖ',
  62048. 'â´—' => 'á‚·',
  62049. 'ⴘ' => 'Ⴘ',
  62050. 'ⴙ' => 'Ⴙ',
  62051. 'ⴚ' => 'Ⴚ',
  62052. 'â´›' => 'á‚»',
  62053. 'ⴜ' => 'Ⴜ',
  62054. '�' => 'Ⴝ',
  62055. 'ⴞ' => 'Ⴞ',
  62056. 'â´Ÿ' => 'á‚¿',
  62057. 'ⴠ' => 'Ⴠ',
  62058. 'ⴡ' => '�',
  62059. 'ⴢ' => 'Ⴢ',
  62060. 'ⴣ' => 'Ⴣ',
  62061. 'ⴤ' => 'Ⴤ',
  62062. 'ⴥ' => 'Ⴥ',
  62063. 'ⴧ' => 'Ⴧ',
  62064. 'ⴭ' => '�',
  62065. '�' => 'Ꙁ',
  62066. 'ꙃ' => 'Ꙃ',
  62067. 'ꙅ' => 'Ꙅ',
  62068. 'ꙇ' => 'Ꙇ',
  62069. 'ꙉ' => 'Ꙉ',
  62070. 'ꙋ' => 'Ꙋ',
  62071. '�' => 'Ꙍ',
  62072. '�' => 'Ꙏ',
  62073. 'ꙑ' => '�',
  62074. 'ꙓ' => 'Ꙓ',
  62075. 'ꙕ' => 'Ꙕ',
  62076. 'ê™—' => 'ê™–',
  62077. 'ꙙ' => 'Ꙙ',
  62078. 'ꙛ' => 'Ꙛ',
  62079. '�' => 'Ꙝ',
  62080. 'ꙟ' => 'Ꙟ',
  62081. 'ꙡ' => 'Ꙡ',
  62082. 'ꙣ' => 'Ꙣ',
  62083. 'ꙥ' => 'Ꙥ',
  62084. 'ꙧ' => 'Ꙧ',
  62085. 'ꙩ' => 'Ꙩ',
  62086. 'ꙫ' => 'Ꙫ',
  62087. 'ꙭ' => 'Ꙭ',
  62088. '�' => 'Ꚁ',
  62089. 'ꚃ' => 'Ꚃ',
  62090. 'êš…' => 'êš„',
  62091. 'ꚇ' => 'Ꚇ',
  62092. 'ꚉ' => 'Ꚉ',
  62093. 'ꚋ' => 'Ꚋ',
  62094. '�' => 'Ꚍ',
  62095. '�' => 'Ꚏ',
  62096. 'ꚑ' => '�',
  62097. 'êš“' => 'êš’',
  62098. 'êš•' => 'êš”',
  62099. 'êš—' => 'êš–',
  62100. 'ꚙ' => 'Ꚙ',
  62101. 'êš›' => 'êšš',
  62102. 'ꜣ' => 'Ꜣ',
  62103. 'ꜥ' => 'Ꜥ',
  62104. 'ꜧ' => 'Ꜧ',
  62105. 'ꜩ' => 'Ꜩ',
  62106. 'ꜫ' => 'Ꜫ',
  62107. 'ꜭ' => 'Ꜭ',
  62108. 'ꜯ' => 'Ꜯ',
  62109. 'ꜳ' => 'Ꜳ',
  62110. 'ꜵ' => 'Ꜵ',
  62111. 'ꜷ' => 'Ꜷ',
  62112. 'ꜹ' => 'Ꜹ',
  62113. 'ꜻ' => 'Ꜻ',
  62114. 'ꜽ' => 'Ꜽ',
  62115. 'ꜿ' => 'Ꜿ',
  62116. '�' => '�',
  62117. '�' => '�',
  62118. '�' => '�',
  62119. '�' => '�',
  62120. '�' => '�',
  62121. '�' => '�',
  62122. '�' => '�',
  62123. '�' => '�',
  62124. '�' => '�',
  62125. '�' => '�',
  62126. '�' => '�',
  62127. '�' => '�',
  62128. '�' => '�',
  62129. '�' => '�',
  62130. '�' => '�',
  62131. '�' => '�',
  62132. '�' => '�',
  62133. '�' => '�',
  62134. '�' => '�',
  62135. '�' => '�',
  62136. '�' => '�',
  62137. '�' => '�',
  62138. '�' => '�',
  62139. '�' => '�',
  62140. '�' => '�',
  62141. '�' => '�',
  62142. '�' => '�',
  62143. '�' => 'Ꞁ',
  62144. 'ꞃ' => 'Ꞃ',
  62145. 'êž…' => 'êž„',
  62146. 'ꞇ' => 'Ꞇ',
  62147. 'ꞌ' => 'Ꞌ',
  62148. 'ꞑ' => '�',
  62149. 'êž“' => 'êž’',
  62150. 'ꞔ' => 'Ꞔ',
  62151. 'êž—' => 'êž–',
  62152. 'ꞙ' => 'Ꞙ',
  62153. 'êž›' => 'êžš',
  62154. '�' => 'Ꞝ',
  62155. 'ꞟ' => 'Ꞟ',
  62156. 'êž¡' => 'êž ',
  62157. 'ꞣ' => 'Ꞣ',
  62158. 'ꞥ' => 'Ꞥ',
  62159. 'ꞧ' => 'Ꞧ',
  62160. 'ꞩ' => 'Ꞩ',
  62161. 'êžµ' => 'êž´',
  62162. 'ꞷ' => 'Ꞷ',
  62163. 'ꞹ' => 'Ꞹ',
  62164. 'ꞻ' => 'Ꞻ',
  62165. 'êž½' => 'êž¼',
  62166. 'êž¿' => 'êž¾',
  62167. 'ꟃ' => 'Ꟃ',
  62168. 'ꟈ' => 'Ꟈ',
  62169. 'ꟊ' => 'Ꟊ',
  62170. 'ꟶ' => 'Ꟶ',
  62171. 'ê­“' => 'êž³',
  62172. 'ꭰ' => 'Ꭰ',
  62173. 'ꭱ' => 'Ꭱ',
  62174. 'ꭲ' => 'Ꭲ',
  62175. 'ꭳ' => 'Ꭳ',
  62176. 'ꭴ' => 'Ꭴ',
  62177. 'ꭵ' => 'Ꭵ',
  62178. 'ꭶ' => 'Ꭶ',
  62179. 'ꭷ' => 'Ꭷ',
  62180. 'ꭸ' => 'Ꭸ',
  62181. 'ꭹ' => 'Ꭹ',
  62182. 'ꭺ' => 'Ꭺ',
  62183. 'ꭻ' => 'Ꭻ',
  62184. 'ꭼ' => 'Ꭼ',
  62185. 'ꭽ' => 'Ꭽ',
  62186. 'ꭾ' => 'Ꭾ',
  62187. 'ꭿ' => 'Ꭿ',
  62188. 'ꮀ' => 'Ꮀ',
  62189. '�' => 'Ꮁ',
  62190. 'ꮂ' => 'Ꮂ',
  62191. 'ꮃ' => 'Ꮃ',
  62192. 'ꮄ' => 'Ꮄ',
  62193. 'ꮅ' => 'Ꮅ',
  62194. 'ꮆ' => 'Ꮆ',
  62195. 'ꮇ' => 'Ꮇ',
  62196. 'ꮈ' => 'Ꮈ',
  62197. 'ꮉ' => 'Ꮉ',
  62198. 'ꮊ' => 'Ꮊ',
  62199. 'ꮋ' => 'Ꮋ',
  62200. 'ꮌ' => 'Ꮌ',
  62201. '�' => 'Ꮍ',
  62202. 'ꮎ' => 'Ꮎ',
  62203. '�' => 'Ꮏ',
  62204. '�' => '�',
  62205. 'ꮑ' => '�',
  62206. 'ꮒ' => '�',
  62207. 'ꮓ' => '�',
  62208. 'ꮔ' => '�',
  62209. 'ꮕ' => '�',
  62210. 'ꮖ' => '�',
  62211. 'ꮗ' => '�',
  62212. 'ꮘ' => '�',
  62213. 'ꮙ' => '�',
  62214. 'ꮚ' => '�',
  62215. 'ꮛ' => '�',
  62216. 'ꮜ' => '�',
  62217. '�' => '�',
  62218. 'ꮞ' => '�',
  62219. 'ꮟ' => '�',
  62220. 'ꮠ' => '�',
  62221. 'ꮡ' => '�',
  62222. 'ꮢ' => '�',
  62223. 'ꮣ' => '�',
  62224. 'ꮤ' => '�',
  62225. 'ꮥ' => '�',
  62226. 'ꮦ' => '�',
  62227. 'ꮧ' => '�',
  62228. 'ꮨ' => '�',
  62229. 'ꮩ' => '�',
  62230. 'ꮪ' => '�',
  62231. 'ꮫ' => '�',
  62232. 'ꮬ' => '�',
  62233. 'ꮭ' => '�',
  62234. 'ꮮ' => '�',
  62235. 'ꮯ' => '�',
  62236. 'ꮰ' => '�',
  62237. 'ꮱ' => '�',
  62238. 'ꮲ' => '�',
  62239. 'ꮳ' => '�',
  62240. 'ꮴ' => '�',
  62241. 'ꮵ' => '�',
  62242. 'ꮶ' => '�',
  62243. 'ꮷ' => '�',
  62244. 'ꮸ' => '�',
  62245. 'ꮹ' => '�',
  62246. 'ꮺ' => '�',
  62247. 'ꮻ' => '�',
  62248. 'ꮼ' => '�',
  62249. 'ꮽ' => '�',
  62250. 'ꮾ' => '�',
  62251. 'ꮿ' => '�',
  62252. '�' => 'A',
  62253. 'b' => 'B',
  62254. 'c' => 'C',
  62255. 'd' => 'D',
  62256. 'ï½…' => 'ï¼¥',
  62257. 'f' => 'F',
  62258. 'g' => 'G',
  62259. 'h' => 'H',
  62260. 'i' => 'I',
  62261. 'j' => 'J',
  62262. 'k' => 'K',
  62263. 'l' => 'L',
  62264. '�' => 'M',
  62265. 'n' => 'N',
  62266. '�' => 'O',
  62267. '�' => 'P',
  62268. 'q' => 'Q',
  62269. 'ï½’' => 'ï¼²',
  62270. 's' => 'S',
  62271. 'ï½”' => 'ï¼´',
  62272. 'u' => 'U',
  62273. 'v' => 'V',
  62274. 'ï½—' => 'ï¼·',
  62275. 'x' => 'X',
  62276. 'ï½™' => 'ï¼¹',
  62277. 'z' => 'Z',
  62278. '�' => '�',
  62279. '�' => '�',
  62280. '�' => '�',
  62281. '�' => '�',
  62282. '�' => '�',
  62283. '�' => '�',
  62284. '�' => '�',
  62285. '�' => '�',
  62286. '�' => '�',
  62287. '�' => '�',
  62288. '�' => '�',
  62289. '�' => '�',
  62290. '�' => '�',
  62291. '�' => '�',
  62292. '�' => '�',
  62293. '�' => '�',
  62294. '�' => '�',
  62295. '�' => '�',
  62296. '�' => '�',
  62297. '�' => '�',
  62298. '�' => '�',
  62299. '�' => '�',
  62300. '�' => '�',
  62301. '�' => '�',
  62302. '�' => '�',
  62303. '�' => '�',
  62304. '�' => '�',
  62305. '�' => '�',
  62306. '�' => '�',
  62307. '�' => '�',
  62308. '�' => '�',
  62309. '�' => '�',
  62310. '�' => '�',
  62311. '�' => '�',
  62312. '�' => '�',
  62313. '�' => '�',
  62314. '�' => '�',
  62315. '�' => '�',
  62316. '�' => '�',
  62317. '�' => '�',
  62318. '�' => '�',
  62319. '�' => '�',
  62320. '�' => '�',
  62321. '�' => '�',
  62322. '�' => '�',
  62323. '�' => '�',
  62324. '�' => '�',
  62325. '�' => '�',
  62326. '�' => '�',
  62327. '�' => '�',
  62328. '�' => '�',
  62329. '�' => '�',
  62330. '�' => '�',
  62331. '�' => '�',
  62332. '�' => '�',
  62333. '�' => '�',
  62334. '�' => '�',
  62335. '�' => '�',
  62336. '�' => '�',
  62337. '�' => '�',
  62338. '�' => '�',
  62339. '�' => '�',
  62340. '�' => '�',
  62341. '�' => '�',
  62342. '�' => '�',
  62343. '�' => '�',
  62344. '�' => '�',
  62345. '�' => '�',
  62346. '�' => '�',
  62347. '�' => '�',
  62348. '�' => '�',
  62349. '�' => '�',
  62350. '�' => '�',
  62351. '�' => '�',
  62352. '�' => '�',
  62353. '�' => '�',
  62354. '�' => '�',
  62355. '�' => '�',
  62356. '�' => '�',
  62357. '�' => '�',
  62358. '�' => '�',
  62359. '�' => '�',
  62360. '�' => '�',
  62361. '�' => '�',
  62362. '�' => '�',
  62363. '�' => '�',
  62364. '�' => '�',
  62365. '�' => '�',
  62366. '�' => '�',
  62367. '�' => '�',
  62368. '�' => '�',
  62369. '�' => '�',
  62370. '�' => '�',
  62371. '�' => '�',
  62372. '�' => '�',
  62373. '�' => '�',
  62374. '�' => '�',
  62375. '�' => '�',
  62376. '�' => '�',
  62377. '�' => '�',
  62378. '�' => '�',
  62379. '�' => '�',
  62380. '�' => '�',
  62381. '�' => '�',
  62382. '�' => '�',
  62383. '�' => '�',
  62384. '�' => '�',
  62385. '�' => '�',
  62386. '�' => '�',
  62387. '�' => '�',
  62388. '�' => '�',
  62389. '�' => '�',
  62390. '�' => '�',
  62391. '�' => '�',
  62392. '�' => '�',
  62393. '�' => '�',
  62394. '�' => '�',
  62395. '�' => '�',
  62396. '�' => '�',
  62397. '�' => '�',
  62398. '�' => '�',
  62399. '�' => '�',
  62400. '�' => '�',
  62401. '�' => '�',
  62402. '�' => '�',
  62403. '�' => '�',
  62404. '�' => '�',
  62405. 'ð‘£€' => 'ð‘¢ ',
  62406. '�' => '𑢡',
  62407. '𑣂' => '𑢢',
  62408. '𑣃' => '𑢣',
  62409. '𑣄' => '𑢤',
  62410. 'ð‘£…' => 'ð‘¢¥',
  62411. '𑣆' => '𑢦',
  62412. '𑣇' => '𑢧',
  62413. '𑣈' => '𑢨',
  62414. '𑣉' => '𑢩',
  62415. '𑣊' => '𑢪',
  62416. '𑣋' => '𑢫',
  62417. '𑣌' => '𑢬',
  62418. '�' => '𑢭',
  62419. '𑣎' => '𑢮',
  62420. '�' => '𑢯',
  62421. '�' => '𑢰',
  62422. '𑣑' => '𑢱',
  62423. 'ð‘£’' => 'ð‘¢²',
  62424. '𑣓' => '𑢳',
  62425. 'ð‘£”' => 'ð‘¢´',
  62426. '𑣕' => '𑢵',
  62427. '𑣖' => '𑢶',
  62428. 'ð‘£—' => 'ð‘¢·',
  62429. '𑣘' => '𑢸',
  62430. 'ð‘£™' => 'ð‘¢¹',
  62431. '𑣚' => '𑢺',
  62432. 'ð‘£›' => 'ð‘¢»',
  62433. '𑣜' => '𑢼',
  62434. '�' => '𑢽',
  62435. '𑣞' => '𑢾',
  62436. '𑣟' => '𑢿',
  62437. 'ð–¹ ' => 'ð–¹€',
  62438. '𖹡' => '�',
  62439. '𖹢' => '𖹂',
  62440. '𖹣' => '𖹃',
  62441. '𖹤' => '𖹄',
  62442. 'ð–¹¥' => 'ð–¹…',
  62443. '𖹦' => '𖹆',
  62444. '𖹧' => '𖹇',
  62445. '𖹨' => '𖹈',
  62446. '𖹩' => '𖹉',
  62447. '𖹪' => '𖹊',
  62448. '𖹫' => '𖹋',
  62449. '𖹬' => '𖹌',
  62450. '𖹭' => '�',
  62451. '𖹮' => '𖹎',
  62452. '𖹯' => '�',
  62453. '𖹰' => '�',
  62454. '𖹱' => '𖹑',
  62455. 'ð–¹²' => 'ð–¹’',
  62456. '𖹳' => '𖹓',
  62457. 'ð–¹´' => 'ð–¹”',
  62458. '𖹵' => '𖹕',
  62459. '𖹶' => '𖹖',
  62460. 'ð–¹·' => 'ð–¹—',
  62461. '𖹸' => '𖹘',
  62462. 'ð–¹¹' => 'ð–¹™',
  62463. '𖹺' => '𖹚',
  62464. 'ð–¹»' => 'ð–¹›',
  62465. '𖹼' => '𖹜',
  62466. '𖹽' => '�',
  62467. '𖹾' => '𖹞',
  62468. '𖹿' => '𖹟',
  62469. '𞤢' => '𞤀',
  62470. '𞤣' => '�',
  62471. '𞤤' => '𞤂',
  62472. '𞤥' => '𞤃',
  62473. '𞤦' => '𞤄',
  62474. '𞤧' => '𞤅',
  62475. '𞤨' => '𞤆',
  62476. '𞤩' => '𞤇',
  62477. '𞤪' => '𞤈',
  62478. '𞤫' => '𞤉',
  62479. '𞤬' => '𞤊',
  62480. '𞤭' => '𞤋',
  62481. '𞤮' => '𞤌',
  62482. '𞤯' => '�',
  62483. '𞤰' => '𞤎',
  62484. '𞤱' => '�',
  62485. '𞤲' => '�',
  62486. '𞤳' => '𞤑',
  62487. '𞤴' => '𞤒',
  62488. '𞤵' => '𞤓',
  62489. '𞤶' => '𞤔',
  62490. '𞤷' => '𞤕',
  62491. '𞤸' => '𞤖',
  62492. '𞤹' => '𞤗',
  62493. '𞤺' => '𞤘',
  62494. '𞤻' => '𞤙',
  62495. '𞤼' => '𞤚',
  62496. '𞤽' => '𞤛',
  62497. '𞤾' => '𞤜',
  62498. '𞤿' => '�',
  62499. '𞥀' => '𞤞',
  62500. '�' => '𞤟',
  62501. '𞥂' => '𞤠',
  62502. '𞥃' => '𞤡',
  62503. );
  62504. <?php
  62505. use Symfony\Polyfill\Mbstring as p;
  62506. if (!function_exists('mb_convert_encoding')) {
  62507. function mb_convert_encoding($string, $to_encoding, $from_encoding = null) { return p\Mbstring::mb_convert_encoding($string, $to_encoding, $from_encoding); }
  62508. }
  62509. if (!function_exists('mb_decode_mimeheader')) {
  62510. function mb_decode_mimeheader($string) { return p\Mbstring::mb_decode_mimeheader($string); }
  62511. }
  62512. if (!function_exists('mb_encode_mimeheader')) {
  62513. function mb_encode_mimeheader($string, $charset = null, $transfer_encoding = null, $newline = null, $indent = null) { return p\Mbstring::mb_encode_mimeheader($string, $charset, $transfer_encoding, $newline, $indent); }
  62514. }
  62515. if (!function_exists('mb_decode_numericentity')) {
  62516. function mb_decode_numericentity($string, $map, $encoding = null) { return p\Mbstring::mb_decode_numericentity($string, $map, $encoding); }
  62517. }
  62518. if (!function_exists('mb_encode_numericentity')) {
  62519. function mb_encode_numericentity($string, $map, $encoding = null, $hex = false) { return p\Mbstring::mb_encode_numericentity($string, $map, $encoding, $hex); }
  62520. }
  62521. if (!function_exists('mb_convert_case')) {
  62522. function mb_convert_case($string, $mode, $encoding = null) { return p\Mbstring::mb_convert_case($string, $mode, $encoding); }
  62523. }
  62524. if (!function_exists('mb_internal_encoding')) {
  62525. function mb_internal_encoding($encoding = null) { return p\Mbstring::mb_internal_encoding($encoding); }
  62526. }
  62527. if (!function_exists('mb_language')) {
  62528. function mb_language($language = null) { return p\Mbstring::mb_language($language); }
  62529. }
  62530. if (!function_exists('mb_list_encodings')) {
  62531. function mb_list_encodings() { return p\Mbstring::mb_list_encodings(); }
  62532. }
  62533. if (!function_exists('mb_encoding_aliases')) {
  62534. function mb_encoding_aliases($encoding) { return p\Mbstring::mb_encoding_aliases($encoding); }
  62535. }
  62536. if (!function_exists('mb_check_encoding')) {
  62537. function mb_check_encoding($value = null, $encoding = null) { return p\Mbstring::mb_check_encoding($value, $encoding); }
  62538. }
  62539. if (!function_exists('mb_detect_encoding')) {
  62540. function mb_detect_encoding($string, $encodings = null, $strict = false) { return p\Mbstring::mb_detect_encoding($string, $encodings, $strict); }
  62541. }
  62542. if (!function_exists('mb_detect_order')) {
  62543. function mb_detect_order($encoding = null) { return p\Mbstring::mb_detect_order($encoding); }
  62544. }
  62545. if (!function_exists('mb_parse_str')) {
  62546. function mb_parse_str($string, &$result = array()) { parse_str($string, $result); }
  62547. }
  62548. if (!function_exists('mb_strlen')) {
  62549. function mb_strlen($string, $encoding = null) { return p\Mbstring::mb_strlen($string, $encoding); }
  62550. }
  62551. if (!function_exists('mb_strpos')) {
  62552. function mb_strpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strpos($haystack, $needle, $offset, $encoding); }
  62553. }
  62554. if (!function_exists('mb_strtolower')) {
  62555. function mb_strtolower($string, $encoding = null) { return p\Mbstring::mb_strtolower($string, $encoding); }
  62556. }
  62557. if (!function_exists('mb_strtoupper')) {
  62558. function mb_strtoupper($string, $encoding = null) { return p\Mbstring::mb_strtoupper($string, $encoding); }
  62559. }
  62560. if (!function_exists('mb_substitute_character')) {
  62561. function mb_substitute_character($substitute_character = null) { return p\Mbstring::mb_substitute_character($substitute_character); }
  62562. }
  62563. if (!function_exists('mb_substr')) {
  62564. function mb_substr($string, $start, $length = 2147483647, $encoding = null) { return p\Mbstring::mb_substr($string, $start, $length, $encoding); }
  62565. }
  62566. if (!function_exists('mb_stripos')) {
  62567. function mb_stripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_stripos($haystack, $needle, $offset, $encoding); }
  62568. }
  62569. if (!function_exists('mb_stristr')) {
  62570. function mb_stristr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_stristr($haystack, $needle, $before_needle, $encoding); }
  62571. }
  62572. if (!function_exists('mb_strrchr')) {
  62573. function mb_strrchr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrchr($haystack, $needle, $before_needle, $encoding); }
  62574. }
  62575. if (!function_exists('mb_strrichr')) {
  62576. function mb_strrichr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strrichr($haystack, $needle, $before_needle, $encoding); }
  62577. }
  62578. if (!function_exists('mb_strripos')) {
  62579. function mb_strripos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strripos($haystack, $needle, $offset, $encoding); }
  62580. }
  62581. if (!function_exists('mb_strrpos')) {
  62582. function mb_strrpos($haystack, $needle, $offset = 0, $encoding = null) { return p\Mbstring::mb_strrpos($haystack, $needle, $offset, $encoding); }
  62583. }
  62584. if (!function_exists('mb_strstr')) {
  62585. function mb_strstr($haystack, $needle, $before_needle = false, $encoding = null) { return p\Mbstring::mb_strstr($haystack, $needle, $before_needle, $encoding); }
  62586. }
  62587. if (!function_exists('mb_get_info')) {
  62588. function mb_get_info($type = 'all') { return p\Mbstring::mb_get_info($type); }
  62589. }
  62590. if (!function_exists('mb_http_output')) {
  62591. function mb_http_output($encoding = null) { return p\Mbstring::mb_http_output($encoding); }
  62592. }
  62593. if (!function_exists('mb_strwidth')) {
  62594. function mb_strwidth($string, $encoding = null) { return p\Mbstring::mb_strwidth($string, $encoding); }
  62595. }
  62596. if (!function_exists('mb_substr_count')) {
  62597. function mb_substr_count($haystack, $needle, $encoding = null) { return p\Mbstring::mb_substr_count($haystack, $needle, $encoding); }
  62598. }
  62599. if (!function_exists('mb_output_handler')) {
  62600. function mb_output_handler($string, $status) { return p\Mbstring::mb_output_handler($string, $status); }
  62601. }
  62602. if (!function_exists('mb_http_input')) {
  62603. function mb_http_input($type = '') { return p\Mbstring::mb_http_input($type); }
  62604. }
  62605. if (PHP_VERSION_ID >= 80000) {
  62606. require_once __DIR__.'/Resources/mb_convert_variables.php8';
  62607. } elseif (!function_exists('mb_convert_variables')) {
  62608. 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); }
  62609. }
  62610. if (!function_exists('mb_ord')) {
  62611. function mb_ord($string, $encoding = null) { return p\Mbstring::mb_ord($string, $encoding); }
  62612. }
  62613. if (!function_exists('mb_chr')) {
  62614. function mb_chr($codepoint, $encoding = null) { return p\Mbstring::mb_chr($codepoint, $encoding); }
  62615. }
  62616. if (!function_exists('mb_scrub')) {
  62617. function mb_scrub($string, $encoding = null) { $encoding = null === $encoding ? mb_internal_encoding() : $encoding; return mb_convert_encoding($string, $encoding, $encoding); }
  62618. }
  62619. if (!function_exists('mb_str_split')) {
  62620. function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
  62621. }
  62622. if (extension_loaded('mbstring')) {
  62623. return;
  62624. }
  62625. if (!defined('MB_CASE_UPPER')) {
  62626. define('MB_CASE_UPPER', 0);
  62627. }
  62628. if (!defined('MB_CASE_LOWER')) {
  62629. define('MB_CASE_LOWER', 1);
  62630. }
  62631. if (!defined('MB_CASE_TITLE')) {
  62632. define('MB_CASE_TITLE', 2);
  62633. }
  62634. <?php
  62635. namespace Symfony\Component\Process\Exception;
  62636. interface ExceptionInterface
  62637. {
  62638. }
  62639. <?php
  62640. namespace Symfony\Component\Process\Exception;
  62641. class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface
  62642. {
  62643. }
  62644. <?php
  62645. namespace Symfony\Component\Process\Exception;
  62646. class LogicException extends \LogicException implements ExceptionInterface
  62647. {
  62648. }
  62649. <?php
  62650. namespace Symfony\Component\Process\Exception;
  62651. use Symfony\Component\Process\Process;
  62652. class ProcessFailedException extends RuntimeException
  62653. {
  62654. private $process;
  62655. public function __construct(Process $process)
  62656. {
  62657. if ($process->isSuccessful()) {
  62658. throw new InvalidArgumentException('Expected a failed process, but the given process was successful.');
  62659. }
  62660. $error = sprintf('The command "%s" failed.'."\n\nExit Code: %s(%s)\n\nWorking directory: %s",
  62661. $process->getCommandLine(),
  62662. $process->getExitCode(),
  62663. $process->getExitCodeText(),
  62664. $process->getWorkingDirectory()
  62665. );
  62666. if (!$process->isOutputDisabled()) {
  62667. $error .= sprintf("\n\nOutput:\n================\n%s\n\nError Output:\n================\n%s",
  62668. $process->getOutput(),
  62669. $process->getErrorOutput()
  62670. );
  62671. }
  62672. parent::__construct($error);
  62673. $this->process = $process;
  62674. }
  62675. public function getProcess()
  62676. {
  62677. return $this->process;
  62678. }
  62679. }
  62680. <?php
  62681. namespace Symfony\Component\Process\Exception;
  62682. use Symfony\Component\Process\Process;
  62683. class ProcessTimedOutException extends RuntimeException
  62684. {
  62685. const TYPE_GENERAL = 1;
  62686. const TYPE_IDLE = 2;
  62687. private $process;
  62688. private $timeoutType;
  62689. public function __construct(Process $process, $timeoutType)
  62690. {
  62691. $this->process = $process;
  62692. $this->timeoutType = $timeoutType;
  62693. parent::__construct(sprintf(
  62694. 'The process "%s" exceeded the timeout of %s seconds.',
  62695. $process->getCommandLine(),
  62696. $this->getExceededTimeout()
  62697. ));
  62698. }
  62699. public function getProcess()
  62700. {
  62701. return $this->process;
  62702. }
  62703. public function isGeneralTimeout()
  62704. {
  62705. return self::TYPE_GENERAL === $this->timeoutType;
  62706. }
  62707. public function isIdleTimeout()
  62708. {
  62709. return self::TYPE_IDLE === $this->timeoutType;
  62710. }
  62711. public function getExceededTimeout()
  62712. {
  62713. switch ($this->timeoutType) {
  62714. case self::TYPE_GENERAL:
  62715. return $this->process->getTimeout();
  62716. case self::TYPE_IDLE:
  62717. return $this->process->getIdleTimeout();
  62718. default:
  62719. throw new \LogicException(sprintf('Unknown timeout type "%d".', $this->timeoutType));
  62720. }
  62721. }
  62722. }
  62723. <?php
  62724. namespace Symfony\Component\Process\Exception;
  62725. class RuntimeException extends \RuntimeException implements ExceptionInterface
  62726. {
  62727. }
  62728. <?php
  62729. namespace Symfony\Component\Process;
  62730. class ExecutableFinder
  62731. {
  62732. private $suffixes = array('.exe', '.bat', '.cmd', '.com');
  62733. public function setSuffixes(array $suffixes)
  62734. {
  62735. $this->suffixes = $suffixes;
  62736. }
  62737. public function addSuffix($suffix)
  62738. {
  62739. $this->suffixes[] = $suffix;
  62740. }
  62741. public function find($name, $default = null, array $extraDirs = array())
  62742. {
  62743. if (ini_get('open_basedir')) {
  62744. $searchPath = explode(PATH_SEPARATOR, ini_get('open_basedir'));
  62745. $dirs = array();
  62746. foreach ($searchPath as $path) {
  62747. if (@is_dir($path)) {
  62748. $dirs[] = $path;
  62749. } else {
  62750. if (basename($path) == $name && @is_executable($path)) {
  62751. return $path;
  62752. }
  62753. }
  62754. }
  62755. } else {
  62756. $dirs = array_merge(
  62757. explode(PATH_SEPARATOR, getenv('PATH') ?: getenv('Path')),
  62758. $extraDirs
  62759. );
  62760. }
  62761. $suffixes = array('');
  62762. if ('\\' === \DIRECTORY_SEPARATOR) {
  62763. $pathExt = getenv('PATHEXT');
  62764. $suffixes = array_merge($pathExt ? explode(PATH_SEPARATOR, $pathExt) : $this->suffixes, $suffixes);
  62765. }
  62766. foreach ($suffixes as $suffix) {
  62767. foreach ($dirs as $dir) {
  62768. if (@is_file($file = $dir.\DIRECTORY_SEPARATOR.$name.$suffix) && ('\\' === \DIRECTORY_SEPARATOR || @is_executable($file))) {
  62769. return $file;
  62770. }
  62771. }
  62772. }
  62773. return $default;
  62774. }
  62775. }
  62776. Copyright (c) 2004-2018 Fabien Potencier
  62777. Permission is hereby granted, free of charge, to any person obtaining a copy
  62778. of this software and associated documentation files (the "Software"), to deal
  62779. in the Software without restriction, including without limitation the rights
  62780. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  62781. copies of the Software, and to permit persons to whom the Software is furnished
  62782. to do so, subject to the following conditions:
  62783. The above copyright notice and this permission notice shall be included in all
  62784. copies or substantial portions of the Software.
  62785. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  62786. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  62787. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  62788. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  62789. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  62790. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  62791. THE SOFTWARE.
  62792. <?php
  62793. namespace Symfony\Component\Process;
  62794. class PhpExecutableFinder
  62795. {
  62796. private $executableFinder;
  62797. public function __construct()
  62798. {
  62799. $this->executableFinder = new ExecutableFinder();
  62800. }
  62801. public function find($includeArgs = true)
  62802. {
  62803. $args = $this->findArguments();
  62804. $args = $includeArgs && $args ? ' '.implode(' ', $args) : '';
  62805. if (\defined('HHVM_VERSION')) {
  62806. return (getenv('PHP_BINARY') ?: PHP_BINARY).$args;
  62807. }
  62808. if (\defined('PHP_BINARY') && PHP_BINARY && \in_array(\PHP_SAPI, array('cli', 'cli-server', 'phpdbg'), true)) {
  62809. return PHP_BINARY.$args;
  62810. }
  62811. if ($php = getenv('PHP_PATH')) {
  62812. if (!@is_executable($php)) {
  62813. return false;
  62814. }
  62815. return $php;
  62816. }
  62817. if ($php = getenv('PHP_PEAR_PHP_BIN')) {
  62818. if (@is_executable($php)) {
  62819. return $php;
  62820. }
  62821. }
  62822. if (@is_executable($php = PHP_BINDIR.('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php'))) {
  62823. return $php;
  62824. }
  62825. $dirs = array(PHP_BINDIR);
  62826. if ('\\' === \DIRECTORY_SEPARATOR) {
  62827. $dirs[] = 'C:\xampp\php\\';
  62828. }
  62829. return $this->executableFinder->find('php', false, $dirs);
  62830. }
  62831. public function findArguments()
  62832. {
  62833. $arguments = array();
  62834. if (\defined('HHVM_VERSION')) {
  62835. $arguments[] = '--php';
  62836. } elseif ('phpdbg' === \PHP_SAPI) {
  62837. $arguments[] = '-qrr';
  62838. }
  62839. return $arguments;
  62840. }
  62841. }
  62842. <?php
  62843. namespace Symfony\Component\Process;
  62844. use Symfony\Component\Process\Exception\RuntimeException;
  62845. class PhpProcess extends Process
  62846. {
  62847. public function __construct($script, $cwd = null, array $env = null, $timeout = 60, array $options = array())
  62848. {
  62849. $executableFinder = new PhpExecutableFinder();
  62850. if (false === $php = $executableFinder->find()) {
  62851. $php = null;
  62852. }
  62853. if ('phpdbg' === \PHP_SAPI) {
  62854. $file = tempnam(sys_get_temp_dir(), 'dbg');
  62855. file_put_contents($file, $script);
  62856. register_shutdown_function('unlink', $file);
  62857. $php .= ' '.ProcessUtils::escapeArgument($file);
  62858. $script = null;
  62859. }
  62860. if ('\\' !== \DIRECTORY_SEPARATOR && null !== $php) {
  62861. $php = 'exec '.$php;
  62862. }
  62863. parent::__construct($php, $cwd, $env, $script, $timeout, $options);
  62864. }
  62865. public function setPhpBinary($php)
  62866. {
  62867. $this->setCommandLine($php);
  62868. }
  62869. public function start($callback = null)
  62870. {
  62871. if (null === $this->getCommandLine()) {
  62872. throw new RuntimeException('Unable to find the PHP executable.');
  62873. }
  62874. parent::start($callback);
  62875. }
  62876. }
  62877. <?php
  62878. namespace Symfony\Component\Process\Pipes;
  62879. abstract class AbstractPipes implements PipesInterface
  62880. {
  62881. public $pipes = array();
  62882. private $inputBuffer = '';
  62883. private $input;
  62884. private $blocked = true;
  62885. private $lastError;
  62886. public function __construct($input)
  62887. {
  62888. if (\is_resource($input)) {
  62889. $this->input = $input;
  62890. } elseif (\is_string($input)) {
  62891. $this->inputBuffer = $input;
  62892. } else {
  62893. $this->inputBuffer = (string) $input;
  62894. }
  62895. }
  62896. public function close()
  62897. {
  62898. foreach ($this->pipes as $pipe) {
  62899. fclose($pipe);
  62900. }
  62901. $this->pipes = array();
  62902. }
  62903. protected function hasSystemCallBeenInterrupted()
  62904. {
  62905. $lastError = $this->lastError;
  62906. $this->lastError = null;
  62907. return null !== $lastError && false !== stripos($lastError, 'interrupted system call');
  62908. }
  62909. protected function unblock()
  62910. {
  62911. if (!$this->blocked) {
  62912. return;
  62913. }
  62914. foreach ($this->pipes as $pipe) {
  62915. stream_set_blocking($pipe, 0);
  62916. }
  62917. if (null !== $this->input) {
  62918. stream_set_blocking($this->input, 0);
  62919. }
  62920. $this->blocked = false;
  62921. }
  62922. protected function write()
  62923. {
  62924. if (!isset($this->pipes[0])) {
  62925. return;
  62926. }
  62927. $input = $this->input;
  62928. $r = $e = array();
  62929. $w = array($this->pipes[0]);
  62930. if (false === @stream_select($r, $w, $e, 0, 0)) {
  62931. return;
  62932. }
  62933. foreach ($w as $stdin) {
  62934. if (isset($this->inputBuffer[0])) {
  62935. $written = fwrite($stdin, $this->inputBuffer);
  62936. $this->inputBuffer = substr($this->inputBuffer, $written);
  62937. if (isset($this->inputBuffer[0])) {
  62938. return array($this->pipes[0]);
  62939. }
  62940. }
  62941. if ($input) {
  62942. for (;;) {
  62943. $data = fread($input, self::CHUNK_SIZE);
  62944. if (!isset($data[0])) {
  62945. break;
  62946. }
  62947. $written = fwrite($stdin, $data);
  62948. $data = substr($data, $written);
  62949. if (isset($data[0])) {
  62950. $this->inputBuffer = $data;
  62951. return array($this->pipes[0]);
  62952. }
  62953. }
  62954. if (feof($input)) {
  62955. $this->input = null;
  62956. }
  62957. }
  62958. }
  62959. if (null === $this->input && !isset($this->inputBuffer[0])) {
  62960. fclose($this->pipes[0]);
  62961. unset($this->pipes[0]);
  62962. } elseif (!$w) {
  62963. return array($this->pipes[0]);
  62964. }
  62965. }
  62966. public function handleError($type, $msg)
  62967. {
  62968. $this->lastError = $msg;
  62969. }
  62970. }
  62971. <?php
  62972. namespace Symfony\Component\Process\Pipes;
  62973. interface PipesInterface
  62974. {
  62975. const CHUNK_SIZE = 16384;
  62976. public function getDescriptors();
  62977. public function getFiles();
  62978. public function readAndWrite($blocking, $close = false);
  62979. public function areOpen();
  62980. public function close();
  62981. }
  62982. <?php
  62983. namespace Symfony\Component\Process\Pipes;
  62984. use Symfony\Component\Process\Process;
  62985. class UnixPipes extends AbstractPipes
  62986. {
  62987. private $ttyMode;
  62988. private $ptyMode;
  62989. private $disableOutput;
  62990. public function __construct($ttyMode, $ptyMode, $input, $disableOutput)
  62991. {
  62992. $this->ttyMode = (bool) $ttyMode;
  62993. $this->ptyMode = (bool) $ptyMode;
  62994. $this->disableOutput = (bool) $disableOutput;
  62995. parent::__construct($input);
  62996. }
  62997. public function __destruct()
  62998. {
  62999. $this->close();
  63000. }
  63001. public function getDescriptors()
  63002. {
  63003. if ($this->disableOutput) {
  63004. $nullstream = fopen('/dev/null', 'c');
  63005. return array(
  63006. array('pipe', 'r'),
  63007. $nullstream,
  63008. $nullstream,
  63009. );
  63010. }
  63011. if ($this->ttyMode) {
  63012. return array(
  63013. array('file', '/dev/tty', 'r'),
  63014. array('file', '/dev/tty', 'w'),
  63015. array('file', '/dev/tty', 'w'),
  63016. );
  63017. }
  63018. if ($this->ptyMode && Process::isPtySupported()) {
  63019. return array(
  63020. array('pty'),
  63021. array('pty'),
  63022. array('pty'),
  63023. );
  63024. }
  63025. return array(
  63026. array('pipe', 'r'),
  63027. array('pipe', 'w'),
  63028. array('pipe', 'w'),
  63029. );
  63030. }
  63031. public function getFiles()
  63032. {
  63033. return array();
  63034. }
  63035. public function readAndWrite($blocking, $close = false)
  63036. {
  63037. $this->unblock();
  63038. $w = $this->write();
  63039. $read = $e = array();
  63040. $r = $this->pipes;
  63041. unset($r[0]);
  63042. set_error_handler(array($this, 'handleError'));
  63043. if (($r || $w) && false === stream_select($r, $w, $e, 0, $blocking ? Process::TIMEOUT_PRECISION * 1E6 : 0)) {
  63044. restore_error_handler();
  63045. if (!$this->hasSystemCallBeenInterrupted()) {
  63046. $this->pipes = array();
  63047. }
  63048. return $read;
  63049. }
  63050. restore_error_handler();
  63051. foreach ($r as $pipe) {
  63052. $read[$type = array_search($pipe, $this->pipes, true)] = '';
  63053. do {
  63054. $data = fread($pipe, self::CHUNK_SIZE);
  63055. $read[$type] .= $data;
  63056. } while (isset($data[0]) && ($close || isset($data[self::CHUNK_SIZE - 1])));
  63057. if (!isset($read[$type][0])) {
  63058. unset($read[$type]);
  63059. }
  63060. if ($close && feof($pipe)) {
  63061. fclose($pipe);
  63062. unset($this->pipes[$type]);
  63063. }
  63064. }
  63065. return $read;
  63066. }
  63067. public function areOpen()
  63068. {
  63069. return (bool) $this->pipes;
  63070. }
  63071. public static function create(Process $process, $input)
  63072. {
  63073. return new static($process->isTty(), $process->isPty(), $input, $process->isOutputDisabled());
  63074. }
  63075. }
  63076. <?php
  63077. namespace Symfony\Component\Process\Pipes;
  63078. use Symfony\Component\Process\Exception\RuntimeException;
  63079. use Symfony\Component\Process\Process;
  63080. class WindowsPipes extends AbstractPipes
  63081. {
  63082. private $files = array();
  63083. private $fileHandles = array();
  63084. private $lockHandles = array();
  63085. private $readBytes = array(
  63086. Process::STDOUT => 0,
  63087. Process::STDERR => 0,
  63088. );
  63089. private $disableOutput;
  63090. public function __construct($disableOutput, $input)
  63091. {
  63092. $this->disableOutput = (bool) $disableOutput;
  63093. if (!$this->disableOutput) {
  63094. $pipes = array(
  63095. Process::STDOUT => Process::OUT,
  63096. Process::STDERR => Process::ERR,
  63097. );
  63098. $tmpDir = sys_get_temp_dir();
  63099. $lastError = 'unknown reason';
  63100. set_error_handler(function ($type, $msg) use (&$lastError) { $lastError = $msg; });
  63101. for ($i = 0;; ++$i) {
  63102. foreach ($pipes as $pipe => $name) {
  63103. $file = sprintf('%s\\sf_proc_%02X.%s', $tmpDir, $i, $name);
  63104. if (!$h = fopen($file.'.lock', 'w')) {
  63105. restore_error_handler();
  63106. throw new RuntimeException(sprintf('A temporary file could not be opened to write the process output: %s', $lastError));
  63107. }
  63108. if (!flock($h, LOCK_EX | LOCK_NB)) {
  63109. continue 2;
  63110. }
  63111. if (isset($this->lockHandles[$pipe])) {
  63112. flock($this->lockHandles[$pipe], LOCK_UN);
  63113. fclose($this->lockHandles[$pipe]);
  63114. }
  63115. $this->lockHandles[$pipe] = $h;
  63116. if (!fclose(fopen($file, 'w')) || !$h = fopen($file, 'r')) {
  63117. flock($this->lockHandles[$pipe], LOCK_UN);
  63118. fclose($this->lockHandles[$pipe]);
  63119. unset($this->lockHandles[$pipe]);
  63120. continue 2;
  63121. }
  63122. $this->fileHandles[$pipe] = $h;
  63123. $this->files[$pipe] = $file;
  63124. }
  63125. break;
  63126. }
  63127. restore_error_handler();
  63128. }
  63129. parent::__construct($input);
  63130. }
  63131. public function __destruct()
  63132. {
  63133. $this->close();
  63134. }
  63135. public function getDescriptors()
  63136. {
  63137. if ($this->disableOutput) {
  63138. $nullstream = fopen('NUL', 'c');
  63139. return array(
  63140. array('pipe', 'r'),
  63141. $nullstream,
  63142. $nullstream,
  63143. );
  63144. }
  63145. return array(
  63146. array('pipe', 'r'),
  63147. array('file', 'NUL', 'w'),
  63148. array('file', 'NUL', 'w'),
  63149. );
  63150. }
  63151. public function getFiles()
  63152. {
  63153. return $this->files;
  63154. }
  63155. public function readAndWrite($blocking, $close = false)
  63156. {
  63157. $this->unblock();
  63158. $w = $this->write();
  63159. $read = $r = $e = array();
  63160. if ($blocking) {
  63161. if ($w) {
  63162. @stream_select($r, $w, $e, 0, Process::TIMEOUT_PRECISION * 1E6);
  63163. } elseif ($this->fileHandles) {
  63164. usleep(Process::TIMEOUT_PRECISION * 1E6);
  63165. }
  63166. }
  63167. foreach ($this->fileHandles as $type => $fileHandle) {
  63168. $data = stream_get_contents($fileHandle, -1, $this->readBytes[$type]);
  63169. if (isset($data[0])) {
  63170. $this->readBytes[$type] += \strlen($data);
  63171. $read[$type] = $data;
  63172. }
  63173. if ($close) {
  63174. ftruncate($fileHandle, 0);
  63175. fclose($fileHandle);
  63176. flock($this->lockHandles[$type], LOCK_UN);
  63177. fclose($this->lockHandles[$type]);
  63178. unset($this->fileHandles[$type], $this->lockHandles[$type]);
  63179. }
  63180. }
  63181. return $read;
  63182. }
  63183. public function areOpen()
  63184. {
  63185. return $this->pipes && $this->fileHandles;
  63186. }
  63187. public function close()
  63188. {
  63189. parent::close();
  63190. foreach ($this->fileHandles as $type => $handle) {
  63191. ftruncate($handle, 0);
  63192. fclose($handle);
  63193. flock($this->lockHandles[$type], LOCK_UN);
  63194. fclose($this->lockHandles[$type]);
  63195. }
  63196. $this->fileHandles = $this->lockHandles = array();
  63197. }
  63198. public static function create(Process $process, $input)
  63199. {
  63200. return new static($process->isOutputDisabled(), $input);
  63201. }
  63202. }
  63203. <?php
  63204. namespace Symfony\Component\Process;
  63205. use Symfony\Component\Process\Exception\InvalidArgumentException;
  63206. use Symfony\Component\Process\Exception\LogicException;
  63207. use Symfony\Component\Process\Exception\ProcessFailedException;
  63208. use Symfony\Component\Process\Exception\ProcessTimedOutException;
  63209. use Symfony\Component\Process\Exception\RuntimeException;
  63210. use Symfony\Component\Process\Pipes\PipesInterface;
  63211. use Symfony\Component\Process\Pipes\UnixPipes;
  63212. use Symfony\Component\Process\Pipes\WindowsPipes;
  63213. class Process
  63214. {
  63215. const ERR = 'err';
  63216. const OUT = 'out';
  63217. const STATUS_READY = 'ready';
  63218. const STATUS_STARTED = 'started';
  63219. const STATUS_TERMINATED = 'terminated';
  63220. const STDIN = 0;
  63221. const STDOUT = 1;
  63222. const STDERR = 2;
  63223. const TIMEOUT_PRECISION = 0.2;
  63224. private $callback;
  63225. private $commandline;
  63226. private $cwd;
  63227. private $env;
  63228. private $input;
  63229. private $starttime;
  63230. private $lastOutputTime;
  63231. private $timeout;
  63232. private $idleTimeout;
  63233. private $options;
  63234. private $exitcode;
  63235. private $fallbackStatus = array();
  63236. private $processInformation;
  63237. private $outputDisabled = false;
  63238. private $stdout;
  63239. private $stderr;
  63240. private $enhanceWindowsCompatibility = true;
  63241. private $enhanceSigchildCompatibility;
  63242. private $process;
  63243. private $status = self::STATUS_READY;
  63244. private $incrementalOutputOffset = 0;
  63245. private $incrementalErrorOutputOffset = 0;
  63246. private $tty;
  63247. private $pty;
  63248. private $useFileHandles = false;
  63249. private $processPipes;
  63250. private $latestSignal;
  63251. private static $sigchild;
  63252. public static $exitCodes = array(
  63253. 0 => 'OK',
  63254. 1 => 'General error',
  63255. 2 => 'Misuse of shell builtins',
  63256. 126 => 'Invoked command cannot execute',
  63257. 127 => 'Command not found',
  63258. 128 => 'Invalid exit argument',
  63259. 129 => 'Hangup',
  63260. 130 => 'Interrupt',
  63261. 131 => 'Quit and dump core',
  63262. 132 => 'Illegal instruction',
  63263. 133 => 'Trace/breakpoint trap',
  63264. 134 => 'Process aborted',
  63265. 135 => 'Bus error: "access to undefined portion of memory object"',
  63266. 136 => 'Floating point exception: "erroneous arithmetic operation"',
  63267. 137 => 'Kill (terminate immediately)',
  63268. 138 => 'User-defined 1',
  63269. 139 => 'Segmentation violation',
  63270. 140 => 'User-defined 2',
  63271. 141 => 'Write to pipe with no one reading',
  63272. 142 => 'Signal raised by alarm',
  63273. 143 => 'Termination (request to terminate)',
  63274. 145 => 'Child process terminated, stopped (or continued*)',
  63275. 146 => 'Continue if stopped',
  63276. 147 => 'Stop executing temporarily',
  63277. 148 => 'Terminal stop signal',
  63278. 149 => 'Background process attempting to read from tty ("in")',
  63279. 150 => 'Background process attempting to write to tty ("out")',
  63280. 151 => 'Urgent data available on socket',
  63281. 152 => 'CPU time limit exceeded',
  63282. 153 => 'File size limit exceeded',
  63283. 154 => 'Signal raised by timer counting virtual time: "virtual timer expired"',
  63284. 155 => 'Profiling timer expired',
  63285. 157 => 'Pollable event',
  63286. 159 => 'Bad syscall',
  63287. );
  63288. public function __construct($commandline, $cwd = null, array $env = null, $input = null, $timeout = 60, array $options = array())
  63289. {
  63290. if (!\function_exists('proc_open')) {
  63291. throw new RuntimeException('The Process class relies on proc_open, which is not available on your PHP installation.');
  63292. }
  63293. $this->commandline = $commandline;
  63294. $this->cwd = $cwd;
  63295. if (null === $this->cwd && (\defined('ZEND_THREAD_SAFE') || '\\' === \DIRECTORY_SEPARATOR)) {
  63296. $this->cwd = getcwd();
  63297. }
  63298. if (null !== $env) {
  63299. $this->setEnv($env);
  63300. }
  63301. $this->setInput($input);
  63302. $this->setTimeout($timeout);
  63303. $this->useFileHandles = '\\' === \DIRECTORY_SEPARATOR;
  63304. $this->pty = false;
  63305. $this->enhanceSigchildCompatibility = '\\' !== \DIRECTORY_SEPARATOR && $this->isSigchildEnabled();
  63306. $this->options = array_replace(array('suppress_errors' => true, 'binary_pipes' => true), $options);
  63307. }
  63308. public function __destruct()
  63309. {
  63310. $this->stop(0);
  63311. }
  63312. public function __clone()
  63313. {
  63314. $this->resetProcessData();
  63315. }
  63316. public function run($callback = null)
  63317. {
  63318. $this->start($callback);
  63319. return $this->wait();
  63320. }
  63321. public function mustRun($callback = null)
  63322. {
  63323. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63324. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  63325. }
  63326. if (0 !== $this->run($callback)) {
  63327. throw new ProcessFailedException($this);
  63328. }
  63329. return $this;
  63330. }
  63331. public function start($callback = null)
  63332. {
  63333. if ($this->isRunning()) {
  63334. throw new RuntimeException('Process is already running');
  63335. }
  63336. if ($this->outputDisabled && null !== $callback) {
  63337. throw new LogicException('Output has been disabled, enable it to allow the use of a callback.');
  63338. }
  63339. $this->resetProcessData();
  63340. $this->starttime = $this->lastOutputTime = microtime(true);
  63341. $this->callback = $this->buildCallback($callback);
  63342. $descriptors = $this->getDescriptors();
  63343. $commandline = $this->commandline;
  63344. if ('\\' === \DIRECTORY_SEPARATOR && $this->enhanceWindowsCompatibility) {
  63345. $commandline = 'cmd /V:ON /E:ON /D /C "('.$commandline.')';
  63346. foreach ($this->processPipes->getFiles() as $offset => $filename) {
  63347. $commandline .= ' '.$offset.'>'.ProcessUtils::escapeArgument($filename);
  63348. }
  63349. $commandline .= '"';
  63350. if (!isset($this->options['bypass_shell'])) {
  63351. $this->options['bypass_shell'] = true;
  63352. }
  63353. } elseif (!$this->useFileHandles && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63354. $descriptors[3] = array('pipe', 'w');
  63355. $commandline = '{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
  63356. $commandline .= 'pid=$!; echo $pid >&3; wait $pid; code=$?; echo $code >&3; exit $code';
  63357. $ptsWorkaround = fopen(__FILE__, 'r');
  63358. }
  63359. $this->process = proc_open($commandline, $descriptors, $this->processPipes->pipes, $this->cwd, $this->env, $this->options);
  63360. if (!\is_resource($this->process)) {
  63361. throw new RuntimeException('Unable to launch a new process.');
  63362. }
  63363. $this->status = self::STATUS_STARTED;
  63364. if (isset($descriptors[3])) {
  63365. $this->fallbackStatus['pid'] = (int) fgets($this->processPipes->pipes[3]);
  63366. }
  63367. if ($this->tty) {
  63368. return;
  63369. }
  63370. $this->updateStatus(false);
  63371. $this->checkTimeout();
  63372. }
  63373. public function restart($callback = null)
  63374. {
  63375. if ($this->isRunning()) {
  63376. throw new RuntimeException('Process is already running');
  63377. }
  63378. $process = clone $this;
  63379. $process->start($callback);
  63380. return $process;
  63381. }
  63382. public function wait($callback = null)
  63383. {
  63384. $this->requireProcessIsStarted(__FUNCTION__);
  63385. $this->updateStatus(false);
  63386. if (null !== $callback) {
  63387. $this->callback = $this->buildCallback($callback);
  63388. }
  63389. do {
  63390. $this->checkTimeout();
  63391. $running = '\\' === \DIRECTORY_SEPARATOR ? $this->isRunning() : $this->processPipes->areOpen();
  63392. $this->readPipes($running, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  63393. } while ($running);
  63394. while ($this->isRunning()) {
  63395. usleep(1000);
  63396. }
  63397. if ($this->processInformation['signaled'] && $this->processInformation['termsig'] !== $this->latestSignal) {
  63398. throw new RuntimeException(sprintf('The process has been signaled with signal "%s".', $this->processInformation['termsig']));
  63399. }
  63400. return $this->exitcode;
  63401. }
  63402. public function getPid()
  63403. {
  63404. return $this->isRunning() ? $this->processInformation['pid'] : null;
  63405. }
  63406. public function signal($signal)
  63407. {
  63408. $this->doSignal($signal, true);
  63409. return $this;
  63410. }
  63411. public function disableOutput()
  63412. {
  63413. if ($this->isRunning()) {
  63414. throw new RuntimeException('Disabling output while the process is running is not possible.');
  63415. }
  63416. if (null !== $this->idleTimeout) {
  63417. throw new LogicException('Output can not be disabled while an idle timeout is set.');
  63418. }
  63419. $this->outputDisabled = true;
  63420. return $this;
  63421. }
  63422. public function enableOutput()
  63423. {
  63424. if ($this->isRunning()) {
  63425. throw new RuntimeException('Enabling output while the process is running is not possible.');
  63426. }
  63427. $this->outputDisabled = false;
  63428. return $this;
  63429. }
  63430. public function isOutputDisabled()
  63431. {
  63432. return $this->outputDisabled;
  63433. }
  63434. public function getOutput()
  63435. {
  63436. $this->readPipesForOutput(__FUNCTION__);
  63437. if (false === $ret = stream_get_contents($this->stdout, -1, 0)) {
  63438. return '';
  63439. }
  63440. return $ret;
  63441. }
  63442. public function getIncrementalOutput()
  63443. {
  63444. $this->readPipesForOutput(__FUNCTION__);
  63445. $latest = stream_get_contents($this->stdout, -1, $this->incrementalOutputOffset);
  63446. $this->incrementalOutputOffset = ftell($this->stdout);
  63447. if (false === $latest) {
  63448. return '';
  63449. }
  63450. return $latest;
  63451. }
  63452. public function clearOutput()
  63453. {
  63454. ftruncate($this->stdout, 0);
  63455. fseek($this->stdout, 0);
  63456. $this->incrementalOutputOffset = 0;
  63457. return $this;
  63458. }
  63459. public function getErrorOutput()
  63460. {
  63461. $this->readPipesForOutput(__FUNCTION__);
  63462. if (false === $ret = stream_get_contents($this->stderr, -1, 0)) {
  63463. return '';
  63464. }
  63465. return $ret;
  63466. }
  63467. public function getIncrementalErrorOutput()
  63468. {
  63469. $this->readPipesForOutput(__FUNCTION__);
  63470. $latest = stream_get_contents($this->stderr, -1, $this->incrementalErrorOutputOffset);
  63471. $this->incrementalErrorOutputOffset = ftell($this->stderr);
  63472. if (false === $latest) {
  63473. return '';
  63474. }
  63475. return $latest;
  63476. }
  63477. public function clearErrorOutput()
  63478. {
  63479. ftruncate($this->stderr, 0);
  63480. fseek($this->stderr, 0);
  63481. $this->incrementalErrorOutputOffset = 0;
  63482. return $this;
  63483. }
  63484. public function getExitCode()
  63485. {
  63486. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63487. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. You must use setEnhanceSigchildCompatibility() to use this method.');
  63488. }
  63489. $this->updateStatus(false);
  63490. return $this->exitcode;
  63491. }
  63492. public function getExitCodeText()
  63493. {
  63494. if (null === $exitcode = $this->getExitCode()) {
  63495. return;
  63496. }
  63497. return isset(self::$exitCodes[$exitcode]) ? self::$exitCodes[$exitcode] : 'Unknown error';
  63498. }
  63499. public function isSuccessful()
  63500. {
  63501. return 0 === $this->getExitCode();
  63502. }
  63503. public function hasBeenSignaled()
  63504. {
  63505. $this->requireProcessIsTerminated(__FUNCTION__);
  63506. if (!$this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63507. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  63508. }
  63509. return $this->processInformation['signaled'];
  63510. }
  63511. public function getTermSignal()
  63512. {
  63513. $this->requireProcessIsTerminated(__FUNCTION__);
  63514. if ($this->isSigchildEnabled() && (!$this->enhanceSigchildCompatibility || -1 === $this->processInformation['termsig'])) {
  63515. throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
  63516. }
  63517. return $this->processInformation['termsig'];
  63518. }
  63519. public function hasBeenStopped()
  63520. {
  63521. $this->requireProcessIsTerminated(__FUNCTION__);
  63522. return $this->processInformation['stopped'];
  63523. }
  63524. public function getStopSignal()
  63525. {
  63526. $this->requireProcessIsTerminated(__FUNCTION__);
  63527. return $this->processInformation['stopsig'];
  63528. }
  63529. public function isRunning()
  63530. {
  63531. if (self::STATUS_STARTED !== $this->status) {
  63532. return false;
  63533. }
  63534. $this->updateStatus(false);
  63535. return $this->processInformation['running'];
  63536. }
  63537. public function isStarted()
  63538. {
  63539. return self::STATUS_READY != $this->status;
  63540. }
  63541. public function isTerminated()
  63542. {
  63543. $this->updateStatus(false);
  63544. return self::STATUS_TERMINATED == $this->status;
  63545. }
  63546. public function getStatus()
  63547. {
  63548. $this->updateStatus(false);
  63549. return $this->status;
  63550. }
  63551. public function stop($timeout = 10, $signal = null)
  63552. {
  63553. $timeoutMicro = microtime(true) + $timeout;
  63554. if ($this->isRunning()) {
  63555. $this->doSignal(15, false);
  63556. do {
  63557. usleep(1000);
  63558. } while ($this->isRunning() && microtime(true) < $timeoutMicro);
  63559. if ($this->isRunning()) {
  63560. $this->doSignal($signal ?: 9, false);
  63561. }
  63562. }
  63563. if ($this->isRunning()) {
  63564. if (isset($this->fallbackStatus['pid'])) {
  63565. unset($this->fallbackStatus['pid']);
  63566. return $this->stop(0, $signal);
  63567. }
  63568. $this->close();
  63569. }
  63570. return $this->exitcode;
  63571. }
  63572. public function addOutput($line)
  63573. {
  63574. $this->lastOutputTime = microtime(true);
  63575. fseek($this->stdout, 0, SEEK_END);
  63576. fwrite($this->stdout, $line);
  63577. fseek($this->stdout, $this->incrementalOutputOffset);
  63578. }
  63579. public function addErrorOutput($line)
  63580. {
  63581. $this->lastOutputTime = microtime(true);
  63582. fseek($this->stderr, 0, SEEK_END);
  63583. fwrite($this->stderr, $line);
  63584. fseek($this->stderr, $this->incrementalErrorOutputOffset);
  63585. }
  63586. public function getCommandLine()
  63587. {
  63588. return $this->commandline;
  63589. }
  63590. public function setCommandLine($commandline)
  63591. {
  63592. $this->commandline = $commandline;
  63593. return $this;
  63594. }
  63595. public function getTimeout()
  63596. {
  63597. return $this->timeout;
  63598. }
  63599. public function getIdleTimeout()
  63600. {
  63601. return $this->idleTimeout;
  63602. }
  63603. public function setTimeout($timeout)
  63604. {
  63605. $this->timeout = $this->validateTimeout($timeout);
  63606. return $this;
  63607. }
  63608. public function setIdleTimeout($timeout)
  63609. {
  63610. if (null !== $timeout && $this->outputDisabled) {
  63611. throw new LogicException('Idle timeout can not be set while the output is disabled.');
  63612. }
  63613. $this->idleTimeout = $this->validateTimeout($timeout);
  63614. return $this;
  63615. }
  63616. public function setTty($tty)
  63617. {
  63618. if ('\\' === \DIRECTORY_SEPARATOR && $tty) {
  63619. throw new RuntimeException('TTY mode is not supported on Windows platform.');
  63620. }
  63621. if ($tty) {
  63622. static $isTtySupported;
  63623. if (null === $isTtySupported) {
  63624. $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);
  63625. }
  63626. if (!$isTtySupported) {
  63627. throw new RuntimeException('TTY mode requires /dev/tty to be read/writable.');
  63628. }
  63629. }
  63630. $this->tty = (bool) $tty;
  63631. return $this;
  63632. }
  63633. public function isTty()
  63634. {
  63635. return $this->tty;
  63636. }
  63637. public function setPty($bool)
  63638. {
  63639. $this->pty = (bool) $bool;
  63640. return $this;
  63641. }
  63642. public function isPty()
  63643. {
  63644. return $this->pty;
  63645. }
  63646. public function getWorkingDirectory()
  63647. {
  63648. if (null === $this->cwd) {
  63649. return getcwd() ?: null;
  63650. }
  63651. return $this->cwd;
  63652. }
  63653. public function setWorkingDirectory($cwd)
  63654. {
  63655. $this->cwd = $cwd;
  63656. return $this;
  63657. }
  63658. public function getEnv()
  63659. {
  63660. return $this->env;
  63661. }
  63662. public function setEnv(array $env)
  63663. {
  63664. $env = array_filter($env, function ($value) {
  63665. return !\is_array($value);
  63666. });
  63667. $this->env = array();
  63668. foreach ($env as $key => $value) {
  63669. $this->env[$key] = (string) $value;
  63670. }
  63671. return $this;
  63672. }
  63673. public function getStdin()
  63674. {
  63675. @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);
  63676. return $this->getInput();
  63677. }
  63678. public function getInput()
  63679. {
  63680. return $this->input;
  63681. }
  63682. public function setStdin($stdin)
  63683. {
  63684. @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);
  63685. return $this->setInput($stdin);
  63686. }
  63687. public function setInput($input)
  63688. {
  63689. if ($this->isRunning()) {
  63690. throw new LogicException('Input can not be set while the process is running.');
  63691. }
  63692. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  63693. return $this;
  63694. }
  63695. public function getOptions()
  63696. {
  63697. return $this->options;
  63698. }
  63699. public function setOptions(array $options)
  63700. {
  63701. $this->options = $options;
  63702. return $this;
  63703. }
  63704. public function getEnhanceWindowsCompatibility()
  63705. {
  63706. return $this->enhanceWindowsCompatibility;
  63707. }
  63708. public function setEnhanceWindowsCompatibility($enhance)
  63709. {
  63710. $this->enhanceWindowsCompatibility = (bool) $enhance;
  63711. return $this;
  63712. }
  63713. public function getEnhanceSigchildCompatibility()
  63714. {
  63715. return $this->enhanceSigchildCompatibility;
  63716. }
  63717. public function setEnhanceSigchildCompatibility($enhance)
  63718. {
  63719. $this->enhanceSigchildCompatibility = (bool) $enhance;
  63720. return $this;
  63721. }
  63722. public function checkTimeout()
  63723. {
  63724. if (self::STATUS_STARTED !== $this->status) {
  63725. return;
  63726. }
  63727. if (null !== $this->timeout && $this->timeout < microtime(true) - $this->starttime) {
  63728. $this->stop(0);
  63729. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_GENERAL);
  63730. }
  63731. if (null !== $this->idleTimeout && $this->idleTimeout < microtime(true) - $this->lastOutputTime) {
  63732. $this->stop(0);
  63733. throw new ProcessTimedOutException($this, ProcessTimedOutException::TYPE_IDLE);
  63734. }
  63735. }
  63736. public static function isPtySupported()
  63737. {
  63738. static $result;
  63739. if (null !== $result) {
  63740. return $result;
  63741. }
  63742. if ('\\' === \DIRECTORY_SEPARATOR) {
  63743. return $result = false;
  63744. }
  63745. return $result = (bool) @proc_open('echo 1 >/dev/null', array(array('pty'), array('pty'), array('pty')), $pipes);
  63746. }
  63747. private function getDescriptors()
  63748. {
  63749. if ('\\' === \DIRECTORY_SEPARATOR) {
  63750. $this->processPipes = WindowsPipes::create($this, $this->input);
  63751. } else {
  63752. $this->processPipes = UnixPipes::create($this, $this->input);
  63753. }
  63754. return $this->processPipes->getDescriptors();
  63755. }
  63756. protected function buildCallback($callback)
  63757. {
  63758. $that = $this;
  63759. $out = self::OUT;
  63760. $callback = function ($type, $data) use ($that, $callback, $out) {
  63761. if ($out == $type) {
  63762. $that->addOutput($data);
  63763. } else {
  63764. $that->addErrorOutput($data);
  63765. }
  63766. if (null !== $callback) {
  63767. \call_user_func($callback, $type, $data);
  63768. }
  63769. };
  63770. return $callback;
  63771. }
  63772. protected function updateStatus($blocking)
  63773. {
  63774. if (self::STATUS_STARTED !== $this->status) {
  63775. return;
  63776. }
  63777. $this->processInformation = proc_get_status($this->process);
  63778. $running = $this->processInformation['running'];
  63779. $this->readPipes($running && $blocking, '\\' !== \DIRECTORY_SEPARATOR || !$running);
  63780. if ($this->fallbackStatus && $this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63781. $this->processInformation = $this->fallbackStatus + $this->processInformation;
  63782. }
  63783. if (!$running) {
  63784. $this->close();
  63785. }
  63786. }
  63787. protected function isSigchildEnabled()
  63788. {
  63789. if (null !== self::$sigchild) {
  63790. return self::$sigchild;
  63791. }
  63792. if (!\function_exists('phpinfo') || \defined('HHVM_VERSION')) {
  63793. return self::$sigchild = false;
  63794. }
  63795. ob_start();
  63796. phpinfo(INFO_GENERAL);
  63797. return self::$sigchild = false !== strpos(ob_get_clean(), '--enable-sigchild');
  63798. }
  63799. private function readPipesForOutput($caller)
  63800. {
  63801. if ($this->outputDisabled) {
  63802. throw new LogicException('Output has been disabled.');
  63803. }
  63804. $this->requireProcessIsStarted($caller);
  63805. $this->updateStatus(false);
  63806. }
  63807. private function validateTimeout($timeout)
  63808. {
  63809. $timeout = (float) $timeout;
  63810. if (0.0 === $timeout) {
  63811. $timeout = null;
  63812. } elseif ($timeout < 0) {
  63813. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  63814. }
  63815. return $timeout;
  63816. }
  63817. private function readPipes($blocking, $close)
  63818. {
  63819. $result = $this->processPipes->readAndWrite($blocking, $close);
  63820. $callback = $this->callback;
  63821. foreach ($result as $type => $data) {
  63822. if (3 !== $type) {
  63823. $callback(self::STDOUT === $type ? self::OUT : self::ERR, $data);
  63824. } elseif (!isset($this->fallbackStatus['signaled'])) {
  63825. $this->fallbackStatus['exitcode'] = (int) $data;
  63826. }
  63827. }
  63828. }
  63829. private function close()
  63830. {
  63831. $this->processPipes->close();
  63832. if (\is_resource($this->process)) {
  63833. proc_close($this->process);
  63834. }
  63835. $this->exitcode = $this->processInformation['exitcode'];
  63836. $this->status = self::STATUS_TERMINATED;
  63837. if (-1 === $this->exitcode) {
  63838. if ($this->processInformation['signaled'] && 0 < $this->processInformation['termsig']) {
  63839. $this->exitcode = 128 + $this->processInformation['termsig'];
  63840. } elseif ($this->enhanceSigchildCompatibility && $this->isSigchildEnabled()) {
  63841. $this->processInformation['signaled'] = true;
  63842. $this->processInformation['termsig'] = -1;
  63843. }
  63844. }
  63845. $this->callback = null;
  63846. return $this->exitcode;
  63847. }
  63848. private function resetProcessData()
  63849. {
  63850. $this->starttime = null;
  63851. $this->callback = null;
  63852. $this->exitcode = null;
  63853. $this->fallbackStatus = array();
  63854. $this->processInformation = null;
  63855. $this->stdout = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  63856. $this->stderr = fopen('php://temp/maxmemory:'.(1024 * 1024), 'w+b');
  63857. $this->process = null;
  63858. $this->latestSignal = null;
  63859. $this->status = self::STATUS_READY;
  63860. $this->incrementalOutputOffset = 0;
  63861. $this->incrementalErrorOutputOffset = 0;
  63862. }
  63863. private function doSignal($signal, $throwException)
  63864. {
  63865. if (null === $pid = $this->getPid()) {
  63866. if ($throwException) {
  63867. throw new LogicException('Can not send signal on a non running process.');
  63868. }
  63869. return false;
  63870. }
  63871. if ('\\' === \DIRECTORY_SEPARATOR) {
  63872. exec(sprintf('taskkill /F /T /PID %d 2>&1', $pid), $output, $exitCode);
  63873. if ($exitCode && $this->isRunning()) {
  63874. if ($throwException) {
  63875. throw new RuntimeException(sprintf('Unable to kill the process (%s).', implode(' ', $output)));
  63876. }
  63877. return false;
  63878. }
  63879. } else {
  63880. if (!$this->enhanceSigchildCompatibility || !$this->isSigchildEnabled()) {
  63881. $ok = @proc_terminate($this->process, $signal);
  63882. } elseif (\function_exists('posix_kill')) {
  63883. $ok = @posix_kill($pid, $signal);
  63884. } elseif ($ok = proc_open(sprintf('kill -%d %d', $signal, $pid), array(2 => array('pipe', 'w')), $pipes)) {
  63885. $ok = false === fgets($pipes[2]);
  63886. }
  63887. if (!$ok) {
  63888. if ($throwException) {
  63889. throw new RuntimeException(sprintf('Error while sending signal `%s`.', $signal));
  63890. }
  63891. return false;
  63892. }
  63893. }
  63894. $this->latestSignal = (int) $signal;
  63895. $this->fallbackStatus['signaled'] = true;
  63896. $this->fallbackStatus['exitcode'] = -1;
  63897. $this->fallbackStatus['termsig'] = $this->latestSignal;
  63898. return true;
  63899. }
  63900. private function requireProcessIsStarted($functionName)
  63901. {
  63902. if (!$this->isStarted()) {
  63903. throw new LogicException(sprintf('Process must be started before calling %s.', $functionName));
  63904. }
  63905. }
  63906. private function requireProcessIsTerminated($functionName)
  63907. {
  63908. if (!$this->isTerminated()) {
  63909. throw new LogicException(sprintf('Process must be terminated before calling %s.', $functionName));
  63910. }
  63911. }
  63912. }
  63913. <?php
  63914. namespace Symfony\Component\Process;
  63915. use Symfony\Component\Process\Exception\InvalidArgumentException;
  63916. use Symfony\Component\Process\Exception\LogicException;
  63917. class ProcessBuilder
  63918. {
  63919. private $arguments;
  63920. private $cwd;
  63921. private $env = array();
  63922. private $input;
  63923. private $timeout = 60;
  63924. private $options = array();
  63925. private $inheritEnv = true;
  63926. private $prefix = array();
  63927. private $outputDisabled = false;
  63928. public function __construct(array $arguments = array())
  63929. {
  63930. $this->arguments = $arguments;
  63931. }
  63932. public static function create(array $arguments = array())
  63933. {
  63934. return new static($arguments);
  63935. }
  63936. public function add($argument)
  63937. {
  63938. $this->arguments[] = $argument;
  63939. return $this;
  63940. }
  63941. public function setPrefix($prefix)
  63942. {
  63943. $this->prefix = \is_array($prefix) ? $prefix : array($prefix);
  63944. return $this;
  63945. }
  63946. public function setArguments(array $arguments)
  63947. {
  63948. $this->arguments = $arguments;
  63949. return $this;
  63950. }
  63951. public function setWorkingDirectory($cwd)
  63952. {
  63953. $this->cwd = $cwd;
  63954. return $this;
  63955. }
  63956. public function inheritEnvironmentVariables($inheritEnv = true)
  63957. {
  63958. $this->inheritEnv = $inheritEnv;
  63959. return $this;
  63960. }
  63961. public function setEnv($name, $value)
  63962. {
  63963. $this->env[$name] = $value;
  63964. return $this;
  63965. }
  63966. public function addEnvironmentVariables(array $variables)
  63967. {
  63968. $this->env = array_replace($this->env, $variables);
  63969. return $this;
  63970. }
  63971. public function setInput($input)
  63972. {
  63973. $this->input = ProcessUtils::validateInput(__METHOD__, $input);
  63974. return $this;
  63975. }
  63976. public function setTimeout($timeout)
  63977. {
  63978. if (null === $timeout) {
  63979. $this->timeout = null;
  63980. return $this;
  63981. }
  63982. $timeout = (float) $timeout;
  63983. if ($timeout < 0) {
  63984. throw new InvalidArgumentException('The timeout value must be a valid positive integer or float number.');
  63985. }
  63986. $this->timeout = $timeout;
  63987. return $this;
  63988. }
  63989. public function setOption($name, $value)
  63990. {
  63991. $this->options[$name] = $value;
  63992. return $this;
  63993. }
  63994. public function disableOutput()
  63995. {
  63996. $this->outputDisabled = true;
  63997. return $this;
  63998. }
  63999. public function enableOutput()
  64000. {
  64001. $this->outputDisabled = false;
  64002. return $this;
  64003. }
  64004. public function getProcess()
  64005. {
  64006. if (0 === \count($this->prefix) && 0 === \count($this->arguments)) {
  64007. throw new LogicException('You must add() command arguments before calling getProcess().');
  64008. }
  64009. $options = $this->options;
  64010. $arguments = array_merge($this->prefix, $this->arguments);
  64011. $script = implode(' ', array_map(array(__NAMESPACE__.'\\ProcessUtils', 'escapeArgument'), $arguments));
  64012. if ($this->inheritEnv) {
  64013. $env = array_replace($_ENV, $_SERVER, $this->env);
  64014. } else {
  64015. $env = $this->env;
  64016. }
  64017. $process = new Process($script, $this->cwd, $env, $this->input, $this->timeout, $options);
  64018. if ($this->outputDisabled) {
  64019. $process->disableOutput();
  64020. }
  64021. return $process;
  64022. }
  64023. }
  64024. <?php
  64025. namespace Symfony\Component\Process;
  64026. use Symfony\Component\Process\Exception\InvalidArgumentException;
  64027. class ProcessUtils
  64028. {
  64029. private function __construct()
  64030. {
  64031. }
  64032. public static function escapeArgument($argument)
  64033. {
  64034. if ('\\' === \DIRECTORY_SEPARATOR) {
  64035. if ('' === $argument) {
  64036. return escapeshellarg($argument);
  64037. }
  64038. $escapedArgument = '';
  64039. $quote = false;
  64040. foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
  64041. if ('"' === $part) {
  64042. $escapedArgument .= '\\"';
  64043. } elseif (self::isSurroundedBy($part, '%')) {
  64044. $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
  64045. } else {
  64046. if ('\\' === substr($part, -1)) {
  64047. $part .= '\\';
  64048. }
  64049. $quote = true;
  64050. $escapedArgument .= $part;
  64051. }
  64052. }
  64053. if ($quote) {
  64054. $escapedArgument = '"'.$escapedArgument.'"';
  64055. }
  64056. return $escapedArgument;
  64057. }
  64058. return "'".str_replace("'", "'\\''", $argument)."'";
  64059. }
  64060. public static function validateInput($caller, $input)
  64061. {
  64062. if (null !== $input) {
  64063. if (\is_resource($input)) {
  64064. return $input;
  64065. }
  64066. if (\is_string($input)) {
  64067. return $input;
  64068. }
  64069. if (is_scalar($input)) {
  64070. return (string) $input;
  64071. }
  64072. if (\is_object($input) && method_exists($input, '__toString')) {
  64073. @trigger_error('Passing an object as an input is deprecated since Symfony 2.5 and will be removed in 3.0.', E_USER_DEPRECATED);
  64074. return (string) $input;
  64075. }
  64076. throw new InvalidArgumentException(sprintf('%s only accepts strings or stream resources.', $caller));
  64077. }
  64078. return $input;
  64079. }
  64080. private static function isSurroundedBy($arg, $char)
  64081. {
  64082. return 2 < \strlen($arg) && $char === $arg[0] && $char === $arg[\strlen($arg) - 1];
  64083. }
  64084. }
  64085. <?php
  64086. if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
  64087. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  64088. }
  64089. setlocale(LC_ALL, 'C');
  64090. require __DIR__.'/../src/bootstrap.php';
  64091. use Composer\Console\Application;
  64092. use Composer\XdebugHandler\XdebugHandler;
  64093. error_reporting(-1);
  64094. // Restart without Xdebug
  64095. $xdebug = new XdebugHandler('Composer', '--ansi');
  64096. $xdebug->check();
  64097. unset($xdebug);
  64098. if (defined('HHVM_VERSION') && version_compare(HHVM_VERSION, '4.0', '>=')) {
  64099. echo 'HHVM 4.0 has dropped support for Composer, please use PHP instead. Aborting.'.PHP_EOL;
  64100. exit(1);
  64101. }
  64102. if (function_exists('ini_set')) {
  64103. @ini_set('display_errors', '1');
  64104. // Set user defined memory limit
  64105. if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
  64106. @ini_set('memory_limit', $memoryLimit);
  64107. } else {
  64108. $memoryInBytes = function ($value) {
  64109. $unit = strtolower(substr($value, -1, 1));
  64110. $value = (int) $value;
  64111. switch($unit) {
  64112. case 'g':
  64113. $value *= 1024;
  64114. // no break (cumulative multiplier)
  64115. case 'm':
  64116. $value *= 1024;
  64117. // no break (cumulative multiplier)
  64118. case 'k':
  64119. $value *= 1024;
  64120. }
  64121. return $value;
  64122. };
  64123. $memoryLimit = trim(ini_get('memory_limit'));
  64124. // Increase memory_limit if it is lower than 1.5GB
  64125. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  64126. @ini_set('memory_limit', '1536M');
  64127. }
  64128. unset($memoryInBytes);
  64129. }
  64130. unset($memoryLimit);
  64131. }
  64132. putenv('COMPOSER_BINARY='.realpath($_SERVER['argv'][0]));
  64133. // run the command application
  64134. $application = new Application();
  64135. $application->run();
  64136. Copyright (c) Nils Adermann, Jordi Boggiano
  64137. Permission is hereby granted, free of charge, to any person obtaining a copy
  64138. of this software and associated documentation files (the "Software"), to deal
  64139. in the Software without restriction, including without limitation the rights
  64140. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  64141. copies of the Software, and to permit persons to whom the Software is furnished
  64142. to do so, subject to the following conditions:
  64143. The above copyright notice and this permission notice shall be included in all
  64144. copies or substantial portions of the Software.
  64145. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  64146. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  64147. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  64148. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  64149. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  64150. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  64151. THE SOFTWARE.
  64152. °pÀêÛ'Xùòû ÓoaFn²���GBMB